]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: replace __alignof__() with alignof()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 14 Apr 2023 04:55:31 +0000 (13:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 14 Apr 2023 05:39:06 +0000 (14:39 +0900)
Addresses https://github.com/systemd/systemd/pull/27254#discussion_r1165267046.

src/basic/socket-util.h
src/boot/efi/pe.c
src/fundamental/macro-fundamental.h
src/network/networkd-nexthop.c
src/test/test-sizeof.c

index 00c2998adb4b74093dc2ec828bbd9790d454b846..d6d63a4f339a0366620269ff4ecf781682d1aaa3 100644 (file)
@@ -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; \
         })
 
index e516417c07158199689f44acb1ecf361626b77c2..9759d036b38c82324ff48f27af0593968cf36fd9 100644 (file)
@@ -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)
index fa5b5d221a4d5575b966a09920d88a2ddd7cbfdf..e901e8fb596a2e0f49803002fe72b153cde8ae64 100644 (file)
@@ -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;                                       \
         })
 
index d82766702ac180e410a214861a1b796bddfa8ece..0820e0db2de3b00d660f3cd9d2b7bd9bc52fda89 100644 (file)
@@ -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++) {
index 55bd81e22fdb4966e2d7d6a760db78b23e82fba1..30b252ecd9da7bb31844d4403e1c6827bb777460 100644 (file)
 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*);