diff --git a/lmathlib.c b/lmathlib.c index 3454c41f..f6f0b426 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -276,7 +276,7 @@ static int math_type (lua_State *L) { /* there is a 'long long' type (which must have at least 64 bits) */ #define Rand64 unsigned long long -#elif (LUA_MAXINTEGER >> 30 >> 30) >= 7 +#elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3 /* 'lua_Integer' has at least 64 bits */ #define Rand64 lua_Unsigned @@ -538,7 +538,7 @@ static lua_Unsigned project (lua_Unsigned ran, lua_Unsigned n, lim |= (lim >> 4); lim |= (lim >> 8); lim |= (lim >> 16); -#if (LUA_MAXINTEGER >> 30) >= 3 +#if (LUA_MAXUNSIGNED >> 31) >= 3 lim |= (lim >> 32); /* integer type has more than 32 bits */ #endif } diff --git a/luaconf.h b/luaconf.h index e6271b80..66dca6bf 100644 --- a/luaconf.h +++ b/luaconf.h @@ -515,7 +515,6 @@ */ #define LUA_UNSIGNED unsigned LUAI_UACINT -#define LUA_MAXUNSIGNED (~(lua_Unsigned)0) #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) @@ -530,6 +529,8 @@ #define LUA_MAXINTEGER INT_MAX #define LUA_MININTEGER INT_MIN +#define LUA_MAXUNSIGNED UINT_MAX + #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ #define LUA_INTEGER long @@ -538,6 +539,8 @@ #define LUA_MAXINTEGER LONG_MAX #define LUA_MININTEGER LONG_MIN +#define LUA_MAXUNSIGNED ULONG_MAX + #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ /* use presence of macro LLONG_MAX as proxy for C99 compliance */ @@ -550,6 +553,8 @@ #define LUA_MAXINTEGER LLONG_MAX #define LUA_MININTEGER LLONG_MIN +#define LUA_MAXUNSIGNED ULLONG_MAX + #elif defined(LUA_USE_WINDOWS) /* }{ */ /* in Windows, can use specific Windows types */ @@ -559,6 +564,8 @@ #define LUA_MAXINTEGER _I64_MAX #define LUA_MININTEGER _I64_MIN +#define LUA_MAXUNSIGNED _UI64_MAX + #else /* }{ */ #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \