ltests.h 1.5 KB

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