ltests.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. ** $Id: ltests.h,v 2.5 2004/05/03 12:28:43 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. #undef api_check
  16. #define api_check(L, o) lua_assert(o)
  17. /* to avoid warnings, and to make sure value is really unused */
  18. #define UNUSED(x) (x=0, (void)(x))
  19. /* memory allocator control variables */
  20. typedef struct Memcontrol {
  21. unsigned long numblocks;
  22. unsigned long total;
  23. unsigned long maxmem;
  24. unsigned long memlimit;
  25. } Memcontrol;
  26. extern Memcontrol memcontrol;
  27. /*
  28. ** generic variable for debug tricks
  29. */
  30. extern int Trick;
  31. void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);
  32. #ifdef lua_c
  33. #define luaL_newstate() lua_newstate(debug_realloc, &memcontrol)
  34. #endif
  35. int lua_checkmemory (lua_State *L);
  36. /* test for lock/unlock */
  37. #undef lua_userstateopen
  38. #undef lua_lock
  39. #undef lua_unlock
  40. extern int islocked;
  41. #define LUA_USERSTATE int *
  42. #define getlock(l) (*(cast(LUA_USERSTATE *, l) - 1))
  43. #define lua_userstateopen(l) getlock(l) = &islocked;
  44. #define lua_lock(l) lua_assert((*getlock(l))++ == 0)
  45. #define lua_unlock(l) lua_assert(--(*getlock(l)) == 0)
  46. int luaB_opentests (lua_State *L);
  47. #undef LUA_EXTRALIBS
  48. #define LUA_EXTRALIBS { "tests", luaB_opentests },
  49. /* real main will be defined at `ltests.c' */
  50. int l_main (int argc, char *argv[]);
  51. #define main l_main
  52. /* change some sizes to give some bugs a chance */
  53. #undef LUAL_BUFFERSIZE
  54. #define LUAL_BUFFERSIZE 27
  55. #define MINSTRTABSIZE 2
  56. #endif