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