]> granicus.if.org Git - python/commitdiff
do not worry about 64-bit dict sizes on 32-bit platforms
authorBenjamin Peterson <benjamin@python.org>
Thu, 8 Sep 2016 20:16:41 +0000 (13:16 -0700)
committerBenjamin Peterson <benjamin@python.org>
Thu, 8 Sep 2016 20:16:41 +0000 (13:16 -0700)
Objects/dict-common.h
Objects/dictobject.c

index 865c020c25eb30aca8bd03884d1f551a11fae1e3..c3baf59ef26aeb5f6c4ee4d9bab8da3b586c1d41 100644 (file)
@@ -59,14 +59,16 @@ struct _dictkeysobject {
        - 1 byte if dk_size <= 0xff (char*)
        - 2 bytes if dk_size <= 0xffff (int16_t*)
        - 4 bytes if dk_size <= 0xffffffff (int32_t*)
-       - 8 bytes otherwise (Py_ssize_t*)
+       - 8 bytes otherwise (int64_t*)
 
        Dynamically sized, 8 is minimum. */
     union {
         int8_t as_1[8];
         int16_t as_2[4];
         int32_t as_4[2];
+#if SIZEOF_VOID_P > 4
         int64_t as_8[1];
+#endif
     } dk_indices;
 
     /* "PyDictKeyEntry dk_entries[dk_usable];" array follows:
index d6f183520ed71c1b905f71bf8defb02ce7efbad6..2dcc847512d657790eddfbca0e0be68563cda466 100644 (file)
@@ -237,7 +237,7 @@ static Py_ssize_t lookdict_split(PyDictObject *mp, PyObject *key,
 
 static int dictresize(PyDictObject *mp, Py_ssize_t minused);
 
-/* Global counter used to set ma_version_tag field of dictionary.
+/*Global counter used to set ma_version_tag field of dictionary.
  * It is incremented each time that a dictionary is created and each
  * time that a dictionary is modified. */
 static uint64_t pydict_global_version = 0;
@@ -292,12 +292,12 @@ PyDict_Fini(void)
     (DK_SIZE(dk) <= 0xff ?                     \
         1 : DK_SIZE(dk) <= 0xffff ?            \
             2 : DK_SIZE(dk) <= 0xffffffff ?    \
-                4 : sizeof(Py_ssize_t))
+                4 : sizeof(int64_t))
 #else
 #define DK_IXSIZE(dk)                          \
     (DK_SIZE(dk) <= 0xff ?                     \
         1 : DK_SIZE(dk) <= 0xffff ?            \
-            2 : sizeof(Py_ssize_t))
+            2 : sizeof(int32_t))
 #endif
 #define DK_ENTRIES(dk) \
     ((PyDictKeyEntry*)(&(dk)->dk_indices.as_1[DK_SIZE(dk) * DK_IXSIZE(dk)]))
@@ -330,10 +330,12 @@ dk_get_index(PyDictKeysObject *keys, Py_ssize_t i)
         int32_t *indices = keys->dk_indices.as_4;
         ix = indices[i];
     }
+#if SIZEOF_VOID_P > 4
     else {
         int64_t *indices = keys->dk_indices.as_8;
         ix = indices[i];
     }
+#endif
     assert(ix >= DKIX_DUMMY);
     return ix;
 }
@@ -361,10 +363,12 @@ dk_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
         assert(ix <= 0x7fffffff);
         indices[i] = (int32_t)ix;
     }
+#if SIZEOF_VOID_P > 4
     else {
         int64_t *indices = keys->dk_indices.as_8;
         indices[i] = ix;
     }
+#endif
 }