aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-03-02 14:27:50 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-03-02 14:27:50 -0300
commit7b84f9e65c39542d16dc2b24bdfe5c07496f2042 (patch)
treea2f17d3ee9d40155bb12dbc096aa16a6414641fd
parent1e40b4dc615b7838305ea738bdd8e069adc0180f (diff)
downloadlua-7b84f9e65c39542d16dc2b24bdfe5c07496f2042.tar.gz
lua-7b84f9e65c39542d16dc2b24bdfe5c07496f2042.tar.bz2
lua-7b84f9e65c39542d16dc2b24bdfe5c07496f2042.zip
lower-case for macros with arguments
-rw-r--r--lapi.c206
-rw-r--r--ldebug.c26
-rw-r--r--ldo.c18
-rw-r--r--lgc.c14
-rw-r--r--lobject.h4
-rw-r--r--lstate.c10
-rw-r--r--lstate.h10
-rw-r--r--ltests.c4
-rw-r--r--ltests.h6
-rw-r--r--ltm.c14
10 files changed, 156 insertions, 156 deletions
diff --git a/lapi.c b/lapi.c
index d213ac9b..87131794 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.133 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: lapi.c,v 1.134 2001/02/23 17:28:12 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -70,9 +70,9 @@ void luaA_pushobject (lua_State *L, const TObject *o) {
70 70
71LUA_API int lua_stackspace (lua_State *L) { 71LUA_API int lua_stackspace (lua_State *L) {
72 int i; 72 int i;
73 LUA_LOCK(L); 73 lua_lock(L);
74 i = (L->stack_last - L->top); 74 i = (L->stack_last - L->top);
75 LUA_UNLOCK(L); 75 lua_unlock(L);
76 return i; 76 return i;
77} 77}
78 78
@@ -85,51 +85,51 @@ LUA_API int lua_stackspace (lua_State *L) {
85 85
86LUA_API int lua_gettop (lua_State *L) { 86LUA_API int lua_gettop (lua_State *L) {
87 int i; 87 int i;
88 LUA_LOCK(L); 88 lua_lock(L);
89 i = (L->top - L->Cbase); 89 i = (L->top - L->Cbase);
90 LUA_UNLOCK(L); 90 lua_unlock(L);
91 return i; 91 return i;
92} 92}
93 93
94 94
95LUA_API void lua_settop (lua_State *L, int index) { 95LUA_API void lua_settop (lua_State *L, int index) {
96 LUA_LOCK(L); 96 lua_lock(L);
97 if (index >= 0) 97 if (index >= 0)
98 luaD_adjusttop(L, L->Cbase, index); 98 luaD_adjusttop(L, L->Cbase, index);
99 else { 99 else {
100 api_check(L, -(index+1) <= (L->top - L->Cbase)); 100 api_check(L, -(index+1) <= (L->top - L->Cbase));
101 L->top = L->top+index+1; /* index is negative */ 101 L->top = L->top+index+1; /* index is negative */
102 } 102 }
103 LUA_UNLOCK(L); 103 lua_unlock(L);
104} 104}
105 105
106 106
107LUA_API void lua_remove (lua_State *L, int index) { 107LUA_API void lua_remove (lua_State *L, int index) {
108 StkId p; 108 StkId p;
109 LUA_LOCK(L); 109 lua_lock(L);
110 p = luaA_index(L, index); 110 p = luaA_index(L, index);
111 while (++p < L->top) setobj(p-1, p); 111 while (++p < L->top) setobj(p-1, p);
112 L->top--; 112 L->top--;
113 LUA_UNLOCK(L); 113 lua_unlock(L);
114} 114}
115 115
116 116
117LUA_API void lua_insert (lua_State *L, int index) { 117LUA_API void lua_insert (lua_State *L, int index) {
118 StkId p; 118 StkId p;
119 StkId q; 119 StkId q;
120 LUA_LOCK(L); 120 lua_lock(L);
121 p = luaA_index(L, index); 121 p = luaA_index(L, index);
122 for (q = L->top; q>p; q--) setobj(q, q-1); 122 for (q = L->top; q>p; q--) setobj(q, q-1);
123 setobj(p, L->top); 123 setobj(p, L->top);
124 LUA_UNLOCK(L); 124 lua_unlock(L);
125} 125}
126 126
127 127
128LUA_API void lua_pushvalue (lua_State *L, int index) { 128LUA_API void lua_pushvalue (lua_State *L, int index) {
129 LUA_LOCK(L); 129 lua_lock(L);
130 setobj(L->top, luaA_index(L, index)); 130 setobj(L->top, luaA_index(L, index));
131 api_incr_top(L); 131 api_incr_top(L);
132 LUA_UNLOCK(L); 132 lua_unlock(L);
133} 133}
134 134
135 135
@@ -142,19 +142,19 @@ LUA_API void lua_pushvalue (lua_State *L, int index) {
142LUA_API int lua_type (lua_State *L, int index) { 142LUA_API int lua_type (lua_State *L, int index) {
143 StkId o; 143 StkId o;
144 int i; 144 int i;
145 LUA_LOCK(L); 145 lua_lock(L);
146 o = luaA_indexAcceptable(L, index); 146 o = luaA_indexAcceptable(L, index);
147 i = (o == NULL) ? LUA_TNONE : ttype(o); 147 i = (o == NULL) ? LUA_TNONE : ttype(o);
148 LUA_UNLOCK(L); 148 lua_unlock(L);
149 return i; 149 return i;
150} 150}
151 151
152 152
153LUA_API const l_char *lua_typename (lua_State *L, int t) { 153LUA_API const l_char *lua_typename (lua_State *L, int t) {
154 const l_char *s; 154 const l_char *s;
155 LUA_LOCK(L); 155 lua_lock(L);
156 s = (t == LUA_TNONE) ? l_s("no value") : basictypename(G(L), t); 156 s = (t == LUA_TNONE) ? l_s("no value") : basictypename(G(L), t);
157 LUA_UNLOCK(L); 157 lua_unlock(L);
158 return s; 158 return s;
159} 159}
160 160
@@ -162,10 +162,10 @@ LUA_API const l_char *lua_typename (lua_State *L, int t) {
162LUA_API const l_char *lua_xtype (lua_State *L, int index) { 162LUA_API const l_char *lua_xtype (lua_State *L, int index) {
163 StkId o; 163 StkId o;
164 const l_char *type; 164 const l_char *type;
165 LUA_LOCK(L); 165 lua_lock(L);
166 o = luaA_indexAcceptable(L, index); 166 o = luaA_indexAcceptable(L, index);
167 type = (o == NULL) ? l_s("no value") : luaT_typename(G(L), o); 167 type = (o == NULL) ? l_s("no value") : luaT_typename(G(L), o);
168 LUA_UNLOCK(L); 168 lua_unlock(L);
169 return type; 169 return type;
170} 170}
171 171
@@ -173,20 +173,20 @@ LUA_API const l_char *lua_xtype (lua_State *L, int index) {
173LUA_API int lua_iscfunction (lua_State *L, int index) { 173LUA_API int lua_iscfunction (lua_State *L, int index) {
174 StkId o; 174 StkId o;
175 int i; 175 int i;
176 LUA_LOCK(L); 176 lua_lock(L);
177 o = luaA_indexAcceptable(L, index); 177 o = luaA_indexAcceptable(L, index);
178 i = (o == NULL) ? 0 : iscfunction(o); 178 i = (o == NULL) ? 0 : iscfunction(o);
179 LUA_UNLOCK(L); 179 lua_unlock(L);
180 return i; 180 return i;
181} 181}
182 182
183LUA_API int lua_isnumber (lua_State *L, int index) { 183LUA_API int lua_isnumber (lua_State *L, int index) {
184 TObject *o; 184 TObject *o;
185 int i; 185 int i;
186 LUA_LOCK(L); 186 lua_lock(L);
187 o = luaA_indexAcceptable(L, index); 187 o = luaA_indexAcceptable(L, index);
188 i = (o == NULL) ? 0 : (tonumber(o) == 0); 188 i = (o == NULL) ? 0 : (tonumber(o) == 0);
189 LUA_UNLOCK(L); 189 lua_unlock(L);
190 return i; 190 return i;
191} 191}
192 192
@@ -199,34 +199,34 @@ LUA_API int lua_isstring (lua_State *L, int index) {
199LUA_API int lua_tag (lua_State *L, int index) { 199LUA_API int lua_tag (lua_State *L, int index) {
200 StkId o; 200 StkId o;
201 int i; 201 int i;
202 LUA_LOCK(L); 202 lua_lock(L);
203 o = luaA_indexAcceptable(L, index); 203 o = luaA_indexAcceptable(L, index);
204 i = (o == NULL) ? LUA_NOTAG : luaT_tag(o); 204 i = (o == NULL) ? LUA_NOTAG : luaT_tag(o);
205 LUA_UNLOCK(L); 205 lua_unlock(L);
206 return i; 206 return i;
207} 207}
208 208
209LUA_API int lua_equal (lua_State *L, int index1, int index2) { 209LUA_API int lua_equal (lua_State *L, int index1, int index2) {
210 StkId o1, o2; 210 StkId o1, o2;
211 int i; 211 int i;
212 LUA_LOCK(L); 212 lua_lock(L);
213 o1 = luaA_indexAcceptable(L, index1); 213 o1 = luaA_indexAcceptable(L, index1);
214 o2 = luaA_indexAcceptable(L, index2); 214 o2 = luaA_indexAcceptable(L, index2);
215 i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */ 215 i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */
216 : luaO_equalObj(o1, o2); 216 : luaO_equalObj(o1, o2);
217 LUA_UNLOCK(L); 217 lua_unlock(L);
218 return i; 218 return i;
219} 219}
220 220
221LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { 221LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
222 StkId o1, o2; 222 StkId o1, o2;
223 int i; 223 int i;
224 LUA_LOCK(L); 224 lua_lock(L);
225 o1 = luaA_indexAcceptable(L, index1); 225 o1 = luaA_indexAcceptable(L, index1);
226 o2 = luaA_indexAcceptable(L, index2); 226 o2 = luaA_indexAcceptable(L, index2);
227 i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */ 227 i = (o1 == NULL || o2 == NULL) ? 0 /* index out-of-range */
228 : luaV_lessthan(L, o1, o2); 228 : luaV_lessthan(L, o1, o2);
229 LUA_UNLOCK(L); 229 lua_unlock(L);
230 return i; 230 return i;
231} 231}
232 232
@@ -235,58 +235,58 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
235LUA_API lua_Number lua_tonumber (lua_State *L, int index) { 235LUA_API lua_Number lua_tonumber (lua_State *L, int index) {
236 StkId o; 236 StkId o;
237 lua_Number n; 237 lua_Number n;
238 LUA_LOCK(L); 238 lua_lock(L);
239 o = luaA_indexAcceptable(L, index); 239 o = luaA_indexAcceptable(L, index);
240 n = (o == NULL || tonumber(o)) ? 0 : nvalue(o); 240 n = (o == NULL || tonumber(o)) ? 0 : nvalue(o);
241 LUA_UNLOCK(L); 241 lua_unlock(L);
242 return n; 242 return n;
243} 243}
244 244
245LUA_API const l_char *lua_tostring (lua_State *L, int index) { 245LUA_API const l_char *lua_tostring (lua_State *L, int index) {
246 StkId o; 246 StkId o;
247 const l_char *s; 247 const l_char *s;
248 LUA_LOCK(L); 248 lua_lock(L);
249 o = luaA_indexAcceptable(L, index); 249 o = luaA_indexAcceptable(L, index);
250 s = (o == NULL || tostring(L, o)) ? NULL : svalue(o); 250 s = (o == NULL || tostring(L, o)) ? NULL : svalue(o);
251 LUA_UNLOCK(L); 251 lua_unlock(L);
252 return s; 252 return s;
253} 253}
254 254
255LUA_API size_t lua_strlen (lua_State *L, int index) { 255LUA_API size_t lua_strlen (lua_State *L, int index) {
256 StkId o; 256 StkId o;
257 size_t l; 257 size_t l;
258 LUA_LOCK(L); 258 lua_lock(L);
259 o = luaA_indexAcceptable(L, index); 259 o = luaA_indexAcceptable(L, index);
260 l = (o == NULL || tostring(L, o)) ? 0 : tsvalue(o)->len; 260 l = (o == NULL || tostring(L, o)) ? 0 : tsvalue(o)->len;
261 LUA_UNLOCK(L); 261 lua_unlock(L);
262 return l; 262 return l;
263} 263}
264 264
265LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { 265LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
266 StkId o; 266 StkId o;
267 lua_CFunction f; 267 lua_CFunction f;
268 LUA_LOCK(L); 268 lua_lock(L);
269 o = luaA_indexAcceptable(L, index); 269 o = luaA_indexAcceptable(L, index);
270 f = (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->f.c; 270 f = (o == NULL || !iscfunction(o)) ? NULL : clvalue(o)->f.c;
271 LUA_UNLOCK(L); 271 lua_unlock(L);
272 return f; 272 return f;
273} 273}
274 274
275LUA_API void *lua_touserdata (lua_State *L, int index) { 275LUA_API void *lua_touserdata (lua_State *L, int index) {
276 StkId o; 276 StkId o;
277 void *p; 277 void *p;
278 LUA_LOCK(L); 278 lua_lock(L);
279 o = luaA_indexAcceptable(L, index); 279 o = luaA_indexAcceptable(L, index);
280 p = (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL : 280 p = (o == NULL || ttype(o) != LUA_TUSERDATA) ? NULL :
281 tsvalue(o)->u.d.value; 281 tsvalue(o)->u.d.value;
282 LUA_UNLOCK(L); 282 lua_unlock(L);
283 return p; 283 return p;
284} 284}
285 285
286LUA_API const void *lua_topointer (lua_State *L, int index) { 286LUA_API const void *lua_topointer (lua_State *L, int index) {
287 StkId o; 287 StkId o;
288 const void *p; 288 const void *p;
289 LUA_LOCK(L); 289 lua_lock(L);
290 o = luaA_indexAcceptable(L, index); 290 o = luaA_indexAcceptable(L, index);
291 if (o == NULL) p = NULL; 291 if (o == NULL) p = NULL;
292 else { 292 else {
@@ -302,7 +302,7 @@ LUA_API const void *lua_topointer (lua_State *L, int index) {
302 break; 302 break;
303 } 303 }
304 } 304 }
305 LUA_UNLOCK(L); 305 lua_unlock(L);
306 return p; 306 return p;
307} 307}
308 308
@@ -314,26 +314,26 @@ LUA_API const void *lua_topointer (lua_State *L, int index) {
314 314
315 315
316LUA_API void lua_pushnil (lua_State *L) { 316LUA_API void lua_pushnil (lua_State *L) {
317 LUA_LOCK(L); 317 lua_lock(L);
318 setnilvalue(L->top); 318 setnilvalue(L->top);
319 api_incr_top(L); 319 api_incr_top(L);
320 LUA_UNLOCK(L); 320 lua_unlock(L);
321} 321}
322 322
323 323
324LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { 324LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
325 LUA_LOCK(L); 325 lua_lock(L);
326 setnvalue(L->top, n); 326 setnvalue(L->top, n);
327 api_incr_top(L); 327 api_incr_top(L);
328 LUA_UNLOCK(L); 328 lua_unlock(L);
329} 329}
330 330
331 331
332LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) { 332LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) {
333 LUA_LOCK(L); 333 lua_lock(L);
334 setsvalue(L->top, luaS_newlstr(L, s, len)); 334 setsvalue(L->top, luaS_newlstr(L, s, len));
335 api_incr_top(L); 335 api_incr_top(L);
336 LUA_UNLOCK(L); 336 lua_unlock(L);
337} 337}
338 338
339 339
@@ -346,19 +346,19 @@ LUA_API void lua_pushstring (lua_State *L, const l_char *s) {
346 346
347 347
348LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { 348LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
349 LUA_LOCK(L); 349 lua_lock(L);
350 api_checknelems(L, n); 350 api_checknelems(L, n);
351 luaV_Cclosure(L, fn, n); 351 luaV_Cclosure(L, fn, n);
352 LUA_UNLOCK(L); 352 lua_unlock(L);
353} 353}
354 354
355 355
356LUA_API int lua_pushuserdata (lua_State *L, void *u) { 356LUA_API int lua_pushuserdata (lua_State *L, void *u) {
357 int isnew; 357 int isnew;
358 LUA_LOCK(L); 358 lua_lock(L);
359 isnew = luaS_createudata(L, u, L->top); 359 isnew = luaS_createudata(L, u, L->top);
360 api_incr_top(L); 360 api_incr_top(L);
361 LUA_UNLOCK(L); 361 lua_unlock(L);
362 return isnew; 362 return isnew;
363} 363}
364 364
@@ -370,54 +370,54 @@ LUA_API int lua_pushuserdata (lua_State *L, void *u) {
370 370
371 371
372LUA_API void lua_getglobal (lua_State *L, const l_char *name) { 372LUA_API void lua_getglobal (lua_State *L, const l_char *name) {
373 LUA_LOCK(L); 373 lua_lock(L);
374 luaV_getglobal(L, luaS_new(L, name), L->top); 374 luaV_getglobal(L, luaS_new(L, name), L->top);
375 api_incr_top(L); 375 api_incr_top(L);
376 LUA_UNLOCK(L); 376 lua_unlock(L);
377} 377}
378 378
379 379
380LUA_API void lua_gettable (lua_State *L, int index) { 380LUA_API void lua_gettable (lua_State *L, int index) {
381 StkId t; 381 StkId t;
382 LUA_LOCK(L); 382 lua_lock(L);
383 t = luaA_index(L, index); 383 t = luaA_index(L, index);
384 luaV_gettable(L, t, L->top-1, L->top-1); 384 luaV_gettable(L, t, L->top-1, L->top-1);
385 LUA_UNLOCK(L); 385 lua_unlock(L);
386} 386}
387 387
388 388
389LUA_API void lua_rawget (lua_State *L, int index) { 389LUA_API void lua_rawget (lua_State *L, int index) {
390 StkId t; 390 StkId t;
391 LUA_LOCK(L); 391 lua_lock(L);
392 t = luaA_index(L, index); 392 t = luaA_index(L, index);
393 api_check(L, ttype(t) == LUA_TTABLE); 393 api_check(L, ttype(t) == LUA_TTABLE);
394 setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1)); 394 setobj(L->top - 1, luaH_get(hvalue(t), L->top - 1));
395 LUA_UNLOCK(L); 395 lua_unlock(L);
396} 396}
397 397
398 398
399LUA_API void lua_rawgeti (lua_State *L, int index, int n) { 399LUA_API void lua_rawgeti (lua_State *L, int index, int n) {
400 StkId o; 400 StkId o;
401 LUA_LOCK(L); 401 lua_lock(L);
402 o = luaA_index(L, index); 402 o = luaA_index(L, index);
403 api_check(L, ttype(o) == LUA_TTABLE); 403 api_check(L, ttype(o) == LUA_TTABLE);
404 setobj(L->top, luaH_getnum(hvalue(o), n)); 404 setobj(L->top, luaH_getnum(hvalue(o), n));
405 api_incr_top(L); 405 api_incr_top(L);
406 LUA_UNLOCK(L); 406 lua_unlock(L);
407} 407}
408 408
409 409
410LUA_API void lua_getglobals (lua_State *L) { 410LUA_API void lua_getglobals (lua_State *L) {
411 LUA_LOCK(L); 411 lua_lock(L);
412 sethvalue(L->top, L->gt); 412 sethvalue(L->top, L->gt);
413 api_incr_top(L); 413 api_incr_top(L);
414 LUA_UNLOCK(L); 414 lua_unlock(L);
415} 415}
416 416
417 417
418LUA_API int lua_getref (lua_State *L, int ref) { 418LUA_API int lua_getref (lua_State *L, int ref) {
419 int status = 1; 419 int status = 1;
420 LUA_LOCK(L); 420 lua_lock(L);
421 if (ref == LUA_REFNIL) { 421 if (ref == LUA_REFNIL) {
422 setnilvalue(L->top); 422 setnilvalue(L->top);
423 api_incr_top(L); 423 api_incr_top(L);
@@ -431,16 +431,16 @@ LUA_API int lua_getref (lua_State *L, int ref) {
431 api_incr_top(L); 431 api_incr_top(L);
432 } 432 }
433 } 433 }
434 LUA_UNLOCK(L); 434 lua_unlock(L);
435 return status; 435 return status;
436} 436}
437 437
438 438
439LUA_API void lua_newtable (lua_State *L) { 439LUA_API void lua_newtable (lua_State *L) {
440 LUA_LOCK(L); 440 lua_lock(L);
441 sethvalue(L->top, luaH_new(L, 0)); 441 sethvalue(L->top, luaH_new(L, 0));
442 api_incr_top(L); 442 api_incr_top(L);
443 LUA_UNLOCK(L); 443 lua_unlock(L);
444} 444}
445 445
446 446
@@ -451,63 +451,63 @@ LUA_API void lua_newtable (lua_State *L) {
451 451
452 452
453LUA_API void lua_setglobal (lua_State *L, const l_char *name) { 453LUA_API void lua_setglobal (lua_State *L, const l_char *name) {
454 LUA_LOCK(L); 454 lua_lock(L);
455 api_checknelems(L, 1); 455 api_checknelems(L, 1);
456 luaV_setglobal(L, luaS_new(L, name), L->top - 1); 456 luaV_setglobal(L, luaS_new(L, name), L->top - 1);
457 L->top--; /* remove element from the top */ 457 L->top--; /* remove element from the top */
458 LUA_UNLOCK(L); 458 lua_unlock(L);
459} 459}
460 460
461 461
462LUA_API void lua_settable (lua_State *L, int index) { 462LUA_API void lua_settable (lua_State *L, int index) {
463 StkId t; 463 StkId t;
464 LUA_LOCK(L); 464 lua_lock(L);
465 api_checknelems(L, 2); 465 api_checknelems(L, 2);
466 t = luaA_index(L, index); 466 t = luaA_index(L, index);
467 luaV_settable(L, t, L->top - 2, L->top - 1); 467 luaV_settable(L, t, L->top - 2, L->top - 1);
468 L->top -= 2; /* pop index and value */ 468 L->top -= 2; /* pop index and value */
469 LUA_UNLOCK(L); 469 lua_unlock(L);
470} 470}
471 471
472 472
473LUA_API void lua_rawset (lua_State *L, int index) { 473LUA_API void lua_rawset (lua_State *L, int index) {
474 StkId t; 474 StkId t;
475 LUA_LOCK(L); 475 lua_lock(L);
476 api_checknelems(L, 2); 476 api_checknelems(L, 2);
477 t = luaA_index(L, index); 477 t = luaA_index(L, index);
478 api_check(L, ttype(t) == LUA_TTABLE); 478 api_check(L, ttype(t) == LUA_TTABLE);
479 setobj(luaH_set(L, hvalue(t), L->top-2), (L->top-1)); 479 setobj(luaH_set(L, hvalue(t), L->top-2), (L->top-1));
480 L->top -= 2; 480 L->top -= 2;
481 LUA_UNLOCK(L); 481 lua_unlock(L);
482} 482}
483 483
484 484
485LUA_API void lua_rawseti (lua_State *L, int index, int n) { 485LUA_API void lua_rawseti (lua_State *L, int index, int n) {
486 StkId o; 486 StkId o;
487 LUA_LOCK(L); 487 lua_lock(L);
488 api_checknelems(L, 1); 488 api_checknelems(L, 1);
489 o = luaA_index(L, index); 489 o = luaA_index(L, index);
490 api_check(L, ttype(o) == LUA_TTABLE); 490 api_check(L, ttype(o) == LUA_TTABLE);
491 setobj(luaH_setnum(L, hvalue(o), n), (L->top-1)); 491 setobj(luaH_setnum(L, hvalue(o), n), (L->top-1));
492 L->top--; 492 L->top--;
493 LUA_UNLOCK(L); 493 lua_unlock(L);
494} 494}
495 495
496 496
497LUA_API void lua_setglobals (lua_State *L) { 497LUA_API void lua_setglobals (lua_State *L) {
498 StkId newtable; 498 StkId newtable;
499 LUA_LOCK(L); 499 lua_lock(L);
500 api_checknelems(L, 1); 500 api_checknelems(L, 1);
501 newtable = --L->top; 501 newtable = --L->top;
502 api_check(L, ttype(newtable) == LUA_TTABLE); 502 api_check(L, ttype(newtable) == LUA_TTABLE);
503 L->gt = hvalue(newtable); 503 L->gt = hvalue(newtable);
504 LUA_UNLOCK(L); 504 lua_unlock(L);
505} 505}
506 506
507 507
508LUA_API int lua_ref (lua_State *L, int lock) { 508LUA_API int lua_ref (lua_State *L, int lock) {
509 int ref; 509 int ref;
510 LUA_LOCK(L); 510 lua_lock(L);
511 api_checknelems(L, 1); 511 api_checknelems(L, 1);
512 if (ttype(L->top-1) == LUA_TNIL) 512 if (ttype(L->top-1) == LUA_TNIL)
513 ref = LUA_REFNIL; 513 ref = LUA_REFNIL;
@@ -525,7 +525,7 @@ LUA_API int lua_ref (lua_State *L, int lock) {
525 G(L)->refArray[ref].st = lock ? LOCK : HOLD; 525 G(L)->refArray[ref].st = lock ? LOCK : HOLD;
526 } 526 }
527 L->top--; 527 L->top--;
528 LUA_UNLOCK(L); 528 lua_unlock(L);
529 return ref; 529 return ref;
530} 530}
531 531
@@ -536,10 +536,10 @@ LUA_API int lua_ref (lua_State *L, int lock) {
536*/ 536*/
537 537
538LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { 538LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
539 LUA_LOCK(L); 539 lua_lock(L);
540 api_checknelems(L, nargs+1); 540 api_checknelems(L, nargs+1);
541 luaD_call(L, L->top-(nargs+1), nresults); 541 luaD_call(L, L->top-(nargs+1), nresults);
542 LUA_UNLOCK(L); 542 lua_unlock(L);
543} 543}
544 544
545 545
@@ -553,28 +553,28 @@ LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
553 553
554LUA_API int lua_getgcthreshold (lua_State *L) { 554LUA_API int lua_getgcthreshold (lua_State *L) {
555 int threshold; 555 int threshold;
556 LUA_LOCK(L); 556 lua_lock(L);
557 threshold = GCscale(G(L)->GCthreshold); 557 threshold = GCscale(G(L)->GCthreshold);
558 LUA_UNLOCK(L); 558 lua_unlock(L);
559 return threshold; 559 return threshold;
560} 560}
561 561
562LUA_API int lua_getgccount (lua_State *L) { 562LUA_API int lua_getgccount (lua_State *L) {
563 int count; 563 int count;
564 LUA_LOCK(L); 564 lua_lock(L);
565 count = GCscale(G(L)->nblocks); 565 count = GCscale(G(L)->nblocks);
566 LUA_UNLOCK(L); 566 lua_unlock(L);
567 return count; 567 return count;
568} 568}
569 569
570LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { 570LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
571 LUA_LOCK(L); 571 lua_lock(L);
572 if (newthreshold > GCscale(ULONG_MAX)) 572 if (newthreshold > GCscale(ULONG_MAX))
573 G(L)->GCthreshold = ULONG_MAX; 573 G(L)->GCthreshold = ULONG_MAX;
574 else 574 else
575 G(L)->GCthreshold = GCunscale(newthreshold); 575 G(L)->GCthreshold = GCunscale(newthreshold);
576 luaC_checkGC(L); 576 luaC_checkGC(L);
577 LUA_UNLOCK(L); 577 lua_unlock(L);
578} 578}
579 579
580 580
@@ -584,7 +584,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
584 584
585LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) { 585LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
586 int tag; 586 int tag;
587 LUA_LOCK(L); 587 lua_lock(L);
588 if (basictype != LUA_TNONE && 588 if (basictype != LUA_TNONE &&
589 basictype != LUA_TTABLE && 589 basictype != LUA_TTABLE &&
590 basictype != LUA_TUSERDATA) 590 basictype != LUA_TUSERDATA)
@@ -592,7 +592,7 @@ LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
592 tag = luaT_newtag(L, name, basictype); 592 tag = luaT_newtag(L, name, basictype);
593 if (tag == LUA_TNONE) 593 if (tag == LUA_TNONE)
594 luaO_verror(L, l_s("type name '%.30s' already exists"), name); 594 luaO_verror(L, l_s("type name '%.30s' already exists"), name);
595 LUA_UNLOCK(L); 595 lua_unlock(L);
596 return tag; 596 return tag;
597} 597}
598 598
@@ -600,7 +600,7 @@ LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
600LUA_API int lua_type2tag (lua_State *L, const l_char *name) { 600LUA_API int lua_type2tag (lua_State *L, const l_char *name) {
601 int tag; 601 int tag;
602 const TObject *v; 602 const TObject *v;
603 LUA_LOCK(L); 603 lua_lock(L);
604 v = luaH_getstr(G(L)->type2tag, luaS_new(L, name)); 604 v = luaH_getstr(G(L)->type2tag, luaS_new(L, name));
605 if (ttype(v) == LUA_TNIL) 605 if (ttype(v) == LUA_TNIL)
606 tag = LUA_TNONE; 606 tag = LUA_TNONE;
@@ -608,14 +608,14 @@ LUA_API int lua_type2tag (lua_State *L, const l_char *name) {
608 lua_assert(ttype(v) == LUA_TNUMBER); 608 lua_assert(ttype(v) == LUA_TNUMBER);
609 tag = (int)nvalue(v); 609 tag = (int)nvalue(v);
610 } 610 }
611 LUA_UNLOCK(L); 611 lua_unlock(L);
612 return tag; 612 return tag;
613} 613}
614 614
615 615
616LUA_API void lua_settag (lua_State *L, int tag) { 616LUA_API void lua_settag (lua_State *L, int tag) {
617 int basictype; 617 int basictype;
618 LUA_LOCK(L); 618 lua_lock(L);
619 api_checknelems(L, 1); 619 api_checknelems(L, 1);
620 if (tag < 0 || tag >= G(L)->ntag) 620 if (tag < 0 || tag >= G(L)->ntag)
621 luaO_verror(L, l_s("%d is not a valid tag"), tag); 621 luaO_verror(L, l_s("%d is not a valid tag"), tag);
@@ -634,25 +634,25 @@ LUA_API void lua_settag (lua_State *L, int tag) {
634 luaO_verror(L, l_s("cannot change the tag of a %.20s"), 634 luaO_verror(L, l_s("cannot change the tag of a %.20s"),
635 luaT_typename(G(L), L->top-1)); 635 luaT_typename(G(L), L->top-1));
636 } 636 }
637 LUA_UNLOCK(L); 637 lua_unlock(L);
638} 638}
639 639
640 640
641LUA_API void lua_error (lua_State *L, const l_char *s) { 641LUA_API void lua_error (lua_State *L, const l_char *s) {
642 LUA_LOCK(L); 642 lua_lock(L);
643 luaD_error(L, s); 643 luaD_error(L, s);
644 LUA_UNLOCK(L); 644 lua_unlock(L);
645} 645}
646 646
647 647
648LUA_API void lua_unref (lua_State *L, int ref) { 648LUA_API void lua_unref (lua_State *L, int ref) {
649 LUA_LOCK(L); 649 lua_lock(L);
650 if (ref >= 0) { 650 if (ref >= 0) {
651 api_check(L, ref < G(L)->nref && G(L)->refArray[ref].st < 0); 651 api_check(L, ref < G(L)->nref && G(L)->refArray[ref].st < 0);
652 G(L)->refArray[ref].st = G(L)->refFree; 652 G(L)->refArray[ref].st = G(L)->refFree;
653 G(L)->refFree = ref; 653 G(L)->refFree = ref;
654 } 654 }
655 LUA_UNLOCK(L); 655 lua_unlock(L);
656} 656}
657 657
658 658
@@ -660,7 +660,7 @@ LUA_API int lua_next (lua_State *L, int index) {
660 StkId t; 660 StkId t;
661 Node *n; 661 Node *n;
662 int more; 662 int more;
663 LUA_LOCK(L); 663 lua_lock(L);
664 t = luaA_index(L, index); 664 t = luaA_index(L, index);
665 api_check(L, ttype(t) == LUA_TTABLE); 665 api_check(L, ttype(t) == LUA_TTABLE);
666 n = luaH_next(L, hvalue(t), luaA_index(L, -1)); 666 n = luaH_next(L, hvalue(t), luaA_index(L, -1));
@@ -674,7 +674,7 @@ LUA_API int lua_next (lua_State *L, int index) {
674 L->top -= 1; /* remove key */ 674 L->top -= 1; /* remove key */
675 more = 0; 675 more = 0;
676 } 676 }
677 LUA_UNLOCK(L); 677 lua_unlock(L);
678 return more; 678 return more;
679} 679}
680 680
@@ -683,7 +683,7 @@ LUA_API int lua_getn (lua_State *L, int index) {
683 Hash *h; 683 Hash *h;
684 const TObject *value; 684 const TObject *value;
685 int n; 685 int n;
686 LUA_LOCK(L); 686 lua_lock(L);
687 h = hvalue(luaA_index(L, index)); 687 h = hvalue(luaA_index(L, index));
688 value = luaH_getstr(h, luaS_newliteral(L, l_s("n"))); /* = h.n */ 688 value = luaH_getstr(h, luaS_newliteral(L, l_s("n"))); /* = h.n */
689 if (ttype(value) == LUA_TNUMBER) 689 if (ttype(value) == LUA_TNUMBER)
@@ -701,13 +701,13 @@ LUA_API int lua_getn (lua_State *L, int index) {
701 } 701 }
702 n = (int)max; 702 n = (int)max;
703 } 703 }
704 LUA_UNLOCK(L); 704 lua_unlock(L);
705 return n; 705 return n;
706} 706}
707 707
708 708
709LUA_API void lua_concat (lua_State *L, int n) { 709LUA_API void lua_concat (lua_State *L, int n) {
710 LUA_LOCK(L); 710 lua_lock(L);
711 api_checknelems(L, n); 711 api_checknelems(L, n);
712 if (n >= 2) { 712 if (n >= 2) {
713 luaV_strconc(L, n, L->top); 713 luaV_strconc(L, n, L->top);
@@ -719,20 +719,20 @@ LUA_API void lua_concat (lua_State *L, int n) {
719 api_incr_top(L); 719 api_incr_top(L);
720 } 720 }
721 /* else n == 1; nothing to do */ 721 /* else n == 1; nothing to do */
722 LUA_UNLOCK(L); 722 lua_unlock(L);
723} 723}
724 724
725 725
726LUA_API void *lua_newuserdata (lua_State *L, size_t size) { 726LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
727 TString *ts; 727 TString *ts;
728 void *p; 728 void *p;
729 LUA_LOCK(L); 729 lua_lock(L);
730 if (size == 0) size = 1; 730 if (size == 0) size = 1;
731 ts = luaS_newudata(L, size, NULL); 731 ts = luaS_newudata(L, size, NULL);
732 setuvalue(L->top, ts); 732 setuvalue(L->top, ts);
733 api_incr_top(L); 733 api_incr_top(L);
734 p = ts->u.d.value; 734 p = ts->u.d.value;
735 LUA_UNLOCK(L); 735 lua_unlock(L);
736 return p; 736 return p;
737} 737}
738 738
diff --git a/ldebug.c b/ldebug.c
index f425dc0b..c462768d 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.69 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.70 2001/02/23 20:30:52 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -42,20 +42,20 @@ static int isLmark (StkId o) {
42 42
43LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) { 43LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func) {
44 lua_Hook oldhook; 44 lua_Hook oldhook;
45 LUA_LOCK(L); 45 lua_lock(L);
46 oldhook = L->callhook; 46 oldhook = L->callhook;
47 L->callhook = func; 47 L->callhook = func;
48 LUA_UNLOCK(L); 48 lua_unlock(L);
49 return oldhook; 49 return oldhook;
50} 50}
51 51
52 52
53LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) { 53LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func) {
54 lua_Hook oldhook; 54 lua_Hook oldhook;
55 LUA_LOCK(L); 55 lua_lock(L);
56 oldhook = L->linehook; 56 oldhook = L->linehook;
57 L->linehook = func; 57 L->linehook = func;
58 LUA_UNLOCK(L); 58 lua_unlock(L);
59 return oldhook; 59 return oldhook;
60} 60}
61 61
@@ -76,14 +76,14 @@ static StkId aux_stackedfunction (lua_State *L, int level, StkId top) {
76LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { 76LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
77 StkId f; 77 StkId f;
78 int status; 78 int status;
79 LUA_LOCK(L); 79 lua_lock(L);
80 f = aux_stackedfunction(L, level, L->top); 80 f = aux_stackedfunction(L, level, L->top);
81 if (f == NULL) status = 0; /* there is no such level */ 81 if (f == NULL) status = 0; /* there is no such level */
82 else { 82 else {
83 ar->_func = f; 83 ar->_func = f;
84 status = 1; 84 status = 1;
85 } 85 }
86 LUA_UNLOCK(L); 86 lua_unlock(L);
87 return status; 87 return status;
88} 88}
89 89
@@ -162,7 +162,7 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
162 const l_char *name; 162 const l_char *name;
163 StkId f; 163 StkId f;
164 Proto *fp; 164 Proto *fp;
165 LUA_LOCK(L); 165 lua_lock(L);
166 name = NULL; 166 name = NULL;
167 f = ar->_func; 167 f = ar->_func;
168 fp = getluaproto(f); 168 fp = getluaproto(f);
@@ -171,7 +171,7 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
171 if (name) 171 if (name)
172 luaA_pushobject(L, (f+1)+(n-1)); /* push value */ 172 luaA_pushobject(L, (f+1)+(n-1)); /* push value */
173 } 173 }
174 LUA_UNLOCK(L); 174 lua_unlock(L);
175 return name; 175 return name;
176} 176}
177 177
@@ -180,7 +180,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
180 const l_char *name; 180 const l_char *name;
181 StkId f; 181 StkId f;
182 Proto *fp; 182 Proto *fp;
183 LUA_LOCK(L); 183 lua_lock(L);
184 name = NULL; 184 name = NULL;
185 f = ar->_func; 185 f = ar->_func;
186 fp = getluaproto(f); 186 fp = getluaproto(f);
@@ -192,7 +192,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
192 else 192 else
193 setobj((f+1)+(n-1), L->top); 193 setobj((f+1)+(n-1), L->top);
194 } 194 }
195 LUA_UNLOCK(L); 195 lua_unlock(L);
196 return name; 196 return name;
197} 197}
198 198
@@ -272,7 +272,7 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
272 StkId func; 272 StkId func;
273 int isactive; 273 int isactive;
274 int status = 1; 274 int status = 1;
275 LUA_LOCK(L); 275 lua_lock(L);
276 isactive = (*what != l_c('>')); 276 isactive = (*what != l_c('>'));
277 if (isactive) 277 if (isactive)
278 func = ar->_func; 278 func = ar->_func;
@@ -309,7 +309,7 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
309 } 309 }
310 } 310 }
311 if (!isactive) L->top--; /* pop function */ 311 if (!isactive) L->top--; /* pop function */
312 LUA_UNLOCK(L); 312 lua_unlock(L);
313 return status; 313 return status;
314} 314}
315 315
diff --git a/ldo.c b/ldo.c
index 5b42e302..fb6233be 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.128 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: ldo.c,v 1.129 2001/02/23 17:28:12 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -94,9 +94,9 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
94 StkId old_top = L->Cbase = L->top; 94 StkId old_top = L->Cbase = L->top;
95 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ 95 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
96 L->allowhooks = 0; /* cannot call hooks inside a hook */ 96 L->allowhooks = 0; /* cannot call hooks inside a hook */
97 LUA_UNLOCK(L); 97 lua_unlock(L);
98 (*hook)(L, ar); 98 (*hook)(L, ar);
99 LUA_LOCK(L); 99 lua_lock(L);
100 lua_assert(L->allowhooks == 0); 100 lua_assert(L->allowhooks == 0);
101 L->allowhooks = 1; 101 L->allowhooks = 1;
102 L->top = old_top; 102 L->top = old_top;
@@ -135,9 +135,9 @@ static StkId callCclosure (lua_State *L, const struct Closure *cl, StkId base) {
135 luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */ 135 luaD_checkstack(L, nup+LUA_MINSTACK); /* ensure minimum stack size */
136 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */ 136 for (n=0; n<nup; n++) /* copy upvalues as extra arguments */
137 setobj(L->top++, &cl->upvalue[n]); 137 setobj(L->top++, &cl->upvalue[n]);
138 LUA_UNLOCK(L); 138 lua_unlock(L);
139 n = (*cl->f.c)(L); /* do the actual call */ 139 n = (*cl->f.c)(L); /* do the actual call */
140 LUA_LOCK(L); 140 lua_lock(L);
141 L->Cbase = old_Cbase; /* restore old C base */ 141 L->Cbase = old_Cbase; /* restore old C base */
142 return L->top - n; /* return index of first result */ 142 return L->top - n; /* return index of first result */
143} 143}
@@ -212,13 +212,13 @@ LUA_API int lua_call (lua_State *L, int nargs, int nresults) {
212 StkId func; 212 StkId func;
213 struct CallS c; 213 struct CallS c;
214 int status; 214 int status;
215 LUA_LOCK(L); 215 lua_lock(L);
216 func = L->top - (nargs+1); /* function to be called */ 216 func = L->top - (nargs+1); /* function to be called */
217 c.func = func; c.nresults = nresults; 217 c.func = func; c.nresults = nresults;
218 status = luaD_runprotected(L, f_call, &c); 218 status = luaD_runprotected(L, f_call, &c);
219 if (status != 0) /* an error occurred? */ 219 if (status != 0) /* an error occurred? */
220 L->top = func; /* remove parameters from the stack */ 220 L->top = func; /* remove parameters from the stack */
221 LUA_UNLOCK(L); 221 lua_unlock(L);
222 return status; 222 return status;
223} 223}
224 224
@@ -242,7 +242,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
242 struct SParser p; 242 struct SParser p;
243 lu_mem old_blocks; 243 lu_mem old_blocks;
244 int status; 244 int status;
245 LUA_LOCK(L); 245 lua_lock(L);
246 p.z = z; p.bin = bin; 246 p.z = z; p.bin = bin;
247 /* before parsing, give a (good) chance to GC */ 247 /* before parsing, give a (good) chance to GC */
248 if (G(L)->nblocks/8 >= G(L)->GCthreshold/10) 248 if (G(L)->nblocks/8 >= G(L)->GCthreshold/10)
@@ -256,7 +256,7 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
256 } 256 }
257 else if (status == LUA_ERRRUN) /* an error occurred: correct error code */ 257 else if (status == LUA_ERRRUN) /* an error occurred: correct error code */
258 status = LUA_ERRSYNTAX; 258 status = LUA_ERRSYNTAX;
259 LUA_UNLOCK(L); 259 lua_unlock(L);
260 return status; 260 return status;
261} 261}
262 262
diff --git a/lgc.c b/lgc.c
index 9ab871bd..ff4ccaf0 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.91 2001/02/22 18:59:59 roberto Exp roberto $ 2** $Id: lgc.c,v 1.92 2001/02/23 17:17:25 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -21,12 +21,12 @@
21** optional lock for GC 21** optional lock for GC
22** (when Lua calls GC tag methods it unlocks the regular lock) 22** (when Lua calls GC tag methods it unlocks the regular lock)
23*/ 23*/
24#ifndef LUA_LOCKGC 24#ifndef lua_lockgc
25#define LUA_LOCKGC(L) { 25#define lua_lockgc(L) {
26#endif 26#endif
27 27
28#ifndef LUA_UNLOCKGC 28#ifndef lua_unlockgc
29#define LUA_UNLOCKGC(L) } 29#define lua_unlockgc(L) }
30#endif 30#endif
31 31
32 32
@@ -369,14 +369,14 @@ static void callgcTMudata (lua_State *L) {
369 369
370 370
371void luaC_collect (lua_State *L, int all) { 371void luaC_collect (lua_State *L, int all) {
372 LUA_LOCKGC(L); 372 lua_lockgc(L);
373 collectudata(L, all); 373 collectudata(L, all);
374 callgcTMudata(L); 374 callgcTMudata(L);
375 collectstrings(L, all); 375 collectstrings(L, all);
376 collecttable(L); 376 collecttable(L);
377 collectproto(L); 377 collectproto(L);
378 collectclosure(L); 378 collectclosure(L);
379 LUA_UNLOCKGC(L); 379 lua_unlockgc(L);
380} 380}
381 381
382 382
diff --git a/lobject.h b/lobject.h
index 56fc7346..16c3f53e 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.98 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: lobject.h,v 1.99 2001/02/23 20:32:32 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -117,7 +117,7 @@ union L_UTString {
117 117
118 118
119 119
120#define getstr(ts) ((l_char *)((lu_byte *)(ts) + sizeof(union L_UTString))) 120#define getstr(ts) ((l_char *)((union L_UTString *)(ts) + 1))
121#define svalue(o) getstr(tsvalue(o)) 121#define svalue(o) getstr(tsvalue(o))
122 122
123 123
diff --git a/lstate.c b/lstate.c
index 7e53c5a2..2b16a4eb 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.56 2001/02/02 15:13:05 roberto Exp roberto $ 2** $Id: lstate.c,v 1.57 2001/02/23 17:17:25 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -93,7 +93,7 @@ static void f_luaopen (lua_State *L, void *ud) {
93LUA_API lua_State *lua_open (lua_State *OL, int stacksize) { 93LUA_API lua_State *lua_open (lua_State *OL, int stacksize) {
94 struct Sopen so; 94 struct Sopen so;
95 lua_State *L; 95 lua_State *L;
96 if (OL) LUA_LOCK(OL); 96 if (OL) lua_lock(OL);
97 L = luaM_new(OL, lua_State); 97 L = luaM_new(OL, lua_State);
98 if (L) { /* allocation OK? */ 98 if (L) { /* allocation OK? */
99 L->G = NULL; 99 L->G = NULL;
@@ -112,7 +112,7 @@ LUA_API lua_State *lua_open (lua_State *OL, int stacksize) {
112 L = NULL; 112 L = NULL;
113 } 113 }
114 } 114 }
115 if (OL) LUA_UNLOCK(OL); 115 if (OL) lua_unlock(OL);
116 return L; 116 return L;
117} 117}
118 118
@@ -141,11 +141,11 @@ static void close_state (lua_State *L, lua_State *OL) {
141LUA_API void lua_close (lua_State *L) { 141LUA_API void lua_close (lua_State *L) {
142 lua_State *OL; 142 lua_State *OL;
143 lua_assert(L != lua_state || lua_gettop(L) == 0); 143 lua_assert(L != lua_state || lua_gettop(L) == 0);
144 LUA_LOCK(L); 144 lua_lock(L);
145 OL = L->next; /* any surviving thread (if there is one) */ 145 OL = L->next; /* any surviving thread (if there is one) */
146 if (OL == L) OL = NULL; /* no surviving threads */ 146 if (OL == L) OL = NULL; /* no surviving threads */
147 close_state(L, OL); 147 close_state(L, OL);
148 if (OL) LUA_UNLOCK(OL); /* cannot unlock over a freed state */ 148 if (OL) lua_unlock(OL); /* cannot unlock over a freed state */
149 lua_assert(L != lua_state || memdebug_numblocks == 0); 149 lua_assert(L != lua_state || memdebug_numblocks == 0);
150 lua_assert(L != lua_state || memdebug_total == 0); 150 lua_assert(L != lua_state || memdebug_total == 0);
151} 151}
diff --git a/lstate.h b/lstate.h
index 757d46c3..21348211 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 1.52 2001/02/23 17:17:25 roberto Exp roberto $ 2** $Id: lstate.h,v 1.53 2001/02/23 20:30:01 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -16,12 +16,12 @@
16** macros that control all entries and exits from Lua core machine 16** macros that control all entries and exits from Lua core machine
17** (mainly for thread syncronization) 17** (mainly for thread syncronization)
18*/ 18*/
19#ifndef LUA_LOCK 19#ifndef lua_lock
20#define LUA_LOCK(L) ((void) 0) 20#define lua_lock(L) ((void) 0)
21#endif 21#endif
22 22
23#ifndef LUA_UNLOCK 23#ifndef lua_unlock
24#define LUA_UNLOCK(L) ((void) 0) 24#define lua_unlock(L) ((void) 0)
25#endif 25#endif
26 26
27/* 27/*
diff --git a/ltests.c b/ltests.c
index 5cc9f99a..bf609156 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.71 2001/02/22 18:59:59 roberto Exp roberto $ 2** $Id: ltests.c,v 1.72 2001/02/23 17:17:25 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -432,7 +432,7 @@ static int loadlib (lua_State *L) {
432static int closestate (lua_State *L) { 432static int closestate (lua_State *L) {
433 lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); 433 lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1);
434 lua_close(L1); 434 lua_close(L1);
435 LUA_UNLOCK(L); /* close cannot unlock that */ 435 lua_unlock(L); /* close cannot unlock that */
436 return 0; 436 return 0;
437} 437}
438 438
diff --git a/ltests.h b/ltests.h
index 2d7a4822..6cbb9810 100644
--- a/ltests.h
+++ b/ltests.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.h,v 1.4 2001/02/06 18:18:58 roberto Exp roberto $ 2** $Id: ltests.h,v 1.5 2001/02/12 15:42:44 roberto Exp roberto $
3** Internal Header for Debugging of the Lua Implementation 3** Internal Header for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,8 +41,8 @@ void *debug_realloc (void *block, size_t oldsize, size_t size);
41/* test for lock/unlock */ 41/* test for lock/unlock */
42#define LUA_USERSTATE int *lock; 42#define LUA_USERSTATE int *lock;
43extern int islocked; 43extern int islocked;
44#define LUA_LOCK(L) lua_assert((**((int **)L))++ == 0) 44#define lua_lock(L) lua_assert((**((int **)L))++ == 0)
45#define LUA_UNLOCK(L) lua_assert(--(**((int **)L)) == 0) 45#define lua_unlock(L) lua_assert(--(**((int **)L)) == 0)
46 46
47 47
48extern lua_State *lua_state; 48extern lua_State *lua_state;
diff --git a/ltm.c b/ltm.c
index aff4a227..df30955b 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.68 2001/02/22 18:59:59 roberto Exp roberto $ 2** $Id: ltm.c,v 1.69 2001/02/23 17:17:25 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -111,14 +111,14 @@ static void checktag (lua_State *L, int tag) {
111 111
112LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { 112LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
113 int e; 113 int e;
114 LUA_LOCK(L); 114 lua_lock(L);
115 checktag(L, tagto); 115 checktag(L, tagto);
116 checktag(L, tagfrom); 116 checktag(L, tagfrom);
117 for (e=0; e<TM_N; e++) { 117 for (e=0; e<TM_N; e++) {
118 if (luaT_validevent(tagto, e)) 118 if (luaT_validevent(tagto, e))
119 luaT_gettm(G(L), tagto, e) = luaT_gettm(G(L), tagfrom, e); 119 luaT_gettm(G(L), tagto, e) = luaT_gettm(G(L), tagfrom, e);
120 } 120 }
121 LUA_UNLOCK(L); 121 lua_unlock(L);
122 return tagto; 122 return tagto;
123} 123}
124 124
@@ -156,7 +156,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) {
156 156
157LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) { 157LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
158 int e; 158 int e;
159 LUA_LOCK(L); 159 lua_lock(L);
160 e = luaI_checkevent(L, event, t); 160 e = luaI_checkevent(L, event, t);
161 checktag(L, t); 161 checktag(L, t);
162 if (luaT_validevent(t, e) && luaT_gettm(G(L), t, e)) { 162 if (luaT_validevent(t, e) && luaT_gettm(G(L), t, e)) {
@@ -165,13 +165,13 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
165 else 165 else
166 setnilvalue(L->top); 166 setnilvalue(L->top);
167 incr_top; 167 incr_top;
168 LUA_UNLOCK(L); 168 lua_unlock(L);
169} 169}
170 170
171 171
172LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) { 172LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
173 int e; 173 int e;
174 LUA_LOCK(L); 174 lua_lock(L);
175 e = luaI_checkevent(L, event, t); 175 e = luaI_checkevent(L, event, t);
176 checktag(L, t); 176 checktag(L, t);
177 if (!luaT_validevent(t, e)) 177 if (!luaT_validevent(t, e))
@@ -190,6 +190,6 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
190 luaD_error(L, l_s("tag method must be a function (or nil)")); 190 luaD_error(L, l_s("tag method must be a function (or nil)"));
191 } 191 }
192 L->top--; 192 L->top--;
193 LUA_UNLOCK(L); 193 lua_unlock(L);
194} 194}
195 195