Skip to content

Commit 897512d

Browse files
committed
use unsigned ints also for 64 maps, for the sake of consistance but also to avoid undefined/implementation defined behaviors in case of an overflow
1 parent a2e5679 commit 897512d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

pandas/_libs/src/klib/khash.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ typedef unsigned long khint32_t;
122122
#endif
123123

124124
#if ULONG_MAX == ULLONG_MAX
125-
typedef unsigned long khuint64_t;
126-
typedef signed long khint64_t;
125+
typedef unsigned long khint64_t;
127126
#else
128-
typedef unsigned long long khuint64_t;
129-
typedef signed long long khint64_t;
127+
typedef unsigned long long khint64_t;
130128
#endif
131129

132130
#if UINT_MAX == 0xffffu
@@ -605,7 +603,7 @@ PANDAS_INLINE khint_t __ac_Wang_hash(khint_t key)
605603
// is implementation defined for signed ints if sign-bit is set.
606604
// because we never really "get" the keys, there will be no convertion from
607605
// unsigend int to (signed) int (which would be implementation defined behavior)
608-
// this holds also for 16- and 8-bit integers
606+
// this holds also for 64-, 16- and 8-bit integers
609607
#define KHASH_MAP_INIT_INT(name, khval_t) \
610608
KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
611609

@@ -617,7 +615,7 @@ PANDAS_INLINE khint_t __ac_Wang_hash(khint_t key)
617615
@param name Name of the hash table [symbol]
618616
*/
619617
#define KHASH_SET_INIT_UINT64(name) \
620-
KHASH_INIT(name, khuint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
618+
KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
621619

622620
#define KHASH_SET_INIT_INT64(name) \
623621
KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
@@ -628,7 +626,7 @@ PANDAS_INLINE khint_t __ac_Wang_hash(khint_t key)
628626
@param khval_t Type of values [type]
629627
*/
630628
#define KHASH_MAP_INIT_UINT64(name, khval_t) \
631-
KHASH_INIT(name, khuint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
629+
KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
632630

633631
#define KHASH_MAP_INIT_INT64(name, khval_t) \
634632
KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)

0 commit comments

Comments
 (0)