diff options
Diffstat (limited to 'llimits.h')
-rw-r--r-- | llimits.h | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -70,11 +70,24 @@ typedef signed char ls_byte; | |||
70 | 70 | ||
71 | 71 | ||
72 | /* | 72 | /* |
73 | ** conversion of pointer to unsigned integer: | 73 | ** conversion of pointer to unsigned integer: this is for hashing only; |
74 | ** this is for hashing only; there is no problem if the integer | 74 | ** there is no problem if the integer cannot hold the whole pointer |
75 | ** cannot hold the whole pointer value | 75 | ** value. (In strict ISO C this may cause undefined behavior, but no |
76 | ** actual machine seems to bother.) | ||
76 | */ | 77 | */ |
77 | #define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) | 78 | #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ |
79 | __STDC_VERSION__ >= 199901L | ||
80 | #include <stdint.h> | ||
81 | #if defined(UINTPTR_MAX) /* even in C99 this type is optional */ | ||
82 | #define L_P2I uintptr_t | ||
83 | #else /* no 'intptr'? */ | ||
84 | #define L_P2I uintmax_t /* use the largerst available integer */ | ||
85 | #endif | ||
86 | #else /* C89 option */ | ||
87 | #define L_P2I size_t | ||
88 | #endif | ||
89 | |||
90 | #define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX)) | ||
78 | 91 | ||
79 | 92 | ||
80 | 93 | ||