summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ltests.c9
-rw-r--r--ltests.h5
2 files changed, 11 insertions, 3 deletions
diff --git a/ltests.c b/ltests.c
index 33dc272a..72a448bd 100644
--- a/ltests.c
+++ b/ltests.c
@@ -254,6 +254,13 @@ static int hash_query (lua_State *L) {
254} 254}
255 255
256 256
257static int Cstacklevel (lua_State *L) {
258 unsigned long a = 0;
259 lua_pushnumber(L, (unsigned long)&a);
260 return 1;
261}
262
263
257static int table_query (lua_State *L) { 264static int table_query (lua_State *L) {
258 const Table *t; 265 const Table *t;
259 int i = luaL_opt_int(L, 2, -1); 266 int i = luaL_opt_int(L, 2, -1);
@@ -368,7 +375,6 @@ static int udataval (lua_State *L) {
368static int doonnewstack (lua_State *L) { 375static int doonnewstack (lua_State *L) {
369 lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1)); 376 lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1));
370 if (L1 == NULL) return 0; 377 if (L1 == NULL) return 0;
371 *cast(int **, L1) = &islocked; /* initialize the lock */
372 lua_dostring(L1, luaL_check_string(L, 2)); 378 lua_dostring(L1, luaL_check_string(L, 2));
373 lua_pushnumber(L, 1); 379 lua_pushnumber(L, 1);
374 lua_close(L1); 380 lua_close(L1);
@@ -624,6 +630,7 @@ static const struct luaL_reg tests_funcs[] = {
624 {"listk", listk}, 630 {"listk", listk},
625 {"listlocals", listlocals}, 631 {"listlocals", listlocals},
626 {"loadlib", loadlib}, 632 {"loadlib", loadlib},
633 {"Cstacklevel", Cstacklevel},
627 {"querystr", string_query}, 634 {"querystr", string_query},
628 {"querytab", table_query}, 635 {"querytab", table_query},
629 {"testC", testC}, 636 {"testC", testC},
diff --git a/ltests.h b/ltests.h
index 859ca9ca..18b703a6 100644
--- a/ltests.h
+++ b/ltests.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.h,v 1.8 2001/08/31 19:46:07 roberto Exp $ 2** $Id: ltests.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
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,9 @@ void *debug_realloc (void *block, size_t oldsize, size_t size);
41 41
42 42
43/* test for lock/unlock */ 43/* test for lock/unlock */
44#define LUA_USERSTATE int *lock;
45extern int islocked; 44extern int islocked;
45#define LUA_USERSTATE int *lock;
46#define lua_userstateopen(l) if (l != NULL) *cast(int **, l) = &islocked;
46#define lua_lock(L) lua_assert((**cast(int **, L))++ == 0) 47#define lua_lock(L) lua_assert((**cast(int **, L))++ == 0)
47#define lua_unlock(L) lua_assert(--(**cast(int **, L)) == 0) 48#define lua_unlock(L) lua_assert(--(**cast(int **, L)) == 0)
48 49