]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/include: replace _Static_assert() with static_assert()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 6 Jul 2025 02:33:58 +0000 (11:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 6 Jul 2025 13:02:18 +0000 (22:02 +0900)
If one of the header is included in a C++ source file, then using
_Static_assert() triggers compile error for some reasons.
Let's use static_assert(), which can be used by both C and C++ code.

src/basic/include/sched.h
src/basic/include/sys/mman.h
src/basic/include/sys/random.h
src/basic/include/sys/wait.h

index 13eb8d059e6650edeac20e9be50e3697043bc083..41c830e26b5569f14af681ed7d4422ee8dad099b 100644 (file)
@@ -8,19 +8,21 @@
 
 #include_next <sched.h>
 
+#include <assert.h>
+
 /* 769071ac9f20b6a447410c7eaa55d1a5233ef40c (5.8),
  * defined in sched.h since glibc-2.36. */
 #ifndef CLONE_NEWTIME
 #  define CLONE_NEWTIME 0x00000080
 #else
-_Static_assert(CLONE_NEWTIME == 0x00000080, "");
+static_assert(CLONE_NEWTIME == 0x00000080, "");
 #endif
 
 /* Not exposed yet. Defined at include/linux/sched.h */
 #ifndef PF_KTHREAD
 #  define PF_KTHREAD 0x00200000
 #else
-_Static_assert(PF_KTHREAD == 0x00200000, "");
+static_assert(PF_KTHREAD == 0x00200000, "");
 #endif
 
 /* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of
@@ -31,5 +33,5 @@ _Static_assert(PF_KTHREAD == 0x00200000, "");
 #ifndef TASK_COMM_LEN
 #  define TASK_COMM_LEN 16
 #else
-_Static_assert(TASK_COMM_LEN == 16, "");
+static_assert(TASK_COMM_LEN == 16, "");
 #endif
index 50b03bddf03dd06728ad5786b3051e58fab663b8..68623df7890cc7e8c283304f53a72a9581f5cd6a 100644 (file)
@@ -3,16 +3,18 @@
 
 #include_next <sys/mman.h>
 
+#include <assert.h>
+
 /* since glibc-2.38 */
 #ifndef MFD_NOEXEC_SEAL
 #  define MFD_NOEXEC_SEAL 0x0008U
 #else
-_Static_assert(MFD_NOEXEC_SEAL == 0x0008U, "");
+static_assert(MFD_NOEXEC_SEAL == 0x0008U, "");
 #endif
 
 /* since glibc-2.38 */
 #ifndef MFD_EXEC
 #  define MFD_EXEC 0x0010U
 #else
-_Static_assert(MFD_EXEC == 0x0010U, "");
+static_assert(MFD_EXEC == 0x0010U, "");
 #endif
index c0d1197aa500041fb0bee44bd011c2cda9bbbe86..5750aac1bc0958c804bd4cf0d33f9b0edd43450c 100644 (file)
@@ -3,9 +3,11 @@
 
 #include_next <sys/random.h>
 
+#include <assert.h>
+
 /* Defined since glibc-2.32. */
 #ifndef GRND_INSECURE
 #  define GRND_INSECURE 0x0004
 #else
-_Static_assert(GRND_INSECURE == 0x0004, "");
+static_assert(GRND_INSECURE == 0x0004, "");
 #endif
index 0981631cf656d1882be0d3da8028f4919bf98e74..3a80e8489ab02940c00285f2f6597c889d8f58ea 100644 (file)
@@ -3,9 +3,11 @@
 
 #include_next <sys/wait.h>
 
+#include <assert.h>
+
 /* since glibc-2.36 */
 #ifndef P_PIDFD
 #  define P_PIDFD 3
 #else
-_Static_assert(P_PIDFD == 3, "");
+static_assert(P_PIDFD == 3, "");
 #endif