diff options
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | luaconf.h | 9 |
2 files changed, 10 insertions, 3 deletions
@@ -276,7 +276,7 @@ static int math_type (lua_State *L) { | |||
276 | /* there is a 'long long' type (which must have at least 64 bits) */ | 276 | /* there is a 'long long' type (which must have at least 64 bits) */ |
277 | #define Rand64 unsigned long long | 277 | #define Rand64 unsigned long long |
278 | 278 | ||
279 | #elif (LUA_MAXINTEGER >> 30 >> 30) >= 7 | 279 | #elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3 |
280 | 280 | ||
281 | /* 'lua_Integer' has at least 64 bits */ | 281 | /* 'lua_Integer' has at least 64 bits */ |
282 | #define Rand64 lua_Unsigned | 282 | #define Rand64 lua_Unsigned |
@@ -538,7 +538,7 @@ static lua_Unsigned project (lua_Unsigned ran, lua_Unsigned n, | |||
538 | lim |= (lim >> 4); | 538 | lim |= (lim >> 4); |
539 | lim |= (lim >> 8); | 539 | lim |= (lim >> 8); |
540 | lim |= (lim >> 16); | 540 | lim |= (lim >> 16); |
541 | #if (LUA_MAXINTEGER >> 30) >= 3 | 541 | #if (LUA_MAXUNSIGNED >> 31) >= 3 |
542 | lim |= (lim >> 32); /* integer type has more than 32 bits */ | 542 | lim |= (lim >> 32); /* integer type has more than 32 bits */ |
543 | #endif | 543 | #endif |
544 | } | 544 | } |
@@ -515,7 +515,6 @@ | |||
515 | */ | 515 | */ |
516 | #define LUA_UNSIGNED unsigned LUAI_UACINT | 516 | #define LUA_UNSIGNED unsigned LUAI_UACINT |
517 | 517 | ||
518 | #define LUA_MAXUNSIGNED (~(lua_Unsigned)0) | ||
519 | 518 | ||
520 | #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) | 519 | #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) |
521 | 520 | ||
@@ -530,6 +529,8 @@ | |||
530 | #define LUA_MAXINTEGER INT_MAX | 529 | #define LUA_MAXINTEGER INT_MAX |
531 | #define LUA_MININTEGER INT_MIN | 530 | #define LUA_MININTEGER INT_MIN |
532 | 531 | ||
532 | #define LUA_MAXUNSIGNED UINT_MAX | ||
533 | |||
533 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ | 534 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ |
534 | 535 | ||
535 | #define LUA_INTEGER long | 536 | #define LUA_INTEGER long |
@@ -538,6 +539,8 @@ | |||
538 | #define LUA_MAXINTEGER LONG_MAX | 539 | #define LUA_MAXINTEGER LONG_MAX |
539 | #define LUA_MININTEGER LONG_MIN | 540 | #define LUA_MININTEGER LONG_MIN |
540 | 541 | ||
542 | #define LUA_MAXUNSIGNED ULONG_MAX | ||
543 | |||
541 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ | 544 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ |
542 | 545 | ||
543 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ | 546 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ |
@@ -550,6 +553,8 @@ | |||
550 | #define LUA_MAXINTEGER LLONG_MAX | 553 | #define LUA_MAXINTEGER LLONG_MAX |
551 | #define LUA_MININTEGER LLONG_MIN | 554 | #define LUA_MININTEGER LLONG_MIN |
552 | 555 | ||
556 | #define LUA_MAXUNSIGNED ULLONG_MAX | ||
557 | |||
553 | #elif defined(LUA_USE_WINDOWS) /* }{ */ | 558 | #elif defined(LUA_USE_WINDOWS) /* }{ */ |
554 | /* in Windows, can use specific Windows types */ | 559 | /* in Windows, can use specific Windows types */ |
555 | 560 | ||
@@ -559,6 +564,8 @@ | |||
559 | #define LUA_MAXINTEGER _I64_MAX | 564 | #define LUA_MAXINTEGER _I64_MAX |
560 | #define LUA_MININTEGER _I64_MIN | 565 | #define LUA_MININTEGER _I64_MIN |
561 | 566 | ||
567 | #define LUA_MAXUNSIGNED _UI64_MAX | ||
568 | |||
562 | #else /* }{ */ | 569 | #else /* }{ */ |
563 | 570 | ||
564 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ | 571 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ |