Skip to content

Commit 916a6f1

Browse files
committed
Fix MSVC compile error
1 parent c07d8a0 commit 916a6f1

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Objects/dictobject.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ CountTrailingZeroesNonzero64(uint64_t x) {
188188
}
189189

190190
// These values are same to hashbrown.
191-
static const char CTRL_EMPTY = 0x80; // -128
192-
static const char CTRL_DUMMY = 0xFF; // -1
191+
#define CTRL_EMPTY (0x80) // -128
192+
#define CTRL_DUMMY (0xFF) // -1
193193

194194
#if HAVE_SSE2
195195
static inline uint64_t
196196
match_byte(uint64_t x, uint8_t n) {
197-
return _mm_movemask_pi8(_mm_cmpeq_pi8(_mm_set1_pi8(n), _m_from_int64((int64_t)x)));
197+
return _mm_movemask_pi8(_mm_cmpeq_pi8(_mm_set1_pi8(n), (__m64)x));
198198
}
199199

200200
static inline uint64_t
@@ -205,7 +205,7 @@ match_empty(uint64_t x) {
205205
static inline uint64_t
206206
match_empty_or_dummy(uint64_t x) {
207207
// A byte is EMPTY or DELETED iff the high bit is set
208-
return _mm_movemask_pi8(_m_from_int64((int64_t)x));
208+
return _mm_movemask_pi8((__m64)x);
209209
}
210210

211211
static inline int
@@ -560,10 +560,10 @@ ctrl_get_index(const group_control *g, uint8_t log2size, int pos)
560560
return ((uint16_t*)(g+1))[pos];
561561
}
562562
else if (log2size <= 32-3) {
563-
return ((uint32_t*)(g+1))[pos];
563+
return (Py_ssize_t)((uint32_t*)(g+1))[pos];
564564
}
565565
else {
566-
return ((uint64_t*)(g+1))[pos];
566+
return (Py_ssize_t)((uint64_t*)(g+1))[pos];
567567
}
568568
}
569569

@@ -916,7 +916,7 @@ dictkeys_stringlookup(PyDictKeysObject* dk, PyObject *key, Py_hash_t hash)
916916
int pos = bitmask_getpos(found); \
917917
/* match_byte() has rare false positive. */ \
918918
if (/* g->control.c[pos] == h2 */ 1) { \
919-
Py_ssize_t ix = g->index[pos]; \
919+
Py_ssize_t ix = (Py_ssize_t)g->index[pos]; \
920920
PyDictKeyEntry *ep = &ep0[ix]; \
921921
if (ep->me_key == key || \
922922
(ep->me_hash == hash \
@@ -932,21 +932,24 @@ dictkeys_stringlookup(PyDictKeysObject* dk, PyObject *key, Py_hash_t hash)
932932
}
933933

934934
if (dk->dk_log2_size <= 8-3) {
935-
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
935+
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
936936
LOOP(group8);
937937
}
938938
else if (dk->dk_log2_size <= 16-3) {
939-
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
939+
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
940940
LOOP(group16);
941941
}
942-
else if (dk->dk_log2_size <= 32-3) {
943-
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
944-
LOOP(group32);
942+
#if SIZEOF_VOID_P > 4
943+
else if (dk->dk_log2_size > 32-3) {
944+
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
945+
LOOP(group64);
945946
}
947+
#endif
946948
else {
947-
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
948-
LOOP(group64);
949+
PyDictKeyEntry *ep0 = DK_ENTRIES(dk);
950+
LOOP(group32);
949951
}
952+
950953
#undef LOOP
951954

952955
Py_UNREACHABLE();

0 commit comments

Comments
 (0)