Merge branch 'patch-1' of https://github.com/sweettea/fio
[fio.git] / arch / arch.h
CommitLineData
ebac4655
JA
1#ifndef ARCH_H
2#define ARCH_H
3
33ab6905
KC
4#ifdef __cplusplus
5#include <atomic>
6#else
3932f8be 7#include <stdatomic.h>
33ab6905 8#endif
3932f8be 9
24575392
JA
10#include "../lib/types.h"
11
ebac4655 12enum {
cca84643 13 arch_x86_64 = 1,
e12f4ede 14 arch_x86,
ebac4655
JA
15 arch_ppc,
16 arch_ia64,
17 arch_s390,
18 arch_alpha,
697a606c
JA
19 arch_sparc,
20 arch_sparc64,
a1ea676e 21 arch_arm,
29721c9c 22 arch_sh,
85a86319 23 arch_hppa,
5499f7ff 24 arch_mips,
78c8831e 25 arch_aarch64,
fa77073a
JA
26
27 arch_generic,
cca84643
JA
28
29 arch_nr,
ebac4655
JA
30};
31
5f739e0e
NI
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
4247d1a9
JA
39extern unsigned long arch_flags;
40
96170421
CE
41#define ARCH_CPU_CLOCK_WRAPS
42
33ab6905
KC
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
d4e74fda
DB
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)
3932f8be
BVA
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)
33ab6905 71#endif
3932f8be 72
c473a9bd 73/* IWYU pragma: begin_exports */
ebac4655
JA
74#if defined(__i386__)
75#include "arch-x86.h"
76#elif defined(__x86_64__)
77#include "arch-x86_64.h"
2afd826b 78#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__)
ebac4655
JA
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"
697a606c
JA
86#elif defined(__sparc__)
87#include "arch-sparc.h"
88#elif defined(__sparc64__)
89#include "arch-sparc64.h"
a1ea676e
KS
90#elif defined(__arm__)
91#include "arch-arm.h"
c28b912f
JA
92#elif defined(__mips__) || defined(__mips64__)
93#include "arch-mips.h"
29721c9c
NI
94#elif defined(__sh__)
95#include "arch-sh.h"
85a86319
JA
96#elif defined(__hppa__)
97#include "arch-hppa.h"
78c8831e
DK
98#elif defined(__aarch64__)
99#include "arch-aarch64.h"
ebac4655 100#else
fa77073a
JA
101#warning "Unknown architecture, attempting to use generic model."
102#include "arch-generic.h"
ebac4655
JA
103#endif
104
8f7e39dd 105#include "../lib/ffz.h"
c473a9bd 106/* IWYU pragma: end_exports */
8f7e39dd 107
d3cc4ebf
JA
108#ifndef ARCH_HAVE_INIT
109static inline int arch_init(char *envp[])
110{
111 return 0;
112}
113#endif
114
bfed648c
JA
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
ebac4655 143#endif