#ifndef ARCH_H
#define ARCH_H
+#ifdef __cplusplus
+#include <atomic>
+#else
+#include <stdatomic.h>
+#endif
+
#include "../lib/types.h"
enum {
#define ARCH_CPU_CLOCK_WRAPS
+#ifdef __cplusplus
+#define atomic_add(p, v) \
+ std::atomic_fetch_add(p, (v))
+#define atomic_sub(p, v) \
+ std::atomic_fetch_sub(p, (v))
+#define atomic_load_relaxed(p) \
+ std::atomic_load_explicit(p, \
+ std::memory_order_relaxed)
+#define atomic_load_acquire(p) \
+ std::atomic_load_explicit(p, \
+ std::memory_order_acquire)
+#define atomic_store_release(p, v) \
+ std::atomic_store_explicit(p, (v), \
+ std::memory_order_release)
+#else
+#define atomic_add(p, v) \
+ atomic_fetch_add((_Atomic typeof(*(p)) *)(p), v)
+#define atomic_sub(p, v) \
+ atomic_fetch_sub((_Atomic typeof(*(p)) *)(p), v)
+#define atomic_load_relaxed(p) \
+ atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \
+ memory_order_relaxed)
+#define atomic_load_acquire(p) \
+ atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \
+ memory_order_acquire)
+#define atomic_store_release(p, v) \
+ atomic_store_explicit((_Atomic typeof(*(p)) *)(p), (v), \
+ memory_order_release)
+#endif
+
+/* IWYU pragma: begin_exports */
#if defined(__i386__)
#include "arch-x86.h"
#elif defined(__x86_64__)
#endif
#include "../lib/ffz.h"
+/* IWYU pragma: end_exports */
#ifndef ARCH_HAVE_INIT
static inline int arch_init(char *envp[])
}
#endif
+#ifdef __alpha__
+/*
+ * alpha is the only exception, all other architectures
+ * have common numbers for new system calls.
+ */
+# ifndef __NR_io_uring_setup
+# define __NR_io_uring_setup 535
+# endif
+# ifndef __NR_io_uring_enter
+# define __NR_io_uring_enter 536
+# endif
+# ifndef __NR_io_uring_register
+# define __NR_io_uring_register 537
+# endif
+#else /* !__alpha__ */
+# ifndef __NR_io_uring_setup
+# define __NR_io_uring_setup 425
+# endif
+# ifndef __NR_io_uring_enter
+# define __NR_io_uring_enter 426
+# endif
+# ifndef __NR_io_uring_register
+# define __NR_io_uring_register 427
+# endif
+#endif
+
+#define ARCH_HAVE_IOURING
+
#endif