ltests.h 1.2 KB

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