2 ** $Id: ltests.h,v 2.50.1.1 2017/04/19 17:20:42 roberto Exp $
3 ** Internal Header for Debugging of the Lua Implementation
4 ** See Copyright Notice in lua.h
13 /* test Lua with no compatibility code */
14 #undef LUA_COMPAT_MATHLIB
15 #undef LUA_COMPAT_IPAIRS
16 #undef LUA_COMPAT_BITLIB
17 #undef LUA_COMPAT_APIINTCASTS
18 #undef LUA_COMPAT_FLOATSTRING
19 #undef LUA_COMPAT_UNPACK
20 #undef LUA_COMPAT_LOADERS
21 #undef LUA_COMPAT_LOG10
22 #undef LUA_COMPAT_LOADSTRING
23 #undef LUA_COMPAT_MAXN
24 #undef LUA_COMPAT_MODULE
30 /* turn on assertions */
33 #define lua_assert(c) assert(c)
36 /* to avoid warnings, and to make sure value is really unused */
37 #define UNUSED(x) (x=0, (void)(x))
40 /* test for sizes in 'l_sprintf' (make sure whole buffer is available) */
42 #if !defined(LUA_USE_C89)
43 #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), snprintf(s,sz,f,i))
45 #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), sprintf(s,f,i))
49 /* memory-allocator control variables */
50 typedef struct Memcontrol
{
51 unsigned long numblocks
;
54 unsigned long memlimit
;
55 unsigned long objcount
[LUA_NUMTAGS
];
58 LUA_API Memcontrol l_memcontrol
;
62 ** generic variable for debug tricks
69 ** Function to traverse and check all memory used by Lua
71 int lua_checkmemory (lua_State
*L
);
74 /* test for lock/unlock */
76 struct L_EXTRA
{ int lock
; int *plock
; };
78 #define LUA_EXTRASPACE sizeof(struct L_EXTRA)
79 #define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l))
80 #define luai_userstateopen(l) \
81 (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock))
82 #define luai_userstateclose(l) \
83 lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock))
84 #define luai_userstatethread(l,l1) \
85 lua_assert(getlock(l1)->plock == getlock(l)->plock)
86 #define luai_userstatefree(l,l1) \
87 lua_assert(getlock(l)->plock == getlock(l1)->plock)
88 #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0)
89 #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0)
93 LUA_API
int luaB_opentests (lua_State
*L
);
95 LUA_API
void *debug_realloc (void *ud
, void *block
,
96 size_t osize
, size_t nsize
);
99 #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol)
100 #define luaL_openlibs(L) \
101 { (luaL_openlibs)(L); \
102 luaL_requiref(L, "T", luaB_opentests, 1); \
108 /* change some sizes to give some bugs a chance */
110 #undef LUAL_BUFFERSIZE
111 #define LUAL_BUFFERSIZE 23
112 #define MINSTRTABSIZE 2
116 /* make stack-overflow tests run faster */
118 #define LUAI_MAXSTACK 50000
121 #undef LUAI_USER_ALIGNMENT_T
122 #define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; }
125 #define STRCACHE_N 23