gfio: don't have multiple versions of main_ui
[fio.git] / arch / arch-x86_64.h
CommitLineData
a4e1a86a
TK
1#ifndef ARCH_X86_64_H
2#define ARCH_X86_64_H
ebac4655 3
6b13c710
JA
4static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
5 unsigned int *ecx, unsigned int *edx)
6{
7 asm volatile("cpuid"
8afbf874 8 : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
6b13c710
JA
9 : "0" (*eax), "2" (*ecx)
10 : "memory");
11}
12
c473a9bd 13#include "arch-x86-common.h" /* IWYU pragma: export */
fa80feae 14
cca84643 15#define FIO_ARCH (arch_x86_64)
ebac4655 16
cb25df61
JA
17#define FIO_HUGE_PAGE 2097152
18
db6defc7 19#define nop __asm__ __volatile__("rep;nop": : :"memory")
8287fee8
JA
20#define read_barrier() __asm__ __volatile__("":::"memory")
21#define write_barrier() __asm__ __volatile__("":::"memory")
ebac4655 22
0ce8b119 23static inline unsigned long arch_ffz(unsigned long bitmask)
8f7e39dd 24{
0ce8b119 25 __asm__("bsf %1,%0" :"=r" (bitmask) :"r" (~bitmask));
8f7e39dd
JA
26 return bitmask;
27}
c223da83
JA
28
29static inline unsigned long long get_cpu_clock(void)
30{
31 unsigned int lo, hi;
32
33 __asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi));
34 return ((unsigned long long) hi << 32ULL) | lo;
35}
36
21df44a2 37#define ARCH_HAVE_FFZ
2f68124f 38#define ARCH_HAVE_SSE4_2
c223da83 39#define ARCH_HAVE_CPU_CLOCK
8f7e39dd 40
16dc0710
JA
41#define RDRAND_LONG ".byte 0x48,0x0f,0xc7,0xf0"
42#define RDSEED_LONG ".byte 0x48,0x0f,0xc7,0xf8"
43#define RDRAND_RETRY 100
44
45static inline int arch_rand_long(unsigned long *val)
46{
47 int ok;
48
49 asm volatile("1: " RDRAND_LONG "\n\t"
50 "jc 2f\n\t"
51 "decl %0\n\t"
52 "jnz 1b\n\t"
53 "2:"
54 : "=r" (ok), "=a" (*val)
55 : "0" (RDRAND_RETRY));
56
57 return ok;
58}
59
60static inline int arch_rand_seed(unsigned long *seed)
61{
62 unsigned char ok;
63
64 asm volatile(RDSEED_LONG "\n\t"
65 "setc %0"
66 : "=qm" (ok), "=a" (*seed));
67
68 return 0;
69}
70
ebac4655 71#endif