Skip to content

Commit

Permalink
Use ALIGNOF_MAX_ALIGN_T
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Apr 19, 2023
1 parent b03d431 commit ec9d5a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
8 changes: 1 addition & 7 deletions Modules/_testcapi/heaptype_relative.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,7 @@ _PyTestCapi_Init_HeaptypeRelative(PyObject *m) {
return -1;
}

#ifdef __alignof_is_defined
// C11
PyModule_AddIntConstant(m, "alignof_max_align_t", alignof(max_align_t));
#else
// if alignof and max_align_t is unavailable, skip the alignment tests
PyModule_AddIntConstant(m, "alignof_max_align_t", 1);
#endif
PyModule_AddIntConstant(m, "alignof_max_align_t", ALIGNOF_MAX_ALIGN_T);

return 0;
}
Expand Down
15 changes: 1 addition & 14 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3553,22 +3553,9 @@ static const PySlot_Offset pyslot_offsets[] = {
/* Align up to the nearest multiple of alignof(max_align_t)
* (like _Py_ALIGN_UP, but for a size rather than pointer)
*/
#if __alignof_is_defined
// C11
#define MAX_ALIGN alignof(max_align_t)
#else
// workaround for MSVC
typedef union {
intmax_t x;
long double y;
void *z;
void (*f)();
} _max_align_t_wannabe;
#define MAX_ALIGN _Alignof(_max_align_t_wannabe)
#endif
static Py_ssize_t
_align_up(Py_ssize_t size) {
return (size + MAX_ALIGN - 1) & ~(MAX_ALIGN - 1);
return (size + ALIGNOF_MAX_ALIGN_T - 1) & ~(ALIGNOF_MAX_ALIGN_T - 1);
}

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

0 comments on commit ec9d5a8

Please sign in to comment.