diff options
| -rw-r--r-- | llimits.h | 44 |
1 files changed, 1 insertions, 43 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.105 2013/05/23 21:27:06 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.106 2013/05/27 12:43:37 roberto Exp roberto $ |
| 3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -198,48 +198,6 @@ typedef lu_int32 Instruction; | |||
| 198 | #define luai_userstateyield(L,n) ((void)L) | 198 | #define luai_userstateyield(L,n) ((void)L) |
| 199 | #endif | 199 | #endif |
| 200 | 200 | ||
| 201 | /* | ||
| 202 | ** lua_number2int is a macro to convert lua_Number to int. | ||
| 203 | ** lua_number2integer is a macro to convert lua_Number to lua_Integer. | ||
| 204 | ** lua_number2unsigned is a macro to convert a lua_Number to a lua_Unsigned. | ||
| 205 | ** lua_unsigned2number is a macro to convert a lua_Unsigned to a lua_Number. | ||
| 206 | ** luai_hashnum is a macro to hash a lua_Number value into an integer. | ||
| 207 | ** The hash must be deterministic and give reasonable values for | ||
| 208 | ** both small and large values (outside the range of integers). | ||
| 209 | */ | ||
| 210 | |||
| 211 | #if !defined(lua_number2int) | ||
| 212 | #define lua_number2int(i,n) ((i)=(int)(n)) | ||
| 213 | #endif | ||
| 214 | |||
| 215 | #if !defined(lua_number2integer) | ||
| 216 | #define lua_number2integer(i,n) ((i)=(lua_Integer)(n)) | ||
| 217 | #endif | ||
| 218 | |||
| 219 | #if !defined(lua_number2unsigned) /* { */ | ||
| 220 | /* the following definition assures proper modulo behavior */ | ||
| 221 | #if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT) | ||
| 222 | #include <math.h> | ||
| 223 | #define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1) | ||
| 224 | #define lua_number2unsigned(i,n) \ | ||
| 225 | ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED)) | ||
| 226 | #else | ||
| 227 | #define lua_number2unsigned(i,n) ((i)=(lua_Unsigned)(n)) | ||
| 228 | #endif | ||
| 229 | #endif /* } */ | ||
| 230 | |||
| 231 | |||
| 232 | #if defined(ltable_c) && !defined(luai_hashnum) | ||
| 233 | |||
| 234 | #include <float.h> | ||
| 235 | #include <math.h> | ||
| 236 | |||
| 237 | #define luai_hashnum(i,n) { int e; \ | ||
| 238 | n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ | ||
| 239 | lua_number2int(i, n); i += e; } | ||
| 240 | |||
| 241 | #endif | ||
| 242 | |||
| 243 | 201 | ||
| 244 | 202 | ||
| 245 | /* | 203 | /* |
