aboutsummaryrefslogtreecommitdiff
path: root/ltests.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-24 11:00:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-24 11:00:16 -0300
commitbaa0e234564a5ceca4211486d1cc70be55a070a2 (patch)
tree3531beba9d415363ff80140b68c369a5646d75ff /ltests.h
parent55a710545c811f3ccb6aea6232657015f474139f (diff)
downloadlua-baa0e234564a5ceca4211486d1cc70be55a070a2.tar.gz
lua-baa0e234564a5ceca4211486d1cc70be55a070a2.tar.bz2
lua-baa0e234564a5ceca4211486d1cc70be55a070a2.zip
better support for extra user space associated with a Lua state
Diffstat (limited to 'ltests.h')
-rw-r--r--ltests.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/ltests.h b/ltests.h
index 4ff0675f..805f46ed 100644
--- a/ltests.h
+++ b/ltests.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.h,v 2.36 2014/07/23 16:47:47 roberto Exp roberto $ 2** $Id: ltests.h,v 2.37 2014/07/23 17:16:50 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*/
@@ -64,14 +64,15 @@ int lua_checkmemory (lua_State *L);
64/* test for lock/unlock */ 64/* test for lock/unlock */
65 65
66struct L_EXTRA { int lock; int *plock; }; 66struct L_EXTRA { int lock; int *plock; };
67/* extra space before a Lua state (+1 to make it unaligned) */ 67#undef LUA_EXTRASPACE
68#define LUAI_EXTRASPACE (sizeof(struct L_EXTRA) + 1) 68#define LUA_EXTRASPACE sizeof(struct L_EXTRA)
69#define getlock(l) (cast(struct L_EXTRA *, l) - 1) 69#define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l))
70#define luai_userstateopen(l) \ 70#define luai_userstateopen(l) \
71 (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) 71 (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock))
72#define luai_userstateclose(l) \ 72#define luai_userstateclose(l) \
73 lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock)) 73 lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock))
74#define luai_userstatethread(l,l1) (getlock(l1)->plock = getlock(l)->plock) 74#define luai_userstatethread(l,l1) \
75 lua_assert(getlock(l1)->plock == getlock(l)->plock)
75#define luai_userstatefree(l,l1) \ 76#define luai_userstatefree(l,l1) \
76 lua_assert(getlock(l)->plock == getlock(l1)->plock) 77 lua_assert(getlock(l)->plock == getlock(l1)->plock)
77#define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) 78#define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0)