ScummVM API documentation
llimits.h
1 /*
2 ** $Id$
3 ** Limits, basic types, and some other `installation-dependent' definitions
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef llimits_h
8 #define llimits_h
9 
10 
11 
12 #include "lua.h"
13 
14 
15 typedef LUAI_UINT32 lu_int32;
16 
17 typedef LUAI_UMEM lu_mem;
18 
19 typedef LUAI_MEM l_mem;
20 
21 
22 
23 /* chars used as small naturals (so that `char' is reserved for characters) */
24 typedef unsigned char lu_byte;
25 
26 
27 #define MAX_SIZET ((size_t)(~(size_t)0)-2)
28 
29 #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
30 
31 
32 #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
33 
34 /*
35 ** conversion of pointer to integer
36 ** this is for hashing only; there is no problem if the integer
37 ** cannot hold the whole pointer value
38 */
39 #define IntPoint(p) ((unsigned int)(lu_mem)(p))
40 
41 
42 
43 /* type to ensure maximum alignment */
44 typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
45 
46 
47 /* result of a `usual argument conversion' over lua_Number */
48 typedef LUAI_UACNUMBER l_uacNumber;
49 
50 
51 /* internal assertions for in-house debugging */
52 #ifdef lua_assert
53 
54 #define check_exp(c,e) (lua_assert(c), (e))
55 #define api_check(l,e) lua_assert(e)
56 
57 #else
58 
59 #define lua_assert(c) ((void)0)
60 #define check_exp(c,e) (e)
61 #define api_check luai_apicheck
62 
63 #endif
64 
65 
66 #ifndef UNUSED
67 #define UNUSED(x) ((void)(x)) /* to avoid warnings */
68 #endif
69 
70 
71 #ifndef cast
72 #define cast(t, exp) ((t)(exp))
73 #endif
74 
75 #define cast_byte(i) cast(lu_byte, (i))
76 #define cast_num(i) cast(lua_Number, (i))
77 #define cast_int(i) cast(int, (i))
78 
79 
80 
81 /*
82 ** type for virtual-machine instructions
83 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
84 */
85 typedef lu_int32 Instruction;
86 
87 
88 
89 /* maximum stack for a Lua function */
90 #define MAXSTACK 250
91 
92 
93 
94 /* minimum size for the string table (must be power of 2) */
95 #ifndef MINSTRTABSIZE
96 #define MINSTRTABSIZE 32
97 #endif
98 
99 
100 /* minimum size for string buffer */
101 #ifndef LUA_MINBUFFER
102 #define LUA_MINBUFFER 32
103 #endif
104 
105 
106 #ifndef lua_lock
107 #define lua_lock(L) ((void) 0)
108 #define lua_unlock(L) ((void) 0)
109 #endif
110 
111 #ifndef luai_threadyield
112 #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
113 #endif
114 
115 
116 /*
117 ** macro to control inclusion of some hard tests on stack reallocation
118 */
119 #ifndef HARDSTACKTESTS
120 #define condhardstacktests(x) ((void)0)
121 #else
122 #define condhardstacktests(x) x
123 #endif
124 
125 #endif