summaryrefslogtreecommitdiff
path: root/source/luametatex/source/luacore/lua54/src/llimits.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/luametatex/source/luacore/lua54/src/llimits.h')
-rw-r--r--source/luametatex/source/luacore/lua54/src/llimits.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/luametatex/source/luacore/lua54/src/llimits.h b/source/luametatex/source/luacore/lua54/src/llimits.h
index 52a32f92e..251a27021 100644
--- a/source/luametatex/source/luacore/lua54/src/llimits.h
+++ b/source/luametatex/source/luacore/lua54/src/llimits.h
@@ -71,11 +71,24 @@ typedef signed char ls_byte;
/*
-** conversion of pointer to unsigned integer:
-** this is for hashing only; there is no problem if the integer
-** cannot hold the whole pointer value
+** conversion of pointer to unsigned integer: this is for hashing only;
+** there is no problem if the integer cannot hold the whole pointer
+** value. (In strict ISO C this may cause undefined behavior, but no
+** actual machine seems to bother.)
*/
-#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX))
+#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
+ __STDC_VERSION__ >= 199901L
+#include <stdint.h>
+#if defined(UINTPTR_MAX) /* even in C99 this type is optional */
+#define L_P2I uintptr_t
+#else /* no 'intptr'? */
+#define L_P2I uintmax_t /* use the largerst available integer */
+#endif
+#else /* C89 option */
+#define L_P2I size_t
+#endif
+
+#define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX))