rlm@1: /* rlm@1: ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ rlm@1: ** Limits, basic types, and some other `installation-dependent' definitions rlm@1: ** See Copyright Notice in lua.h rlm@1: */ rlm@1: rlm@1: #ifndef llimits_h rlm@1: #define llimits_h rlm@1: rlm@1: rlm@1: #include rlm@1: #include rlm@1: rlm@1: rlm@1: #include "lua.h" rlm@1: rlm@1: rlm@1: typedef LUAI_UINT32 lu_int32; rlm@1: rlm@1: typedef LUAI_UMEM lu_mem; rlm@1: rlm@1: typedef LUAI_MEM l_mem; rlm@1: rlm@1: rlm@1: rlm@1: /* chars used as small naturals (so that `char' is reserved for characters) */ rlm@1: typedef unsigned char lu_byte; rlm@1: rlm@1: rlm@1: #define MAX_SIZET ((size_t)(~(size_t)0)-2) rlm@1: rlm@1: #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) rlm@1: rlm@1: rlm@1: #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ rlm@1: rlm@1: /* rlm@1: ** conversion of pointer to integer rlm@1: ** this is for hashing only; there is no problem if the integer rlm@1: ** cannot hold the whole pointer value rlm@1: */ rlm@1: #define IntPoint(p) ((unsigned int)(lu_mem)(p)) rlm@1: rlm@1: rlm@1: rlm@1: /* type to ensure maximum alignment */ rlm@1: typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; rlm@1: rlm@1: rlm@1: /* result of a `usual argument conversion' over lua_Number */ rlm@1: typedef LUAI_UACNUMBER l_uacNumber; rlm@1: rlm@1: rlm@1: /* internal assertions for in-house debugging */ rlm@1: #ifdef lua_assert rlm@1: rlm@1: #define check_exp(c,e) (lua_assert(c), (e)) rlm@1: #define api_check(l,e) lua_assert(e) rlm@1: rlm@1: #else rlm@1: rlm@1: #define lua_assert(c) ((void)0) rlm@1: #define check_exp(c,e) (e) rlm@1: #define api_check luai_apicheck rlm@1: rlm@1: #endif rlm@1: rlm@1: rlm@1: #ifndef UNUSED rlm@1: #define UNUSED(x) ((void)(x)) /* to avoid warnings */ rlm@1: #endif rlm@1: rlm@1: rlm@1: #ifndef cast rlm@1: #define cast(t, exp) ((t)(exp)) rlm@1: #endif rlm@1: rlm@1: #define cast_byte(i) cast(lu_byte, (i)) rlm@1: #define cast_num(i) cast(lua_Number, (i)) rlm@1: #define cast_int(i) cast(int, (i)) rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: ** type for virtual-machine instructions rlm@1: ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) rlm@1: */ rlm@1: typedef lu_int32 Instruction; rlm@1: rlm@1: rlm@1: rlm@1: /* maximum stack for a Lua function */ rlm@1: #define MAXSTACK 250 rlm@1: rlm@1: rlm@1: rlm@1: /* minimum size for the string table (must be power of 2) */ rlm@1: #ifndef MINSTRTABSIZE rlm@1: #define MINSTRTABSIZE 32 rlm@1: #endif rlm@1: rlm@1: rlm@1: /* minimum size for string buffer */ rlm@1: #ifndef LUA_MINBUFFER rlm@1: #define LUA_MINBUFFER 32 rlm@1: #endif rlm@1: rlm@1: rlm@1: #ifndef lua_lock rlm@1: #define lua_lock(L) ((void) 0) rlm@1: #define lua_unlock(L) ((void) 0) rlm@1: #endif rlm@1: rlm@1: #ifndef luai_threadyield rlm@1: #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: ** macro to control inclusion of some hard tests on stack reallocation rlm@1: */ rlm@1: #ifndef HARDSTACKTESTS rlm@1: #define condhardstacktests(x) ((void)0) rlm@1: #else rlm@1: #define condhardstacktests(x) x rlm@1: #endif rlm@1: rlm@1: #endif