ltests.h 1.6 KB

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