diff options
Diffstat (limited to 'ltests.h')
-rw-r--r-- | ltests.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/ltests.h b/ltests.h new file mode 100644 index 00000000..7a9d329d --- /dev/null +++ b/ltests.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | ** $Id: ltests.h,v 2.33 2010/07/28 15:51:59 roberto Exp $ | ||
3 | ** Internal Header for Debugging of the Lua Implementation | ||
4 | ** See Copyright Notice in lua.h | ||
5 | */ | ||
6 | |||
7 | #ifndef ltests_h | ||
8 | #define ltests_h | ||
9 | |||
10 | |||
11 | #include <stdlib.h> | ||
12 | |||
13 | /* do not use compatibility macros in Lua code */ | ||
14 | #undef LUA_COMPAT_API | ||
15 | |||
16 | #define LUA_DEBUG | ||
17 | |||
18 | #undef NDEBUG | ||
19 | #include <assert.h> | ||
20 | #define lua_assert(c) assert(c) | ||
21 | |||
22 | |||
23 | /* to avoid warnings, and to make sure value is really unused */ | ||
24 | #define UNUSED(x) (x=0, (void)(x)) | ||
25 | |||
26 | |||
27 | /* memory allocator control variables */ | ||
28 | typedef struct Memcontrol { | ||
29 | unsigned long numblocks; | ||
30 | unsigned long total; | ||
31 | unsigned long maxmem; | ||
32 | unsigned long memlimit; | ||
33 | unsigned long objcount[LUA_NUMTAGS]; | ||
34 | } Memcontrol; | ||
35 | |||
36 | extern Memcontrol l_memcontrol; | ||
37 | |||
38 | |||
39 | /* | ||
40 | ** generic variable for debug tricks | ||
41 | */ | ||
42 | extern void *l_Trick; | ||
43 | |||
44 | |||
45 | void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize); | ||
46 | |||
47 | |||
48 | typedef struct CallInfo *pCallInfo; | ||
49 | |||
50 | int lua_checkmemory (lua_State *L); | ||
51 | |||
52 | |||
53 | /* test for lock/unlock */ | ||
54 | #undef luai_userstateopen | ||
55 | #undef luai_userstatethread | ||
56 | #undef lua_lock | ||
57 | #undef lua_unlock | ||
58 | |||
59 | struct L_EXTRA { int lock; int *plock; }; | ||
60 | #define LUAI_EXTRASPACE sizeof(struct L_EXTRA) | ||
61 | #define getlock(l) (cast(struct L_EXTRA *, l) - 1) | ||
62 | #define luai_userstateopen(l) \ | ||
63 | (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock)) | ||
64 | #define luai_userstatethread(l,l1) (getlock(l1)->plock = getlock(l)->plock) | ||
65 | #define luai_userstatefree(l,l1) \ | ||
66 | lua_assert(getlock(l)->plock == getlock(l1)->plock) | ||
67 | #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0) | ||
68 | #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0) | ||
69 | |||
70 | |||
71 | int luaB_opentests (lua_State *L); | ||
72 | |||
73 | |||
74 | #if defined(lua_c) | ||
75 | #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol) | ||
76 | #define luaL_openlibs(L) \ | ||
77 | { (luaL_openlibs)(L); luaL_requiref(L, "T", luaB_opentests, 1); } | ||
78 | #endif | ||
79 | |||
80 | |||
81 | |||
82 | /* change some sizes to give some bugs a chance */ | ||
83 | |||
84 | #undef LUAL_BUFFERSIZE | ||
85 | #define LUAL_BUFFERSIZE 23 | ||
86 | #define MINSTRTABSIZE 2 | ||
87 | |||
88 | |||
89 | #undef LUAI_USER_ALIGNMENT_T | ||
90 | #define LUAI_USER_ALIGNMENT_T union { char b[32]; } | ||
91 | |||
92 | |||
93 | #endif | ||