ltests.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. ** $Id: ltests.h,v 1.20 2002/12/04 17:29:05 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. typedef struct Memcontrol {
  20. unsigned long numblocks;
  21. unsigned long total;
  22. unsigned long maxmem;
  23. unsigned long memlimit;
  24. } Memcontrol;
  25. extern Memcontrol memcontrol;
  26. void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);
  27. #ifdef lua_c
  28. #define luaL_newstate() lua_newstate(debug_realloc, &memcontrol)
  29. #endif
  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