Skip to content

Commit 2e7132e

Browse files
committed
change to use new _Py_ALIGN_AS() macro
1 parent 15d92ca commit 2e7132e

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

Include/pymacro.h

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626

2727
// _Py_ALIGN_AS: this compiler's spelling of `alignas` keyword,
28-
// We currently use alignas for free-threaded builds only; additional compat
29-
// checking would be great before we add it to the default build.
28+
// additional compat checking would be great since we added it to the default
29+
// build.
3030
// Standards/compiler support:
3131
// - `alignas` is a keyword in C23 and C++11.
3232
// - `_Alignas` is a keyword in C11
@@ -38,30 +38,28 @@
3838
// unsupported platforms, we don't redefine _Py_ALIGN_AS if it's already
3939
// defined. Note that defining it wrong (including defining it to nothing) will
4040
// cause ABI incompatibilities.
41-
#ifdef Py_GIL_DISABLED
42-
# ifndef _Py_ALIGN_AS
43-
# ifdef __cplusplus
44-
# if __cplusplus >= 201103L
45-
# define _Py_ALIGN_AS(V) alignas(V)
46-
# elif defined(__GNUC__) || defined(__clang__)
47-
# define _Py_ALIGN_AS(V) __attribute__((aligned(V)))
48-
# elif defined(_MSC_VER)
49-
# define _Py_ALIGN_AS(V) __declspec(align(V))
50-
# else
51-
# define _Py_ALIGN_AS(V) alignas(V)
52-
# endif
53-
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
54-
# define _Py_ALIGN_AS(V) alignas(V)
55-
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
56-
# define _Py_ALIGN_AS(V) _Alignas(V)
57-
# elif (defined(__GNUC__) || defined(__clang__))
58-
# define _Py_ALIGN_AS(V) __attribute__((aligned(V)))
59-
# elif defined(_MSC_VER)
60-
# define _Py_ALIGN_AS(V) __declspec(align(V))
61-
# else
62-
# define _Py_ALIGN_AS(V) _Alignas(V)
63-
# endif
64-
# endif
41+
#ifndef _Py_ALIGN_AS
42+
# ifdef __cplusplus
43+
# if __cplusplus >= 201103L
44+
# define _Py_ALIGN_AS(V) alignas(V)
45+
# elif defined(__GNUC__) || defined(__clang__)
46+
# define _Py_ALIGN_AS(V) __attribute__((aligned(V)))
47+
# elif defined(_MSC_VER)
48+
# define _Py_ALIGN_AS(V) __declspec(align(V))
49+
# else
50+
# define _Py_ALIGN_AS(V) alignas(V)
51+
# endif
52+
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
53+
# define _Py_ALIGN_AS(V) alignas(V)
54+
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
55+
# define _Py_ALIGN_AS(V) _Alignas(V)
56+
# elif (defined(__GNUC__) || defined(__clang__))
57+
# define _Py_ALIGN_AS(V) __attribute__((aligned(V)))
58+
# elif defined(_MSC_VER)
59+
# define _Py_ALIGN_AS(V) __declspec(align(V))
60+
# else
61+
# define _Py_ALIGN_AS(V) _Alignas(V)
62+
# endif
6563
#endif
6664

6765
/* Minimum value between x and y */

Modules/arraymodule.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,10 @@ struct arraydescr {
4343
int is_signed;
4444
};
4545

46-
#ifdef _MSC_VER
47-
#define Py_ALIGN_AS(x) __declspec(align(x))
48-
#else
49-
#define Py_ALIGN_AS(x) _Alignas(x)
50-
#endif
51-
5246
typedef struct {
5347
Py_ssize_t allocated;
54-
Py_ALIGN_AS(8) char items[];
48+
_Py_ALIGN_AS(8)
49+
char items[];
5550
} arraydata;
5651

5752
typedef struct arrayobject {

0 commit comments

Comments
 (0)