Whamcloud - gitweb
Branch b1_6
authorjohann <johann>
Thu, 6 Dec 2007 11:27:48 +0000 (11:27 +0000)
committerjohann <johann>
Thu, 6 Dec 2007 11:27:48 +0000 (11:27 +0000)
b=13843
i=adilger
i=nathan

Dynamically create DLM blocking callback threads
+ fix an issue with MacOS implementation of atomic_sub_and_test().

lnet/include/libcfs/darwin/darwin-types.h
lnet/include/libcfs/user-lock.h

index 805c3c8..3c24724 100644 (file)
@@ -64,6 +64,7 @@ typedef struct { volatile uint32_t counter; } atomic_t;
 #define atomic_read(a)                 ((a)->counter)
 #define atomic_set(a, v)               (((a)->counter) = (v))
 #ifdef __DARWIN8__
+/* OS*Atomic return the value before the operation */
 #define atomic_add(v, a)               OSAddAtomic(v, (SInt32 *)&((a)->counter))
 #define atomic_sub(v, a)               OSAddAtomic(-(v), (SInt32 *)&((a)->counter))
 #define atomic_inc(a)                  OSIncrementAtomic((SInt32 *)&((a)->counter))
@@ -74,8 +75,10 @@ typedef struct { volatile uint32_t counter; }        atomic_t;
 #define atomic_inc(a)                  atomic_add(1, a)
 #define atomic_dec(a)                  atomic_sub(1, a)
 #endif /* !__DARWIN8__ */
-#define atomic_sub_and_test(v, a)      ( atomic_sub(v, a) == -(a) )
-#define atomic_dec_and_test(a)         ( atomic_dec(a) == 1 )
+#define atomic_sub_and_test(v, a)       (atomic_sub(v, a) == (v))
+#define atomic_dec_and_test(a)          (atomic_dec(a) == 1)
+#define atomic_inc_return(a)            (atomic_inc(a) + 1)
+#define atomic_dec_return(a)            (atomic_dec(a) - 1)
 
 #include <libsa/mach/mach.h>
 typedef off_t                          loff_t;
index 97a5a16..6b46ce2 100644 (file)
@@ -187,6 +187,8 @@ typedef struct { volatile int counter; } atomic_t;
 #define atomic_inc(a)  (((a)->counter)++)
 #define atomic_dec(a)  do { (a)->counter--; } while (0)
 #define atomic_add(b,a)  do {(a)->counter += b;} while (0)
+#define atomic_add_return(n,a) ((a)->counter = n)
+#define atomic_inc_return(a) atomic_add_return(1,a)
 #define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
 
 #endif