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