diff options
Diffstat (limited to 'llimits.h')
-rw-r--r-- | llimits.h | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -16,21 +16,25 @@ | |||
16 | 16 | ||
17 | 17 | ||
18 | /* | 18 | /* |
19 | ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count | 19 | ** 'lu_mem' is an unsigned integer big enough to count the total memory |
20 | ** the total memory used by Lua (in bytes). Usually, 'size_t' and | 20 | ** used by Lua (in bytes). 'l_obj' is a signed integer big enough to |
21 | ** count the total number of objects used by Lua. (It is signed due | ||
22 | ** to the use of debt in several computations.) Usually, 'size_t' and | ||
21 | ** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines. | 23 | ** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines. |
22 | */ | 24 | */ |
23 | #if defined(LUAI_MEM) /* { external definitions? */ | 25 | #if defined(LUAI_MEM) /* { external definitions? */ |
24 | typedef LUAI_UMEM lu_mem; | 26 | typedef LUAI_UMEM lu_mem; |
25 | typedef LUAI_MEM l_mem; | 27 | typedef LUAI_MEM l_obj; |
26 | #elif LUAI_IS32INT /* }{ */ | 28 | #elif LUAI_IS32INT /* }{ */ |
27 | typedef size_t lu_mem; | 29 | typedef size_t lu_mem; |
28 | typedef ptrdiff_t l_mem; | 30 | typedef ptrdiff_t l_obj; |
29 | #else /* 16-bit ints */ /* }{ */ | 31 | #else /* 16-bit ints */ /* }{ */ |
30 | typedef unsigned long lu_mem; | 32 | typedef unsigned long lu_mem; |
31 | typedef long l_mem; | 33 | typedef long l_obj; |
32 | #endif /* } */ | 34 | #endif /* } */ |
33 | 35 | ||
36 | #define MAX_LOBJ cast(l_obj, ~cast(lu_mem, 0) >> 1) | ||
37 | |||
34 | 38 | ||
35 | /* chars used as small naturals (so that 'char' is reserved for characters) */ | 39 | /* chars used as small naturals (so that 'char' is reserved for characters) */ |
36 | typedef unsigned char lu_byte; | 40 | typedef unsigned char lu_byte; |
@@ -45,11 +49,6 @@ typedef signed char ls_byte; | |||
45 | : (size_t)(LUA_MAXINTEGER)) | 49 | : (size_t)(LUA_MAXINTEGER)) |
46 | 50 | ||
47 | 51 | ||
48 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)) | ||
49 | |||
50 | #define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1)) | ||
51 | |||
52 | |||
53 | #define MAX_INT INT_MAX /* maximum value of an int */ | 52 | #define MAX_INT INT_MAX /* maximum value of an int */ |
54 | 53 | ||
55 | 54 | ||
@@ -57,7 +56,7 @@ typedef signed char ls_byte; | |||
57 | ** floor of the log2 of the maximum signed value for integral type 't'. | 56 | ** floor of the log2 of the maximum signed value for integral type 't'. |
58 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) | 57 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) |
59 | */ | 58 | */ |
60 | #define log2maxs(t) (sizeof(t) * 8 - 2) | 59 | #define log2maxs(t) cast_int(sizeof(t) * 8 - 2) |
61 | 60 | ||
62 | 61 | ||
63 | /* | 62 | /* |