ltests.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. ** $Id: ltests.h,v 1.19 2002/11/19 17:42:32 roberto Exp roberto $
  3. ** Internal Header for Debugging of the Lua Implementation
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ltests_h
  7. #define ltests_h
  8. #include <stdlib.h>
  9. #define LUA_DEBUG
  10. #define LUA_OPNAMES
  11. #undef NDEBUG
  12. #include <assert.h>
  13. #define lua_assert(c) assert(c)
  14. #define check_exp(c,e) (lua_assert(c), (e))
  15. #define api_check(L, o) lua_assert(o)
  16. /* to avoid warnings, and to make sure value is really unused */
  17. #define UNUSED(x) (x=0, (void)(x))
  18. /* memory allocator control variables */
  19. extern unsigned long memdebug_numblocks;
  20. extern unsigned long memdebug_total;
  21. extern unsigned long memdebug_maxmem;
  22. extern unsigned long memdebug_memlimit;
  23. #define l_realloc(b, os, s) debug_realloc(b, os, s)
  24. #define l_free(b, os) debug_realloc(b, os, 0)
  25. void *debug_realloc (void *block, size_t oldsize, size_t size);
  26. /* test for lock/unlock */
  27. extern int islocked;
  28. #define LUA_USERSTATE int *
  29. #define getlock(l) (*(cast(LUA_USERSTATE *, l) - 1))
  30. #define lua_userstateopen(l) if (l != NULL) getlock(l) = &islocked;
  31. #define lua_lock(l) lua_assert((*getlock(l))++ == 0)
  32. #define lua_unlock(l) lua_assert(--(*getlock(l)) == 0)
  33. int luaB_opentests (lua_State *L);
  34. #define LUA_EXTRALIBS { "tests", luaB_opentests },
  35. /* real main will be defined at `ltests.c' */
  36. int l_main (int argc, char *argv[]);
  37. #define main l_main
  38. /* change some sizes to give some bugs a chance */
  39. #define LUAL_BUFFERSIZE 27
  40. #define MINSTRTABSIZE 2
  41. #endif