mirror of
https://github.com/lua/lua.git
synced 2024-11-27 20:23:55 +08:00
new macro lua_userstateopen
This commit is contained in:
parent
b3bb0f132b
commit
ea2a75d19e
9
ltests.c
9
ltests.c
@ -254,6 +254,13 @@ static int hash_query (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int Cstacklevel (lua_State *L) {
|
||||||
|
unsigned long a = 0;
|
||||||
|
lua_pushnumber(L, (unsigned long)&a);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int table_query (lua_State *L) {
|
static int table_query (lua_State *L) {
|
||||||
const Table *t;
|
const Table *t;
|
||||||
int i = luaL_opt_int(L, 2, -1);
|
int i = luaL_opt_int(L, 2, -1);
|
||||||
@ -368,7 +375,6 @@ static int udataval (lua_State *L) {
|
|||||||
static int doonnewstack (lua_State *L) {
|
static int doonnewstack (lua_State *L) {
|
||||||
lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1));
|
lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1));
|
||||||
if (L1 == NULL) return 0;
|
if (L1 == NULL) return 0;
|
||||||
*cast(int **, L1) = &islocked; /* initialize the lock */
|
|
||||||
lua_dostring(L1, luaL_check_string(L, 2));
|
lua_dostring(L1, luaL_check_string(L, 2));
|
||||||
lua_pushnumber(L, 1);
|
lua_pushnumber(L, 1);
|
||||||
lua_close(L1);
|
lua_close(L1);
|
||||||
@ -624,6 +630,7 @@ static const struct luaL_reg tests_funcs[] = {
|
|||||||
{"listk", listk},
|
{"listk", listk},
|
||||||
{"listlocals", listlocals},
|
{"listlocals", listlocals},
|
||||||
{"loadlib", loadlib},
|
{"loadlib", loadlib},
|
||||||
|
{"Cstacklevel", Cstacklevel},
|
||||||
{"querystr", string_query},
|
{"querystr", string_query},
|
||||||
{"querytab", table_query},
|
{"querytab", table_query},
|
||||||
{"testC", testC},
|
{"testC", testC},
|
||||||
|
5
ltests.h
5
ltests.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.h,v 1.8 2001/08/31 19:46:07 roberto Exp $
|
** $Id: ltests.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
|
||||||
** Internal Header for Debugging of the Lua Implementation
|
** Internal Header for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -41,8 +41,9 @@ void *debug_realloc (void *block, size_t oldsize, size_t size);
|
|||||||
|
|
||||||
|
|
||||||
/* test for lock/unlock */
|
/* test for lock/unlock */
|
||||||
#define LUA_USERSTATE int *lock;
|
|
||||||
extern int islocked;
|
extern int islocked;
|
||||||
|
#define LUA_USERSTATE int *lock;
|
||||||
|
#define lua_userstateopen(l) if (l != NULL) *cast(int **, l) = &islocked;
|
||||||
#define lua_lock(L) lua_assert((**cast(int **, L))++ == 0)
|
#define lua_lock(L) lua_assert((**cast(int **, L))++ == 0)
|
||||||
#define lua_unlock(L) lua_assert(--(**cast(int **, L)) == 0)
|
#define lua_unlock(L) lua_assert(--(**cast(int **, L)) == 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user