ltests.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. ** $Id: ltests.h,v 2.24 2008/08/05 19:24: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. /* do not use compatibility macros in Lua code */
  10. #undef LUA_COMPAT_API
  11. #define LUA_DEBUG
  12. #undef NDEBUG
  13. #include <assert.h>
  14. #define lua_assert(c) assert(c)
  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. LUAI_DATA Memcontrol l_memcontrol;
  25. /*
  26. ** generic variable for debug tricks
  27. */
  28. LUAI_DATA void *l_Trick;
  29. void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);
  30. #ifdef lua_c
  31. #define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol)
  32. #endif
  33. typedef struct CallInfo *pCallInfo;
  34. int lua_checkmemory (lua_State *L);
  35. /* test for lock/unlock */
  36. #undef luai_userstateopen
  37. #undef luai_userstatethread
  38. #undef lua_lock
  39. #undef lua_unlock
  40. #undef LUAI_EXTRASPACE
  41. struct L_EXTRA { int lock; int *plock; };
  42. #define LUAI_EXTRASPACE sizeof(struct L_EXTRA)
  43. #define getlock(l) (cast(struct L_EXTRA *, l) - 1)
  44. #define luai_userstateopen(l) \
  45. (getlock(l)->lock = 0, getlock(l)->plock = &(getlock(l)->lock))
  46. #define luai_userstatethread(l,l1) (getlock(l1)->plock = getlock(l)->plock)
  47. #define lua_lock(l) lua_assert((*getlock(l)->plock)++ == 0)
  48. #define lua_unlock(l) lua_assert(--(*getlock(l)->plock) == 0)
  49. int luaB_opentests (lua_State *L);
  50. #ifdef lua_c
  51. #define luaL_openlibs(L) { (luaL_openlibs)(L); luaB_opentests(L); }
  52. #endif
  53. /* change some sizes to give some bugs a chance */
  54. #undef LUAL_BUFFERSIZE
  55. #define LUAL_BUFFERSIZE 23
  56. #define MINSTRTABSIZE 2
  57. #undef LUAI_USER_ALIGNMENT_T
  58. #define LUAI_USER_ALIGNMENT_T union { char b[32]; }
  59. #endif