mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-04-04 03:26:54 +02:00
library: alignment: add "may_alias" attribute to mbedtls_uintXX_unaligned_t structs
Tell the GCC compiler that pointers to types "mbedtls_uintXX_unaligned_t" (where XX is 16, 32 or 64) might alias with other types. This helps at high optimizations level (i.e. "-O3") so that the compiler does not mess up with instruction reordering and memory accesses. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@@ -88,13 +88,13 @@ typedef uint64_t __packed mbedtls_uint64_unaligned_t;
|
||||
#define UINT_UNALIGNED_STRUCT
|
||||
typedef struct {
|
||||
uint16_t x;
|
||||
} __attribute__((packed)) mbedtls_uint16_unaligned_t;
|
||||
} __attribute__((packed, may_alias)) mbedtls_uint16_unaligned_t;
|
||||
typedef struct {
|
||||
uint32_t x;
|
||||
} __attribute__((packed)) mbedtls_uint32_unaligned_t;
|
||||
} __attribute__((packed, may_alias)) mbedtls_uint32_unaligned_t;
|
||||
typedef struct {
|
||||
uint64_t x;
|
||||
} __attribute__((packed)) mbedtls_uint64_unaligned_t;
|
||||
} __attribute__((packed, may_alias)) mbedtls_uint64_unaligned_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user