github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/testdata/lua-5.3.3-tests/ltests/ltests.h (about)

     1  /*
     2  ** $Id: ltests.h,v 2.49 2015/09/22 14:18:24 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  /* 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
    25  
    26  
    27  #define LUA_DEBUG
    28  
    29  
    30  /* turn on assertions */
    31  #undef NDEBUG
    32  #include <assert.h>
    33  #define lua_assert(c)           assert(c)
    34  
    35  
    36  /* to avoid warnings, and to make sure value is really unused */
    37  #define UNUSED(x)       (x=0, (void)(x))
    38  
    39  
    40  /* test for sizes in 'l_sprintf' (make sure whole buffer is available) */
    41  #undef l_sprintf
    42  #if !defined(LUA_USE_C89)
    43  #define l_sprintf(s,sz,f,i)	(memset(s,0xAB,sz), snprintf(s,sz,f,i))
    44  #else
    45  #define l_sprintf(s,sz,f,i)	(memset(s,0xAB,sz), sprintf(s,f,i))
    46  #endif
    47  
    48  
    49  /* memory-allocator control variables */
    50  typedef struct Memcontrol {
    51    unsigned long numblocks;
    52    unsigned long total;
    53    unsigned long maxmem;
    54    unsigned long memlimit;
    55    unsigned long objcount[LUA_NUMTAGS];
    56  } Memcontrol;
    57  
    58  LUA_API Memcontrol l_memcontrol;
    59  
    60  
    61  /*
    62  ** generic variable for debug tricks
    63  */
    64  extern void *l_Trick;
    65  
    66  
    67  
    68  /*
    69  ** Function to traverse and check all memory used by Lua
    70  */
    71  int lua_checkmemory (lua_State *L);
    72  
    73  
    74  /* test for lock/unlock */
    75  
    76  struct L_EXTRA { int lock; int *plock; };
    77  #undef LUA_EXTRASPACE
    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)
    90  
    91  
    92  
    93  LUA_API int luaB_opentests (lua_State *L);
    94  
    95  LUA_API void *debug_realloc (void *ud, void *block,
    96                               size_t osize, size_t nsize);
    97  
    98  #if defined(lua_c)
    99  #define luaL_newstate()		lua_newstate(debug_realloc, &l_memcontrol)
   100  #define luaL_openlibs(L)  \
   101    { (luaL_openlibs)(L); luaL_requiref(L, "T", luaB_opentests, 1); }
   102  #endif
   103  
   104  
   105  
   106  /* change some sizes to give some bugs a chance */
   107  
   108  #undef LUAL_BUFFERSIZE
   109  #define LUAL_BUFFERSIZE		23
   110  #define MINSTRTABSIZE		2
   111  
   112  
   113  /* make stack-overflow tests run faster */
   114  #undef LUAI_MAXSTACK
   115  #define LUAI_MAXSTACK   50000
   116  
   117  
   118  #undef LUAI_USER_ALIGNMENT_T
   119  #define LUAI_USER_ALIGNMENT_T   union { char b[sizeof(void*) * 8]; }
   120  
   121  
   122  #define STRCACHE_N	23
   123  #define STRCACHE_M	5
   124  
   125  #endif
   126