diff options
-rw-r--r-- | config/CMakeLists.txt | 1 | ||||
-rw-r--r-- | config/config.h.in | 6 | ||||
-rw-r--r-- | src/api/helpers.c | 8 |
3 files changed, 14 insertions, 1 deletions
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index b94c3f9f07..747ed175ac 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -5,6 +5,7 @@ check_type_size("int" SIZEOF_INT) check_type_size("long" SIZEOF_LONG) check_type_size("time_t" SIZEOF_TIME_T) check_type_size("off_t" SIZEOF_OFF_T) +check_type_size("void *" SIZEOF_VOID_PTR) check_symbol_exists(_NSGetEnviron crt_externs.h HAVE__NSGETENVIRON) diff --git a/config/config.h.in b/config/config.h.in index ae3b473d1d..95d0d3cf68 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -11,6 +11,12 @@ #define SIZEOF_TIME_T @SIZEOF_TIME_T@ #define SIZEOF_OFF_T @SIZEOF_OFF_T@ +#if @SIZEOF_VOID_PTR@ == 8 +#define ARCH_64 +#elif @SIZEOF_VOID_PTR@ == 4 +#define ARCH_32 +#endif + #define _FILE_OFFSET_BITS 64 #cmakedefine HAVE__NSGETENVIRON #cmakedefine HAVE_CRT_EXTERNS_H diff --git a/src/api/helpers.c b/src/api/helpers.c index 585ad493d5..51b1dcb754 100644 --- a/src/api/helpers.c +++ b/src/api/helpers.c @@ -14,7 +14,13 @@ #include "lib/khash.h" +#if defined(ARCH_64) +typedef uint64_t ptr_int_t; KHASH_SET_INIT_INT64(Lookup) +#elif defined(ARCH_32) +typedef uint32_t ptr_int_t; +KHASH_SET_INIT_INT(Lookup) +#endif /// Recursion helper for the `vim_to_object`. This uses a pointer table /// to avoid infinite recursion due to cyclic references @@ -406,7 +412,7 @@ static Object vim_to_object_rec(typval_T *obj, khash_t(Lookup) *lookup) if (obj->v_type == VAR_LIST || obj->v_type == VAR_DICT) { int ret; // Container object, add it to the lookup table - kh_put(Lookup, lookup, (uint64_t)obj, &ret); + kh_put(Lookup, lookup, (ptr_int_t)obj, &ret); if (!ret) { // It's already present, meaning we alredy processed it so just return // nil instead. |