ltests.h 1.7 KB

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