Committed lnum patch 031007
[lua.git] / src / llimits.h
blob49950ef2871da7d3e3a5d1ddb0d995923604549a
1 /*
2 ** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
3 ** Limits, basic types, and some other `installation-dependent' definitions
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef llimits_h
8 #define llimits_h
11 #include <limits.h>
12 #include <stddef.h>
15 #include "lua.h"
18 typedef LUAI_UINT32 lu_int32;
20 typedef LUAI_UMEM lu_mem;
22 typedef LUAI_MEM l_mem;
24 /* Only for internal functions; for public ABI, use 'int' */
25 typedef LUAI_BOOL lu_bool;
29 /* chars used as small naturals (so that `char' is reserved for characters) */
30 typedef unsigned char lu_byte;
33 #define MAX_SIZET ((size_t)(~(size_t)0)-2)
35 #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
38 #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
41 ** conversion of pointer to integer
42 ** this is for hashing only; there is no problem if the integer
43 ** cannot hold the whole pointer value
45 #define IntPoint(p) ((unsigned int)(lu_mem)(p))
49 /* type to ensure maximum alignment */
50 typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
53 /* result of a `usual argument conversion' over lua_Number */
54 typedef LUAI_UACNUMBER l_uacNumber;
55 typedef LUAI_UACINTEGER l_uacInteger;
58 /* internal assertions for in-house debugging */
59 #ifdef lua_assert
61 #define check_exp(c,e) (lua_assert(c), (e))
62 #define api_check(l,e) lua_assert(e)
64 #else
66 #define lua_assert(c) ((void)0)
67 #define check_exp(c,e) (e)
68 #define api_check luai_apicheck
70 #endif
73 #ifndef UNUSED
74 #define UNUSED(x) ((void)(x)) /* to avoid warnings */
75 #endif
78 #ifndef cast
79 #define cast(t, exp) ((t)(exp))
80 #endif
82 #define cast_byte(i) cast(lu_byte, (i))
83 #define cast_num(i) cast(lua_Number, (i))
84 #define cast_int(i) cast(int, (i))
86 #if LNUM_COMPLEX
87 #define cast_complex(i) cast(lua_Complex, (i))
88 #endif
92 ** type for virtual-machine instructions
93 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
95 typedef lu_int32 Instruction;
99 /* maximum stack for a Lua function */
100 #define MAXSTACK 250
104 /* minimum size for the string table (must be power of 2) */
105 #ifndef MINSTRTABSIZE
106 #define MINSTRTABSIZE 32
107 #endif
110 /* minimum size for string buffer */
111 #ifndef LUA_MINBUFFER
112 #define LUA_MINBUFFER 32
113 #endif
116 #ifndef lua_lock
117 #define lua_lock(L) ((void) 0)
118 #define lua_unlock(L) ((void) 0)
119 #endif
121 #ifndef luai_threadyield
122 #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
123 #endif
127 ** macro to control inclusion of some hard tests on stack reallocation
129 #ifndef HARDSTACKTESTS
130 #define condhardstacktests(x) ((void)0)
131 #else
132 #define condhardstacktests(x) x
133 #endif
135 #endif