sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ltests.h
Go to the documentation of this file.
1/*
2** $Id: ltests.h $
3** Internal Header for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h
5*/
6
11#ifndef ltests_h
12#define ltests_h
13
14
15#include <stdio.h>
16#include <stdlib.h>
17
18/* test Lua with compatibility code */
19#define LUA_COMPAT_MATHLIB
20#define LUA_COMPAT_LT_LE
21
22
23#define LUA_DEBUG
24
25
26/* turn on assertions */
27#define LUAI_ASSERT
28
29
30/* to avoid warnings, and to make sure value is really unused */
31#define UNUSED(x) (x=0, (void)(x))
32
33
34/* test for sizes in 'l_sprintf' (make sure whole buffer is available) */
35#undef l_sprintf
36#if !defined(LUA_USE_C89)
37#define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), snprintf(s,sz,f,i))
38#else
39#define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), sprintf(s,f,i))
40#endif
41
42
43/* get a chance to test code without jump tables */
44#define LUA_USE_JUMPTABLE 0
45
46
47/* use 32-bit integers in random generator */
48#define LUA_RAND32
49
50
51/* memory-allocator control variables */
52typedef struct Memcontrol {
53 int failnext;
54 unsigned long numblocks;
55 unsigned long total;
56 unsigned long maxmem;
57 unsigned long memlimit;
58 unsigned long countlimit;
59 unsigned long objcount[LUA_NUMTYPES];
61
62LUA_API Memcontrol l_memcontrol;
63
64
65/*
66** generic variable for debug tricks
67*/
68extern void *l_Trick;
69
70
71
72/*
73** Function to traverse and check all memory used by Lua
74*/
75LUAI_FUNC int lua_checkmemory (lua_State *L);
76
77/*
78** Function to print an object GC-friendly
79*/
80struct GCObject;
81LUAI_FUNC void lua_printobj (lua_State *L, struct GCObject *o);
82
83
84/* test for lock/unlock */
85
86struct L_EXTRA { int lock; int *plock; };
87#undef LUA_EXTRASPACE
88#define LUA_EXTRASPACE sizeof(struct L_EXTRA)
89#define getlock(l) cast(struct L_EXTRA*, lua_getextraspace(l))
90#define luai_userstateopen(l) \
91 (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock))
92#define luai_userstateclose(l) \
93 lua_assert(getlock(l)->lock == 1 && getlock(l)->plock == &(getlock(l)->lock))
94#define luai_userstatethread(l,l1) \
95 lua_assert(getlock(l1)->plock == getlock(l)->plock)
96#define luai_userstatefree(l,l1) \
97 lua_assert(getlock(l)->plock == getlock(l1)->plock)
98#define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0)
99#define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0)
100
101
102
103LUA_API int luaB_opentests (lua_State *L);
104
105LUA_API void *debug_realloc (void *ud, void *block,
106 size_t osize, size_t nsize);
107
108#if defined(lua_c)
109#define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol)
110#define luaL_openlibs(L) \
111 { (luaL_openlibs)(L); \
112 luaL_requiref(L, "T", luaB_opentests, 1); \
113 lua_pop(L, 1); }
114#endif
115
116
117
118/* change some sizes to give some bugs a chance */
119
120#undef LUAL_BUFFERSIZE
121#define LUAL_BUFFERSIZE 23
122#define MINSTRTABSIZE 2
123#define MAXIWTHABS 3
124
125#define STRCACHE_N 23
126#define STRCACHE_M 5
127
128#undef LUAI_USER_ALIGNMENT_T
129#define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; }
130
131
132/*
133** This one is not compatible with tests for opcode optimizations,
134** as it blocks some optimizations
135#define MAXINDEXRK 0
136*/
137
138
139/* make stack-overflow tests run faster */
140#undef LUAI_MAXSTACK
141#define LUAI_MAXSTACK 50000
142
143
144/* test mode uses more stack space */
145#undef LUAI_MAXCCALLS
146#define LUAI_MAXCCALLS 180
147
148
149/* force Lua to use its own implementations */
150#undef lua_strx2number
151#undef lua_number2strx
152
153
154#endif
155