Fix issue with termination before io_size has been reached
[fio.git] / arch / arch-x86_64.h
index 8bdf01e84dd2a3558c3f2eee6a98f2d17176750c..8f33fc541ee6f266e96f9f507ccc3782d618392c 100644 (file)
@@ -5,7 +5,7 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
                            unsigned int *ecx, unsigned int *edx)
 {
        asm volatile("cpuid"
-               : "=a" (*eax), "=b" (*ebx), "=r" (*ecx), "=d" (*edx)
+               : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
                : "0" (*eax), "2" (*ecx)
                : "memory");
 }
@@ -29,6 +29,13 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
 #define __NR_sys_vmsplice      278
 #endif
 
+#ifndef __NR_shmget
+#define __NR_shmget             29
+#define __NR_shmat              30
+#define __NR_shmctl             31
+#define __NR_shmdt              67
+#endif
+
 #define        FIO_HUGE_PAGE           2097152
 
 #define nop            __asm__ __volatile__("rep;nop": : :"memory")
@@ -53,4 +60,34 @@ static inline unsigned long long get_cpu_clock(void)
 #define ARCH_HAVE_SSE4_2
 #define ARCH_HAVE_CPU_CLOCK
 
+#define RDRAND_LONG    ".byte 0x48,0x0f,0xc7,0xf0"
+#define RDSEED_LONG    ".byte 0x48,0x0f,0xc7,0xf8"
+#define RDRAND_RETRY   100
+
+static inline int arch_rand_long(unsigned long *val)
+{
+       int ok;
+
+       asm volatile("1: " RDRAND_LONG "\n\t"
+                    "jc 2f\n\t"
+                    "decl %0\n\t"
+                    "jnz 1b\n\t"
+                    "2:"
+                    : "=r" (ok), "=a" (*val)
+                    : "0" (RDRAND_RETRY));
+
+       return ok;
+}
+
+static inline int arch_rand_seed(unsigned long *seed)
+{
+       unsigned char ok;
+
+       asm volatile(RDSEED_LONG "\n\t"
+                       "setc %0"
+                       : "=qm" (ok), "=a" (*seed));
+
+       return 0;
+}
+
 #endif