aboutsummaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/llimits.h b/llimits.h
index d206e9e1..710dc1b4 100644
--- a/llimits.h
+++ b/llimits.h
@@ -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/*