ltests.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. ** $Id: ltests.h,v 1.3 2001/02/06 16:01:29 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. #define lua_assert(c) assert(c)
  13. /* to avoid warnings, and to make sure value is really unused */
  14. #define UNUSED(x) (x=0, (void)(x))
  15. /* memory allocator control variables */
  16. extern unsigned long memdebug_numblocks;
  17. extern unsigned long memdebug_total;
  18. extern unsigned long memdebug_maxmem;
  19. extern unsigned long memdebug_memlimit;
  20. #define l_malloc(s) debug_realloc(NULL, 0, s)
  21. #define l_realloc(b, os, s) debug_realloc(b, os, s)
  22. #define l_free(b, s) debug_realloc(b, s, 0)
  23. void *debug_realloc (void *block, size_t oldsize, size_t size);
  24. /* test for lock/unlock */
  25. #define LUA_USERSTATE int *lock;
  26. extern int islocked;
  27. #define LUA_LOCK(L) lua_assert((**((int **)L))++ == 0)
  28. #define LUA_UNLOCK(L) lua_assert(--(**((int **)L)) == 0)
  29. extern lua_State *lua_state;
  30. void luaB_opentests (lua_State *L);
  31. #define LUA_USERINIT(L) (luaB_opentests(L), openstdlibs(L))
  32. #endif