-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
The struct module uses pre-C11 hacks to determine alignment for types:
Lines 79 to 106 in 5808889
/* Define various structs to figure out the alignments of types */ | |
typedef struct { char c; short x; } st_short; | |
typedef struct { char c; int x; } st_int; | |
typedef struct { char c; long x; } st_long; | |
typedef struct { char c; float x; } st_float; | |
typedef struct { char c; double x; } st_double; | |
#ifdef Py_HAVE_C_COMPLEX | |
typedef struct { char c; float complex x; } st_float_complex; | |
typedef struct { char c; double complex x; } st_double_complex; | |
#endif | |
typedef struct { char c; void *x; } st_void_p; | |
typedef struct { char c; size_t x; } st_size_t; | |
typedef struct { char c; _Bool x; } st_bool; | |
#define SHORT_ALIGN (sizeof(st_short) - sizeof(short)) | |
#define INT_ALIGN (sizeof(st_int) - sizeof(int)) | |
#define LONG_ALIGN (sizeof(st_long) - sizeof(long)) | |
#define FLOAT_ALIGN (sizeof(st_float) - sizeof(float)) | |
#define DOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) | |
#ifdef Py_HAVE_C_COMPLEX | |
# define FLOAT_COMPLEX_ALIGN (sizeof(st_float_complex) - sizeof(float complex)) | |
# define DOUBLE_COMPLEX_ALIGN (sizeof(st_double_complex) - sizeof(double complex)) | |
#endif | |
#define VOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) | |
#define SIZE_T_ALIGN (sizeof(st_size_t) - sizeof(size_t)) | |
#define BOOL_ALIGN (sizeof(st_bool) - sizeof(_Bool)) |
Now we can use _Alignof
operator, as C11-compatible compiler is a build requireent.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement