Revert "Remove unused define"
[fio.git] / arch / arch-x86.h
index 4d7ea49dd1cdde71d004050875a95dc9c4c3ea80..b9249eae6f449d4f04e6fc2e6f25873eb9763527 100644 (file)
 #define FIO_HAVE_SYSLET
 
 #define nop            __asm__ __volatile__("rep;nop": : :"memory")
-#define read_barrier() asm volatile ("": : :"memory")
+#define read_barrier() __asm__ __volatile__("": : :"memory")
+#define write_barrier()        __asm__ __volatile__("": : :"memory")
+
+static inline unsigned long arch_ffz(unsigned long bitmask)
+{
+       __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask));
+       return bitmask;
+}
+#define ARCH_HAVE_FFZ
+
+typedef struct {
+       unsigned int lock;
+} spinlock_t;
+
+static inline void spin_lock(spinlock_t *lock)
+{
+       short inc = 0x0100;
+
+       __asm__ __volatile__("xaddw %w0, %1\n"
+                       "1:\t"
+                       "cmpb %h0, %b0\n\t"
+                       "je 2f\n\t"
+                       "rep ; nop\n\t"
+                       "movb %1, %b0\n\t"
+                       "jmp 1b\n"
+                       "2:"
+                       : "+Q" (inc), "+m" (lock->lock)
+                       :
+                       : "memory", "cc");
+}
+
+static inline void spin_unlock(spinlock_t *lock)
+{
+       __asm__ __volatile__("incb %0"
+                       : "+m" (lock->lock)
+                       :
+                       : "memory", "cc");
+}
+
+#define __SPIN_LOCK_UNLOCKED   { 0 }
 
 #endif