Skip to content

Commit ec9d5a8

Browse files
committed
Use ALIGNOF_MAX_ALIGN_T
1 parent b03d431 commit ec9d5a8

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

Modules/_testcapi/heaptype_relative.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,7 @@ _PyTestCapi_Init_HeaptypeRelative(PyObject *m) {
280280
return -1;
281281
}
282282

283-
#ifdef __alignof_is_defined
284-
// C11
285-
PyModule_AddIntConstant(m, "alignof_max_align_t", alignof(max_align_t));
286-
#else
287-
// if alignof and max_align_t is unavailable, skip the alignment tests
288-
PyModule_AddIntConstant(m, "alignof_max_align_t", 1);
289-
#endif
283+
PyModule_AddIntConstant(m, "alignof_max_align_t", ALIGNOF_MAX_ALIGN_T);
290284

291285
return 0;
292286
}

Objects/typeobject.c

+1-14
Original file line numberDiff line numberDiff line change
@@ -3553,22 +3553,9 @@ static const PySlot_Offset pyslot_offsets[] = {
35533553
/* Align up to the nearest multiple of alignof(max_align_t)
35543554
* (like _Py_ALIGN_UP, but for a size rather than pointer)
35553555
*/
3556-
#if __alignof_is_defined
3557-
// C11
3558-
#define MAX_ALIGN alignof(max_align_t)
3559-
#else
3560-
// workaround for MSVC
3561-
typedef union {
3562-
intmax_t x;
3563-
long double y;
3564-
void *z;
3565-
void (*f)();
3566-
} _max_align_t_wannabe;
3567-
#define MAX_ALIGN _Alignof(_max_align_t_wannabe)
3568-
#endif
35693556
static Py_ssize_t
35703557
_align_up(Py_ssize_t size) {
3571-
return (size + MAX_ALIGN - 1) & ~(MAX_ALIGN - 1);
3558+
return (size + ALIGNOF_MAX_ALIGN_T - 1) & ~(ALIGNOF_MAX_ALIGN_T - 1);
35723559
}
35733560

35743561
/* Given a PyType_FromMetaclass `bases` argument (NULL, type, or tuple of

0 commit comments

Comments
 (0)