diff options
| -rw-r--r-- | ldump.c | 2 | ||||
| -rw-r--r-- | lfunc.c | 9 | ||||
| -rw-r--r-- | llimits.h | 6 | ||||
| -rw-r--r-- | ltable.c | 2 | ||||
| -rw-r--r-- | ltests.h | 3 | ||||
| -rw-r--r-- | lvm.c | 2 |
6 files changed, 9 insertions, 15 deletions
| @@ -87,7 +87,7 @@ static void dumpByte (DumpState *D, int y) { | |||
| 87 | ** size for 'dumpVarint' buffer: each byte can store up to 7 bits. | 87 | ** size for 'dumpVarint' buffer: each byte can store up to 7 bits. |
| 88 | ** (The "+6" rounds up the division.) | 88 | ** (The "+6" rounds up the division.) |
| 89 | */ | 89 | */ |
| 90 | #define DIBS ((sizeof(size_t) * CHAR_BIT + 6) / 7) | 90 | #define DIBS ((l_numbits(size_t) + 6) / 7) |
| 91 | 91 | ||
| 92 | /* | 92 | /* |
| 93 | ** Dumps an unsigned integer using the MSB Varint encoding | 93 | ** Dumps an unsigned integer using the MSB Varint encoding |
| @@ -162,13 +162,8 @@ static void prepcallclosemth (lua_State *L, StkId level, TStatus status, | |||
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | 164 | ||
| 165 | /* | 165 | /* Maximum value for deltas in 'tbclist' */ |
| 166 | ** Maximum value for deltas in 'tbclist', dependent on the type | 166 | #define MAXDELTA USHRT_MAX |
| 167 | ** of delta. (This macro assumes that an 'L' is in scope where it | ||
| 168 | ** is used.) | ||
| 169 | */ | ||
| 170 | #define MAXDELTA \ | ||
| 171 | ((256ul << ((sizeof(L->stack.p->tbclist.delta) - 1) * 8)) - 1) | ||
| 172 | 167 | ||
| 173 | 168 | ||
| 174 | /* | 169 | /* |
| @@ -15,6 +15,8 @@ | |||
| 15 | #include "lua.h" | 15 | #include "lua.h" |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | #define l_numbits(t) cast_int(sizeof(t) * CHAR_BIT) | ||
| 19 | |||
| 18 | /* | 20 | /* |
| 19 | ** 'l_mem' is a signed integer big enough to count the total memory | 21 | ** 'l_mem' is a signed integer big enough to count the total memory |
| 20 | ** used by Lua. (It is signed due to the use of debt in several | 22 | ** used by Lua. (It is signed due to the use of debt in several |
| @@ -33,7 +35,7 @@ typedef unsigned long lu_mem; | |||
| 33 | #endif /* } */ | 35 | #endif /* } */ |
| 34 | 36 | ||
| 35 | #define MAX_LMEM \ | 37 | #define MAX_LMEM \ |
| 36 | cast(l_mem, (cast(lu_mem, 1) << (sizeof(l_mem) * 8 - 1)) - 1) | 38 | cast(l_mem, (cast(lu_mem, 1) << (l_numbits(l_mem) - 1)) - 1) |
| 37 | 39 | ||
| 38 | 40 | ||
| 39 | /* chars used as small naturals (so that 'char' is reserved for characters) */ | 41 | /* chars used as small naturals (so that 'char' is reserved for characters) */ |
| @@ -61,7 +63,7 @@ typedef lu_byte TStatus; | |||
| 61 | ** floor of the log2 of the maximum signed value for integral type 't'. | 63 | ** floor of the log2 of the maximum signed value for integral type 't'. |
| 62 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) | 64 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) |
| 63 | */ | 65 | */ |
| 64 | #define log2maxs(t) cast_int(sizeof(t) * 8 - 2) | 66 | #define log2maxs(t) (l_numbits(t) - 2) |
| 65 | 67 | ||
| 66 | 68 | ||
| 67 | /* | 69 | /* |
| @@ -67,7 +67,7 @@ typedef union { | |||
| 67 | ** MAXABITS is the largest integer such that 2^MAXABITS fits in an | 67 | ** MAXABITS is the largest integer such that 2^MAXABITS fits in an |
| 68 | ** unsigned int. | 68 | ** unsigned int. |
| 69 | */ | 69 | */ |
| 70 | #define MAXABITS cast_int(sizeof(int) * CHAR_BIT - 1) | 70 | #define MAXABITS (l_numbits(int) - 1) |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | /* | 73 | /* |
| @@ -142,9 +142,6 @@ LUA_API void *debug_realloc (void *ud, void *block, | |||
| 142 | #define STRCACHE_N 23 | 142 | #define STRCACHE_N 23 |
| 143 | #define STRCACHE_M 5 | 143 | #define STRCACHE_M 5 |
| 144 | 144 | ||
| 145 | #undef LUAI_USER_ALIGNMENT_T | ||
| 146 | #define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; } | ||
| 147 | |||
| 148 | 145 | ||
| 149 | /* | 146 | /* |
| 150 | ** This one is not compatible with tests for opcode optimizations, | 147 | ** This one is not compatible with tests for opcode optimizations, |
| @@ -774,7 +774,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) { | |||
| 774 | 774 | ||
| 775 | 775 | ||
| 776 | /* number of bits in an integer */ | 776 | /* number of bits in an integer */ |
| 777 | #define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT) | 777 | #define NBITS l_numbits(lua_Integer) |
| 778 | 778 | ||
| 779 | 779 | ||
| 780 | /* | 780 | /* |
