aarch64: add system call definitions
[fio.git] / arch / arch.h
... / ...
CommitLineData
1#ifndef ARCH_H
2#define ARCH_H
3
4#ifdef __cplusplus
5#include <atomic>
6#else
7#include <stdatomic.h>
8#endif
9
10#include "../lib/types.h"
11
12enum {
13 arch_x86_64 = 1,
14 arch_x86,
15 arch_ppc,
16 arch_ia64,
17 arch_s390,
18 arch_alpha,
19 arch_sparc,
20 arch_sparc64,
21 arch_arm,
22 arch_sh,
23 arch_hppa,
24 arch_mips,
25 arch_aarch64,
26
27 arch_generic,
28
29 arch_nr,
30};
31
32enum {
33 ARCH_FLAG_1 = 1 << 0,
34 ARCH_FLAG_2 = 1 << 1,
35 ARCH_FLAG_3 = 1 << 2,
36 ARCH_FLAG_4 = 1 << 3,
37};
38
39extern unsigned long arch_flags;
40
41#define ARCH_CPU_CLOCK_WRAPS
42
43#ifdef __cplusplus
44#define atomic_add(p, v) \
45 std::atomic_fetch_add(p, (v))
46#define atomic_sub(p, v) \
47 std::atomic_fetch_sub(p, (v))
48#define atomic_load_relaxed(p) \
49 std::atomic_load_explicit(p, \
50 std::memory_order_relaxed)
51#define atomic_load_acquire(p) \
52 std::atomic_load_explicit(p, \
53 std::memory_order_acquire)
54#define atomic_store_release(p, v) \
55 std::atomic_store_explicit(p, (v), \
56 std::memory_order_release)
57#else
58#define atomic_add(p, v) \
59 atomic_fetch_add((_Atomic typeof(*(p)) *)(p), v)
60#define atomic_sub(p, v) \
61 atomic_fetch_sub((_Atomic typeof(*(p)) *)(p), v)
62#define atomic_load_relaxed(p) \
63 atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \
64 memory_order_relaxed)
65#define atomic_load_acquire(p) \
66 atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \
67 memory_order_acquire)
68#define atomic_store_release(p, v) \
69 atomic_store_explicit((_Atomic typeof(*(p)) *)(p), (v), \
70 memory_order_release)
71#endif
72
73/* IWYU pragma: begin_exports */
74#if defined(__i386__)
75#include "arch-x86.h"
76#elif defined(__x86_64__)
77#include "arch-x86_64.h"
78#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__)
79#include "arch-ppc.h"
80#elif defined(__ia64__)
81#include "arch-ia64.h"
82#elif defined(__alpha__)
83#include "arch-alpha.h"
84#elif defined(__s390x__) || defined(__s390__)
85#include "arch-s390.h"
86#elif defined(__sparc__)
87#include "arch-sparc.h"
88#elif defined(__sparc64__)
89#include "arch-sparc64.h"
90#elif defined(__arm__)
91#include "arch-arm.h"
92#elif defined(__mips__) || defined(__mips64__)
93#include "arch-mips.h"
94#elif defined(__sh__)
95#include "arch-sh.h"
96#elif defined(__hppa__)
97#include "arch-hppa.h"
98#elif defined(__aarch64__)
99#include "arch-aarch64.h"
100#else
101#warning "Unknown architecture, attempting to use generic model."
102#include "arch-generic.h"
103#endif
104
105#include "../lib/ffz.h"
106/* IWYU pragma: end_exports */
107
108#ifndef ARCH_HAVE_INIT
109static inline int arch_init(char *envp[])
110{
111 return 0;
112}
113#endif
114
115#ifdef __alpha__
116/*
117 * alpha is the only exception, all other architectures
118 * have common numbers for new system calls.
119 */
120# ifndef __NR_io_uring_setup
121# define __NR_io_uring_setup 535
122# endif
123# ifndef __NR_io_uring_enter
124# define __NR_io_uring_enter 536
125# endif
126# ifndef __NR_io_uring_register
127# define __NR_io_uring_register 537
128# endif
129#else /* !__alpha__ */
130# ifndef __NR_io_uring_setup
131# define __NR_io_uring_setup 425
132# endif
133# ifndef __NR_io_uring_enter
134# define __NR_io_uring_enter 426
135# endif
136# ifndef __NR_io_uring_register
137# define __NR_io_uring_register 427
138# endif
139#endif
140
141#define ARCH_HAVE_IOURING
142
143#endif