diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-11-24 16:55:56 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-11-24 16:55:56 -0200 |
commit | 2f82bf6fe940557fb5258c65c03e18f097ff831f (patch) | |
tree | a58f6ae8734e2f4a298b79dc6704a1e735334afc /luaconf.h | |
parent | 087df82a61ddcf1f86e9cffe5550a1ce0174f6e2 (diff) | |
download | lua-2f82bf6fe940557fb5258c65c03e18f097ff831f.tar.gz lua-2f82bf6fe940557fb5258c65c03e18f097ff831f.tar.bz2 lua-2f82bf6fe940557fb5258c65c03e18f097ff831f.zip |
better support for 64-bit machines
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 54 |
1 files changed, 36 insertions, 18 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.15 2004/10/18 18:07:31 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.16 2004/11/18 19:53:49 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -46,8 +46,11 @@ | |||
46 | #define LUA_NUMBER_FMT "%.14g" | 46 | #define LUA_NUMBER_FMT "%.14g" |
47 | 47 | ||
48 | 48 | ||
49 | /* type for integer functions */ | 49 | /* |
50 | #define LUA_INTEGER long | 50 | ** type for integer functions |
51 | ** on most machines, `ptrdiff_t' gives a reasonable size for integers | ||
52 | */ | ||
53 | #define LUA_INTEGER ptrdiff_t | ||
51 | 54 | ||
52 | 55 | ||
53 | /* mark for all API functions */ | 56 | /* mark for all API functions */ |
@@ -130,12 +133,38 @@ | |||
130 | #define api_check(L,o) lua_assert(o) | 133 | #define api_check(L,o) lua_assert(o) |
131 | 134 | ||
132 | 135 | ||
133 | /* an unsigned integer with at least 32 bits */ | 136 | /* number of bits in an `int' */ |
134 | #define LUA_UINT32 unsigned long | 137 | /* avoid overflows in comparison */ |
138 | #if INT_MAX-20 < 32760 | ||
139 | #define LUA_BITSINT 16 | ||
140 | #elif INT_MAX > 2147483640L | ||
141 | /* `int' has at least 32 bits */ | ||
142 | #define LUA_BITSINT 32 | ||
143 | #else | ||
144 | #error "you must define LUA_BITSINT with number of bits in an integer" | ||
145 | #endif | ||
146 | |||
135 | 147 | ||
136 | /* a signed integer with at least 32 bits */ | 148 | /* |
149 | ** L_UINT32: unsigned integer with at least 32 bits | ||
150 | ** L_INT32: signed integer with at least 32 bits | ||
151 | ** LU_MEM: an unsigned integer big enough to count the total memory used by Lua | ||
152 | ** L_MEM: a signed integer big enough to count the total memory used by Lua | ||
153 | */ | ||
154 | #if LUA_BITSINT >= 32 | ||
155 | #define LUA_UINT32 unsigned int | ||
156 | #define LUA_INT32 int | ||
157 | #define LUA_MAXINT32 INT_MAX | ||
158 | #define LU_MEM size_t | ||
159 | #define L_MEM ptrdiff_t | ||
160 | #else | ||
161 | /* 16-bit ints */ | ||
162 | #define LUA_UINT32 unsigned long | ||
137 | #define LUA_INT32 long | 163 | #define LUA_INT32 long |
138 | #define LUA_MAXINT32 LONG_MAX | 164 | #define LUA_MAXINT32 LONG_MAX |
165 | #define LU_MEM LUA_UINT32 | ||
166 | #define L_MEM ptrdiff_t | ||
167 | #endif | ||
139 | 168 | ||
140 | 169 | ||
141 | /* maximum depth for calls (unsigned short) */ | 170 | /* maximum depth for calls (unsigned short) */ |
@@ -174,7 +203,7 @@ | |||
174 | /* function to convert a lua_Number to int (with any rounding method) */ | 203 | /* function to convert a lua_Number to int (with any rounding method) */ |
175 | #if defined(__GNUC__) && defined(__i386) | 204 | #if defined(__GNUC__) && defined(__i386) |
176 | #define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") | 205 | #define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") |
177 | #elif 0 | 206 | #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199900L) |
178 | /* on machines compliant with C99, you can try `lrint' */ | 207 | /* on machines compliant with C99, you can try `lrint' */ |
179 | #include <math.h> | 208 | #include <math.h> |
180 | #define lua_number2int(i,d) ((i)=lrint(d)) | 209 | #define lua_number2int(i,d) ((i)=lrint(d)) |
@@ -199,17 +228,6 @@ | |||
199 | #define LUA_UACNUMBER double | 228 | #define LUA_UACNUMBER double |
200 | 229 | ||
201 | 230 | ||
202 | /* number of bits in an `int' */ | ||
203 | /* avoid overflows in comparison */ | ||
204 | #if INT_MAX-20 < 32760 | ||
205 | #define LUA_BITSINT 16 | ||
206 | #elif INT_MAX > 2147483640L | ||
207 | /* machine has at least 32 bits */ | ||
208 | #define LUA_BITSINT 32 | ||
209 | #else | ||
210 | #error "you must define LUA_BITSINT with number of bits in an integer" | ||
211 | #endif | ||
212 | |||
213 | 231 | ||
214 | /* type to ensure maximum alignment */ | 232 | /* type to ensure maximum alignment */ |
215 | #define LUSER_ALIGNMENT_T union { double u; void *s; long l; } | 233 | #define LUSER_ALIGNMENT_T union { double u; void *s; long l; } |