diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-11 16:56:04 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-11 16:56:04 -0300 |
| commit | bf06e22b6a8415adc6970adfea84d3b236425c90 (patch) | |
| tree | c01403a9e76f2a7285830ce692ea960b36a68c4d | |
| parent | d99ffa920dadc8ff9ef8cade2436e26d8fa9a6b2 (diff) | |
| download | lua-bf06e22b6a8415adc6970adfea84d3b236425c90.tar.gz lua-bf06e22b6a8415adc6970adfea84d3b236425c90.tar.bz2 lua-bf06e22b6a8415adc6970adfea84d3b236425c90.zip | |
correct definition for 'MAX_SIZE' (using singed integers as the limit,
not unsigned ones) + new type 'l_uacInt'
| -rw-r--r-- | llimits.h | 17 |
1 files changed, 9 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.111 2014/03/07 16:19:00 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.112 2014/04/11 19:02:16 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 | */ |
| @@ -27,12 +27,16 @@ typedef LUAI_MEM l_mem; | |||
| 27 | typedef unsigned char lu_byte; | 27 | typedef unsigned char lu_byte; |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | /* maximum value for a lua_Unsigned */ | ||
| 31 | #define MAX_UINTEGER (((lua_Unsigned)LUA_MAXINTEGER << 1) + 1u) | ||
| 32 | |||
| 33 | |||
| 30 | /* maximum value for size_t */ | 34 | /* maximum value for size_t */ |
| 31 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) | 35 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) |
| 32 | 36 | ||
| 33 | /* maximum size visible for Lua (must be representable in a lua_Integer */ | 37 | /* maximum size visible for Lua (must be representable in a lua_Integer */ |
| 34 | #define MAX_SIZE (sizeof(size_t) <= sizeof(lua_Integer) ? MAX_SIZET \ | 38 | #define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ |
| 35 | : (size_t)(~(lua_Unsigned)0)-2) | 39 | : (size_t)(LUA_MAXINTEGER)-2) |
| 36 | 40 | ||
| 37 | 41 | ||
| 38 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) | 42 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) |
| @@ -43,10 +47,6 @@ typedef unsigned char lu_byte; | |||
| 43 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ | 47 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ |
| 44 | 48 | ||
| 45 | 49 | ||
| 46 | /* maximum value for a lua_Unsigned */ | ||
| 47 | #define MAX_UINTEGER (((lua_Unsigned)LUA_MAXINTEGER << 1) + 1u) | ||
| 48 | |||
| 49 | |||
| 50 | /* | 50 | /* |
| 51 | ** conversion of pointer to integer | 51 | ** conversion of pointer to integer |
| 52 | ** this is for hashing only; there is no problem if the integer | 52 | ** this is for hashing only; there is no problem if the integer |
| @@ -64,8 +64,9 @@ typedef unsigned char lu_byte; | |||
| 64 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; | 64 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; |
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | /* result of a `usual argument conversion' over lua_Number */ | 67 | /* types of 'usual argument conversions' for lua_Number and lua_Integer */ |
| 68 | typedef LUAI_UACNUMBER l_uacNumber; | 68 | typedef LUAI_UACNUMBER l_uacNumber; |
| 69 | typedef LUAI_UACINT l_uacInt; | ||
| 69 | 70 | ||
| 70 | 71 | ||
| 71 | /* internal assertions for in-house debugging */ | 72 | /* internal assertions for in-house debugging */ |
