@@ -1283,30 +1283,30 @@ NPY_NO_EXPORT PyTypeObject PyArray_Type = {
12831283 but in our case it is not a problem in practice because this is used only in stable ABI
12841284 extensions where the original object layout is opaque.
12851285
1286- The first member of the structs are aligned to 8 bytes, because on 32 bit free-threaded builds,
1287- sizeof(PyObject) is not a multiple of 8 so the compiler will add padding to the struct and if we
1288- don't align the first member to 8 bytes, the offsets of fields structs i.e. `PyArray_Descr_fields`
1289- will differ from `PyArray_Descr` which is the actual layout. The alignment of 8 bytes is important
1290- because older abi3 extensions have sizeof(PyObject) which a multiple of 8 so the added alignment of 8
1286+ The first member of the structs are aligned to 16 bytes, because on 32 bit free-threaded builds,
1287+ sizeof(PyObject) is not a multiple of 16 so the compiler will add padding to the struct and if we
1288+ don't align the first member to 16 bytes, the offsets of fields structs i.e. `PyArray_Descr_fields`
1289+ will differ from `PyArray_Descr` which is the actual layout. The alignment of 16 bytes is important
1290+ because older abi3 extensions have sizeof(PyObject) which a multiple of 16 so the added alignment of 16
12911291 does not change the offsets of the fields structs for those extensions.
12921292
12931293 To calculate the correct offset for the fields, we use offsetof with the first member
12941294 of the struct because there can be padding before the first member of the struct and the object header,
12951295 and we want to skip that padding.
12961296*/
12971297
1298- static_assert (NPY_ALIGNOF (PyArray_Descr_fields ) <= 8 ,
1299- "PyArray_Descr must not require more than 8 -byte alignment" );
1300- static_assert (NPY_ALIGNOF (_PyArray_LegacyDescr_fields ) <= 8 ,
1301- "_PyArray_LegacyDescr must not require more than 8 -byte alignment" );
1302- static_assert (NPY_ALIGNOF (PyArrayObject_fields ) <= 8 ,
1303- "PyArrayObject must not require more than 8 -byte alignment" );
1304- static_assert (NPY_ALIGNOF (PyArrayMultiIterObject_fields ) <= 8 ,
1305- "PyArrayMultiIterObject must not require more than 8 -byte alignment" );
1306- static_assert (NPY_ALIGNOF (PyArrayIterObject_fields ) <= 8 ,
1307- "PyArrayIterObject must not require more than 8 -byte alignment" );
1308- static_assert (NPY_ALIGNOF (PyArrayNeighborhoodIterObject_fields ) <= 8 ,
1309- "PyArrayNeighborhoodIterObject must not require more than 8 -byte alignment" );
1298+ static_assert (NPY_ALIGNOF (PyArray_Descr_fields ) <= 16 ,
1299+ "PyArray_Descr must not require more than 16 -byte alignment" );
1300+ static_assert (NPY_ALIGNOF (_PyArray_LegacyDescr_fields ) <= 16 ,
1301+ "_PyArray_LegacyDescr must not require more than 16 -byte alignment" );
1302+ static_assert (NPY_ALIGNOF (PyArrayObject_fields ) <= 16 ,
1303+ "PyArrayObject must not require more than 16 -byte alignment" );
1304+ static_assert (NPY_ALIGNOF (PyArrayMultiIterObject_fields ) <= 16 ,
1305+ "PyArrayMultiIterObject must not require more than 16 -byte alignment" );
1306+ static_assert (NPY_ALIGNOF (PyArrayIterObject_fields ) <= 16 ,
1307+ "PyArrayIterObject must not require more than 16 -byte alignment" );
1308+ static_assert (NPY_ALIGNOF (PyArrayNeighborhoodIterObject_fields ) <= 16 ,
1309+ "PyArrayNeighborhoodIterObject must not require more than 16 -byte alignment" );
13101310#undef _PyDataType_GET_ITEM_DATA
13111311/*NUMPY_API*/
13121312NPY_NO_EXPORT PyArray_Descr_fields *
0 commit comments