diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/socket-util.h | 2 | ||||
-rw-r--r-- | src/boot/efi/pe.c | 2 | ||||
-rw-r--r-- | src/fundamental/macro-fundamental.h | 11 | ||||
-rw-r--r-- | src/network/networkd-nexthop.c | 2 | ||||
-rw-r--r-- | src/test/test-sizeof.c | 10 |
5 files changed, 14 insertions, 13 deletions
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h index 00c2998adb..d6d63a4f33 100644 --- a/src/basic/socket-util.h +++ b/src/basic/socket-util.h @@ -184,7 +184,7 @@ int flush_accept(int fd); #define CMSG_TYPED_DATA(cmsg, type) \ ({ \ struct cmsghdr *_cmsg = (cmsg); \ - assert_cc(__alignof__(type) <= __alignof__(struct cmsghdr)); \ + assert_cc(alignof(type) <= alignof(struct cmsghdr)); \ _cmsg ? CAST_ALIGN_PTR(type, CMSG_DATA(_cmsg)) : (type*) NULL; \ }) diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c index e516417c07..9759d036b3 100644 --- a/src/boot/efi/pe.c +++ b/src/boot/efi/pe.c @@ -191,7 +191,7 @@ static uint32_t get_compatibility_entry_address(const DosFileHeader *dos, const uint32_t entry_point; } _packed_ LinuxPeCompat1; - while (size >= sizeof(LinuxPeCompat1) && addr % __alignof__(LinuxPeCompat1) == 0) { + while (size >= sizeof(LinuxPeCompat1) && addr % alignof(LinuxPeCompat1) == 0) { LinuxPeCompat1 *compat = (LinuxPeCompat1 *) ((uint8_t *) dos + addr); if (compat->type == 0 || compat->size == 0 || compat->size > size) diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index fa5b5d221a..e901e8fb59 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -6,12 +6,13 @@ #endif #include <limits.h> +#include <stdalign.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #define _align_(x) __attribute__((__aligned__(x))) -#define _alignas_(x) __attribute__((__aligned__(__alignof__(x)))) +#define _alignas_(x) __attribute__((__aligned__(alignof(x)))) #define _alignptr_ __attribute__((__aligned__(sizeof(void *)))) #define _cleanup_(x) __attribute__((__cleanup__(x))) #define _const_ __attribute__((__const__)) @@ -343,9 +344,9 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #define ALIGN_PTR(p) ((void*) ALIGN((uintptr_t) (p))) /* Checks if the specified pointer is aligned as appropriate for the specific type */ -#define IS_ALIGNED16(p) (((uintptr_t) p) % __alignof__(uint16_t) == 0) -#define IS_ALIGNED32(p) (((uintptr_t) p) % __alignof__(uint32_t) == 0) -#define IS_ALIGNED64(p) (((uintptr_t) p) % __alignof__(uint64_t) == 0) +#define IS_ALIGNED16(p) (((uintptr_t) p) % alignof(uint16_t) == 0) +#define IS_ALIGNED32(p) (((uintptr_t) p) % alignof(uint32_t) == 0) +#define IS_ALIGNED64(p) (((uintptr_t) p) % alignof(uint64_t) == 0) /* Same as ALIGN_TO but callable in constant contexts. */ #define CONST_ALIGN_TO(l, ali) \ @@ -363,7 +364,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { #define CAST_ALIGN_PTR(t, p) \ ({ \ const void *_p = (p); \ - assert(((uintptr_t) _p) % __alignof__(t) == 0); \ + assert(((uintptr_t) _p) % alignof(t) == 0); \ (t *) _p; \ }) diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index d82766702a..0820e0db2d 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -894,7 +894,7 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, return 0; } - assert((uintptr_t) group % __alignof__(struct nexthop_grp) == 0); + assert((uintptr_t) group % alignof(struct nexthop_grp) == 0); n_group = raw_group_size / sizeof(struct nexthop_grp); for (size_t i = 0; i < n_group; i++) { diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c index 55bd81e22f..30b252ecd9 100644 --- a/src/test/test-sizeof.c +++ b/src/test/test-sizeof.c @@ -17,16 +17,16 @@ DISABLE_WARNING_TYPE_LIMITS; #define info_no_sign(t) \ - printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \ + printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \ sizeof(t)*CHAR_BIT, \ - __alignof__(t)) + alignof(t)) #define info(t) \ - printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ + printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ sizeof(t)*CHAR_BIT, \ strstr(STRINGIFY(t), "signed") ? "" : \ (t)-1 < (t)0 ? ", signed" : ", unsigned", \ - __alignof__(t)) + alignof(t)) enum Enum { enum_value, @@ -44,7 +44,7 @@ enum BigEnum2 { int main(void) { int (*function_pointer)(void); - info_no_sign(function_pointer); + info_no_sign(typeof(function_pointer)); info_no_sign(void*); info(char*); |