mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-02 06:57:24 +00: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 <[email protected]>
This commit is contained in:
+3
-3
@@ -88,13 +88,13 @@ typedef uint64_t __packed mbedtls_uint64_unaligned_t;
|
|||||||
#define UINT_UNALIGNED_STRUCT
|
#define UINT_UNALIGNED_STRUCT
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
} __attribute__((packed)) mbedtls_uint16_unaligned_t;
|
} __attribute__((packed, may_alias)) mbedtls_uint16_unaligned_t;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
} __attribute__((packed)) mbedtls_uint32_unaligned_t;
|
} __attribute__((packed, may_alias)) mbedtls_uint32_unaligned_t;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t x;
|
uint64_t x;
|
||||||
} __attribute__((packed)) mbedtls_uint64_unaligned_t;
|
} __attribute__((packed, may_alias)) mbedtls_uint64_unaligned_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user