Skip to content

Commit aad4907

Browse files
fix windows 32 bit: use clang -target i686-pc-windows-msvc
1 parent 4c889e8 commit aad4907

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

Include/internal/pycore_dict.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,21 @@ struct _dictvalues {
232232
#define DK_SIZE(dk) (1<<DK_LOG_SIZE(dk))
233233
#endif
234234

235-
static inline void* _DK_INDICES_BASE(const PyDictKeysObject *dk) {
235+
static inline const void* _DK_INDICES_CONST_BASE(const PyDictKeysObject *dk) {
236236
size_t indices_size = (size_t)1 << dk->dk_log2_index_bytes;
237-
return (char *)dk - indices_size;
237+
return (const char *)dk - indices_size;
238+
}
239+
240+
static inline void* _DK_INDICES_BASE(PyDictKeysObject *dk) {
241+
return (void *)_DK_INDICES_CONST_BASE(dk);
242+
}
243+
244+
static inline const void* _DK_ALLOC_CONST_BASE(const PyDictKeysObject *dk) {
245+
return _DK_INDICES_CONST_BASE(dk);
238246
}
239247

240248
static inline void* _DK_ALLOC_BASE(PyDictKeysObject *dk) {
241-
return _DK_INDICES_BASE(dk);
249+
return (void *)_DK_ALLOC_CONST_BASE(dk);
242250
}
243251

244252
static inline void* _DK_ENTRIES(PyDictKeysObject *dk) {

Modules/_testinternalcapi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ dict_getitem_knownhash(PyObject *self, PyObject *args)
19041904
}
19051905

19061906
static size_t
1907-
dict_index_bytes_for_keys(PyDictKeysObject *keys)
1907+
dict_index_bytes_for_keys(const PyDictKeysObject *keys)
19081908
{
19091909
int index_shift = keys->dk_log2_index_bytes - DK_LOG_SIZE(keys);
19101910
if (index_shift == 0) {
@@ -1936,7 +1936,7 @@ dict_check_indices_layout(PyObject *self, PyObject *arg)
19361936
PyDictKeysObject *keys = mp->ma_keys;
19371937

19381938
size_t indices_size = (size_t)1 << keys->dk_log2_index_bytes;
1939-
char *base = (char *)_DK_ALLOC_BASE(keys);
1939+
const char *base = (const char *)_DK_ALLOC_CONST_BASE(keys);
19401940
char *header = (char *)keys;
19411941
char *entries = (char *)_DK_ENTRIES(keys);
19421942

@@ -1945,7 +1945,7 @@ dict_check_indices_layout(PyObject *self, PyObject *arg)
19451945
ok &= (entries == header + offsetof(PyDictKeysObject, dk_entries));
19461946

19471947
size_t index_bytes = dict_index_bytes_for_keys(keys);
1948-
char *idx_base = (char *)_DK_INDICES_BASE(keys);
1948+
const char *idx_base = (const char *)_DK_INDICES_CONST_BASE(keys);
19491949
/* Index 0 is stored immediately before the header. */
19501950
char *idx0 = (char *)keys - (ptrdiff_t)index_bytes;
19511951
ok &= (idx0 == idx_base + indices_size - (ptrdiff_t)index_bytes);

Objects/dictobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ ASSERT_DICT_LOCKED(PyObject *op)
182182

183183
#define IS_DICT_SHARED(mp) _PyObject_GC_IS_SHARED(mp)
184184
#define SET_DICT_SHARED(mp) _PyObject_GC_SET_SHARED(mp)
185-
#define LOAD_INDEX(keys, size, idx) _Py_atomic_load_int##size##_relaxed(&((const int##size##_t*)(_DK_INDICES_BASE(keys)))[(idx)]);
185+
#define LOAD_INDEX(keys, size, idx) _Py_atomic_load_int##size##_relaxed(&((const int##size##_t*)(_DK_INDICES_CONST_BASE(keys)))[(idx)]);
186186
#define STORE_INDEX(keys, size, idx, value) _Py_atomic_store_int##size##_relaxed(&((int##size##_t*)(_DK_INDICES_BASE(keys)))[(idx)], (int##size##_t)value);
187187
#define ASSERT_OWNED_OR_SHARED(mp) \
188188
assert(_Py_IsOwnedByCurrentThread((PyObject *)mp) || IS_DICT_SHARED(mp));
@@ -262,7 +262,7 @@ static inline void split_keys_entry_added(PyDictKeysObject *keys)
262262
#define UNLOCK_KEYS_IF_SPLIT(keys, kind)
263263
#define IS_DICT_SHARED(mp) (false)
264264
#define SET_DICT_SHARED(mp)
265-
#define LOAD_INDEX(keys, size, idx) ((const int##size##_t*)(_DK_INDICES_BASE(keys)))[(idx)]
265+
#define LOAD_INDEX(keys, size, idx) ((const int##size##_t*)(_DK_INDICES_CONST_BASE(keys)))[(idx)]
266266
#define STORE_INDEX(keys, size, idx, value) ((int##size##_t*)(_DK_INDICES_BASE(keys)))[(idx)] = (int##size##_t)value
267267

268268
static inline void split_keys_entry_added(PyDictKeysObject *keys)
@@ -651,7 +651,7 @@ static const _PyDict_EmptyKeysStorage empty_keys_storage = {
651651
1, /* dk_version */
652652
0, /* dk_usable (immutable) */
653653
0, /* dk_nentries */
654-
{}, /* dk_entries */
654+
{0}, /* dk_entries */
655655
}
656656
};
657657

@@ -989,7 +989,7 @@ clone_combined_dict_keys(PyDictObject *orig)
989989

990990
PyDictKeysObject *keys = (PyDictKeysObject *)((char *)base + indices_size);
991991

992-
memcpy(base, _DK_ALLOC_BASE(orig_keys), keys_size);
992+
memcpy(base, _DK_ALLOC_CONST_BASE(orig_keys), keys_size);
993993

994994
/* After copying key/value pairs, we need to incref all
995995
keys and values and they are about to be co-owned by a

0 commit comments

Comments
 (0)