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