ltests.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. ** $Id: ltests.h,v 1.6 2001/03/02 17:27:50 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 api_check(L, o) lua_assert(o)
  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. extern unsigned long memdebug_numblocks;
  19. extern unsigned long memdebug_total;
  20. extern unsigned long memdebug_maxmem;
  21. extern unsigned long memdebug_memlimit;
  22. #define l_malloc(s) debug_realloc(NULL, 0, s)
  23. #define l_realloc(b, os, s) debug_realloc(b, os, s)
  24. #define l_free(b, s) debug_realloc(b, s, 0)
  25. void *debug_realloc (void *block, size_t oldsize, size_t size);
  26. /* test for lock/unlock */
  27. #define LUA_USERSTATE int *lock;
  28. extern int islocked;
  29. #define lua_lock(L) lua_assert((**((int **)L))++ == 0)
  30. #define lua_unlock(L) lua_assert(--(**((int **)L)) == 0)
  31. extern lua_State *lua_state;
  32. void luaB_opentests (lua_State *L);
  33. #define LUA_USERINIT(L) (luaB_opentests(L), openstdlibs(L))
  34. #endif