Skip to contentSkip to conversation

Fix compilation with iso C standard (c89, c99 and c11)

PATCH Applied Simon Zeni 2 participants 2 messages Oct 29, 2020 io_uring

lore
Share & tools
lore

Simon Zeni

author
#0 lore raw

PATCH v2 1/1 Fix compilation with iso C standard (c89, c99 and c11)

- References to the compiler extension typeof have been changed to __typeof__ for portability. See [GCC's documentation][1] about typeof.

- Added the definition _POSIX_C_SOURCE in the source files that are using functions not defined in by the POSIX standard, fixing a few occurences of sigset_t not being defined.

- Added the definition _DEFAULT_SOURCE in setup.c and syscall.c for respectively the madvise function (posix_madvise exists, but there is not equivalent forMADV_DONTFORK), and syscall.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

---
 src/include/liburing/barrier.h | 8 ++++----
 src/queue.c                    | 2 ++
 src/register.c                 | 2 ++
 src/setup.c                    | 3 +++
 src/syscall.c                  | 2 ++
 5 files changed, 13 insertions(+), 4 deletions(-)
src/include/liburing/barrier.h +4 -4
index a4a59fb..89ac682 100644
@@ -56,17 +56,17 @@ static inline T io_uring_smp_load_acquire(const T *p)
 #include <stdatomic.h>
 
 #define IO_URING_WRITE_ONCE(var, val)				\
-	atomic_store_explicit((_Atomic typeof(var) *)&(var),	\
+	atomic_store_explicit((_Atomic __typeof__(var) *)&(var),	\
 			      (val), memory_order_relaxed)
 #define IO_URING_READ_ONCE(var)					\
-	atomic_load_explicit((_Atomic typeof(var) *)&(var),	\
+	atomic_load_explicit((_Atomic __typeof__(var) *)&(var),	\
 			     memory_order_relaxed)
 
 #define io_uring_smp_store_release(p, v)			\
-	atomic_store_explicit((_Atomic typeof(*(p)) *)(p), (v), \
+	atomic_store_explicit((_Atomic __typeof__(*(p)) *)(p), (v), \
 			      memory_order_release)
 #define io_uring_smp_load_acquire(p)				\
-	atomic_load_explicit((_Atomic typeof(*(p)) *)(p),	\
+	atomic_load_explicit((_Atomic __typeof__(*(p)) *)(p),	\
 			     memory_order_acquire)
 #endif
 
src/queue.c +2 -0
index 24fde2d..053d430 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: MIT */
+#define _POSIX_C_SOURCE 200112L
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
src/register.c +2 -0
index f3787c0..994aaff 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: MIT */
+#define _POSIX_C_SOURCE 200112L
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
src/setup.c +3 -0
index 8e14085..dded481 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: MIT */
+#define _DEFAULT_SOURCE
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
@@ -6,6 +8,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <signal.h>
 
 #include "liburing/compat.h"
 #include "liburing/io_uring.h"
src/syscall.c +2 -0
index 598b531..49b4ec2 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: MIT */
+#define _DEFAULT_SOURCE
+
 /*
  * Will go away once libc support is there
  */

--
2.29.1

maintainer Applied
#1 lore raw
Quoted 8 lines · Simon Zeni

- References to the compiler extension typeof have been changed to __typeof__ for portability. See [GCC's documentation][1] about typeof.

- Added the definition _POSIX_C_SOURCE in the source files that are using functions not defined in by the POSIX standard, fixing a few occurences of sigset_t not being defined.

Quoted 5 lines

- Added the definition _DEFAULT_SOURCE in setup.c and syscall.c for respectively the madvise function (posix_madvise exists, but there is not equivalent forMADV_DONTFORK), and syscall.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

Thanks, applied.

Signature · 1 line
Jens Axboe