annotate lib/lua/lua-5.2.2/llimits.h @ 2553:48708da03b7f

Party Creation UI logic separated from MainMenu
author a.parshin
date Wed, 13 May 2015 02:20:05 +0200
parents 41cc4dd3c122
children
rev   line source
1866
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
1 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
2 ** $Id: llimits.h,v 1.103 2013/02/20 14:08:56 roberto Exp $
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
3 ** Limits, basic types, and some other `installation-dependent' definitions
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
4 ** See Copyright Notice in lua.h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
5 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
6
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
7 #ifndef llimits_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
8 #define llimits_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
9
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
10
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
11 #include <limits.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
12 #include <stddef.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
13
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
14
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
15 #include "lua.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
16
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
17
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
18 typedef unsigned LUA_INT32 lu_int32;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
19
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
20 typedef LUAI_UMEM lu_mem;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
21
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
22 typedef LUAI_MEM l_mem;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
23
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
24
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
25
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
26 /* chars used as small naturals (so that `char' is reserved for characters) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
27 typedef unsigned char lu_byte;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
28
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
29
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
30 #define MAX_SIZET ((size_t)(~(size_t)0)-2)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
31
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
32 #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
33
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
34 #define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
35
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
36
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
37 #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
38
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
39 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
40 ** conversion of pointer to integer
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
41 ** this is for hashing only; there is no problem if the integer
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
42 ** cannot hold the whole pointer value
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
43 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
44 #define IntPoint(p) ((unsigned int)(lu_mem)(p))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
45
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
46
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
47
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
48 /* type to ensure maximum alignment */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
49 #if !defined(LUAI_USER_ALIGNMENT_T)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
50 #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
51 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
52
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
53 typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
54
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
55
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
56 /* result of a `usual argument conversion' over lua_Number */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
57 typedef LUAI_UACNUMBER l_uacNumber;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
58
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
59
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
60 /* internal assertions for in-house debugging */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
61 #if defined(lua_assert)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
62 #define check_exp(c,e) (lua_assert(c), (e))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
63 /* to avoid problems with conditions too long */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
64 #define lua_longassert(c) { if (!(c)) lua_assert(0); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
65 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
66 #define lua_assert(c) ((void)0)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
67 #define check_exp(c,e) (e)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
68 #define lua_longassert(c) ((void)0)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
69 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
70
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
71 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
72 ** assertion for checking API calls
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
73 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
74 #if !defined(luai_apicheck)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
75
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
76 #if defined(LUA_USE_APICHECK)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
77 #include <assert.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
78 #define luai_apicheck(L,e) assert(e)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
79 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
80 #define luai_apicheck(L,e) lua_assert(e)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
81 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
82
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
83 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
84
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
85 #define api_check(l,e,msg) luai_apicheck(l,(e) && msg)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
86
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
87
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
88 #if !defined(UNUSED)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
89 #define UNUSED(x) ((void)(x)) /* to avoid warnings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
90 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
91
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
92
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
93 #define cast(t, exp) ((t)(exp))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
94
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
95 #define cast_byte(i) cast(lu_byte, (i))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
96 #define cast_num(i) cast(lua_Number, (i))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
97 #define cast_int(i) cast(int, (i))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
98 #define cast_uchar(i) cast(unsigned char, (i))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
99
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
100
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
101 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
102 ** non-return type
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
103 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
104 #if defined(__GNUC__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
105 #define l_noret void __attribute__((noreturn))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
106 #elif defined(_MSC_VER)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
107 #define l_noret void __declspec(noreturn)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
108 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
109 #define l_noret void
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
110 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
111
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
112
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
113
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
114 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
115 ** maximum depth for nested C calls and syntactical nested non-terminals
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
116 ** in a program. (Value must fit in an unsigned short int.)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
117 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
118 #if !defined(LUAI_MAXCCALLS)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
119 #define LUAI_MAXCCALLS 200
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
120 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
121
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
122 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
123 ** maximum number of upvalues in a closure (both C and Lua). (Value
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
124 ** must fit in an unsigned char.)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
125 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
126 #define MAXUPVAL UCHAR_MAX
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
127
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
128
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
129 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
130 ** type for virtual-machine instructions
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
131 ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
132 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
133 typedef lu_int32 Instruction;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
134
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
135
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
136
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
137 /* maximum stack for a Lua function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
138 #define MAXSTACK 250
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
139
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
140
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
141
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
142 /* minimum size for the string table (must be power of 2) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
143 #if !defined(MINSTRTABSIZE)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
144 #define MINSTRTABSIZE 32
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
145 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
146
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
147
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
148 /* minimum size for string buffer */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
149 #if !defined(LUA_MINBUFFER)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
150 #define LUA_MINBUFFER 32
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
151 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
152
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
153
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
154 #if !defined(lua_lock)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
155 #define lua_lock(L) ((void) 0)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
156 #define lua_unlock(L) ((void) 0)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
157 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
158
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
159 #if !defined(luai_threadyield)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
160 #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
161 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
162
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
163
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
164 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
165 ** these macros allow user-specific actions on threads when you defined
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
166 ** LUAI_EXTRASPACE and need to do something extra when a thread is
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
167 ** created/deleted/resumed/yielded.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
168 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
169 #if !defined(luai_userstateopen)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
170 #define luai_userstateopen(L) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
171 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
172
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
173 #if !defined(luai_userstateclose)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
174 #define luai_userstateclose(L) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
175 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
176
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
177 #if !defined(luai_userstatethread)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
178 #define luai_userstatethread(L,L1) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
179 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
180
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
181 #if !defined(luai_userstatefree)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
182 #define luai_userstatefree(L,L1) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
183 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
184
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
185 #if !defined(luai_userstateresume)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
186 #define luai_userstateresume(L,n) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
187 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
188
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
189 #if !defined(luai_userstateyield)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
190 #define luai_userstateyield(L,n) ((void)L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
191 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
192
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
193 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
194 ** lua_number2int is a macro to convert lua_Number to int.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
195 ** lua_number2integer is a macro to convert lua_Number to lua_Integer.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
196 ** lua_number2unsigned is a macro to convert a lua_Number to a lua_Unsigned.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
197 ** lua_unsigned2number is a macro to convert a lua_Unsigned to a lua_Number.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
198 ** luai_hashnum is a macro to hash a lua_Number value into an integer.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
199 ** The hash must be deterministic and give reasonable values for
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
200 ** both small and large values (outside the range of integers).
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
201 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
202
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
203 #if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) /* { */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
204 /* trick with Microsoft assembler for X86 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
205
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
206 #define lua_number2int(i,n) __asm {__asm fld n __asm fistp i}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
207 #define lua_number2integer(i,n) lua_number2int(i, n)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
208 #define lua_number2unsigned(i,n) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
209 {__int64 l; __asm {__asm fld n __asm fistp l} i = (unsigned int)l;}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
210
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
211
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
212 #elif defined(LUA_IEEE754TRICK) /* }{ */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
213 /* the next trick should work on any machine using IEEE754 with
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
214 a 32-bit int type */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
215
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
216 union luai_Cast { double l_d; LUA_INT32 l_p[2]; };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
217
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
218 #if !defined(LUA_IEEEENDIAN) /* { */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
219 #define LUAI_EXTRAIEEE \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
220 static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)};
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
221 #define LUA_IEEEENDIANLOC (ieeeendian.l_p[1] == 33)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
222 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
223 #define LUA_IEEEENDIANLOC LUA_IEEEENDIAN
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
224 #define LUAI_EXTRAIEEE /* empty */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
225 #endif /* } */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
226
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
227 #define lua_number2int32(i,n,t) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
228 { LUAI_EXTRAIEEE \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
229 volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
230 (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
231
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
232 #define luai_hashnum(i,n) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
233 { volatile union luai_Cast u; u.l_d = (n) + 1.0; /* avoid -0 */ \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
234 (i) = u.l_p[0]; (i) += u.l_p[1]; } /* add double bits for his hash */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
235
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
236 #define lua_number2int(i,n) lua_number2int32(i, n, int)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
237 #define lua_number2unsigned(i,n) lua_number2int32(i, n, lua_Unsigned)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
238
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
239 /* the trick can be expanded to lua_Integer when it is a 32-bit value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
240 #if defined(LUA_IEEELL)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
241 #define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
242 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
243
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
244 #endif /* } */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
245
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
246
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
247 /* the following definitions always work, but may be slow */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
248
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
249 #if !defined(lua_number2int)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
250 #define lua_number2int(i,n) ((i)=(int)(n))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
251 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
252
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
253 #if !defined(lua_number2integer)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
254 #define lua_number2integer(i,n) ((i)=(lua_Integer)(n))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
255 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
256
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
257 #if !defined(lua_number2unsigned) /* { */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
258 /* the following definition assures proper modulo behavior */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
259 #if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
260 #include <math.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
261 #define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
262 #define lua_number2unsigned(i,n) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
263 ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
264 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
265 #define lua_number2unsigned(i,n) ((i)=(lua_Unsigned)(n))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
266 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
267 #endif /* } */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
268
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
269
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
270 #if !defined(lua_unsigned2number)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
271 /* on several machines, coercion from unsigned to double is slow,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
272 so it may be worth to avoid */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
273 #define lua_unsigned2number(u) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
274 (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)(u))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
275 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
276
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
277
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
278
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
279 #if defined(ltable_c) && !defined(luai_hashnum)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
280
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
281 #include <float.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
282 #include <math.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
283
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
284 #define luai_hashnum(i,n) { int e; \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
285 n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
286 lua_number2int(i, n); i += e; }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
287
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
288 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
289
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
290
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
291
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
292 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
293 ** macro to control inclusion of some hard tests on stack reallocation
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
294 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
295 #if !defined(HARDSTACKTESTS)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
296 #define condmovestack(L) ((void)0)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
297 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
298 /* realloc stack keeping its size */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
299 #define condmovestack(L) luaD_reallocstack((L), (L)->stacksize)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
300 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
301
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
302 #if !defined(HARDMEMTESTS)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
303 #define condchangemem(L) condmovestack(L)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
304 #else
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
305 #define condchangemem(L) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
306 ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1)))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
307 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
308
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
309 #endif