patch-2.4.6 linux/include/asm-sparc64/bitops.h
Next file: linux/include/asm-sparc64/hardirq.h
Previous file: linux/include/asm-sparc64/auxio.h
Back to the patch index
Back to the overall index
- Lines: 60
- Date:
Wed Jun 20 21:00:55 2001
- Orig file:
v2.4.5/linux/include/asm-sparc64/bitops.h
- Orig date:
Thu Apr 26 22:17:26 2001
diff -u --recursive --new-file v2.4.5/linux/include/asm-sparc64/bitops.h linux/include/asm-sparc64/bitops.h
@@ -1,4 +1,4 @@
-/* $Id: bitops.h,v 1.33 2001/04/24 01:09:12 davem Exp $
+/* $Id: bitops.h,v 1.36 2001/06/14 12:34:49 davem Exp $
* bitops.h: Bit string operations on the V9.
*
* Copyright 1996, 1997 David S. Miller (davem@caip.rutgers.edu)
@@ -20,13 +20,46 @@
#define clear_bit(nr,addr) ((void)___test_and_clear_bit(nr,addr))
#define change_bit(nr,addr) ((void)___test_and_change_bit(nr,addr))
-/* "non-atomic" versions, nothing special for now... */
-#define __set_bit(X,Y) set_bit(X,Y)
-#define __clear_bit(X,Y) clear_bit(X,Y)
-#define __change_bit(X,Y) change_bit(X,Y)
-#define __test_and_set_bit(X,Y) test_and_set_bit(X,Y)
-#define __test_and_clear_bit(X,Y) test_and_clear_bit(X,Y)
-#define __test_and_change_bit(X,Y) test_and_change_bit(X,Y)
+/* "non-atomic" versions... */
+#define __set_bit(X,Y) \
+do { unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ *__m |= (1UL << (__nr & 63)); \
+} while (0)
+#define __clear_bit(X,Y) \
+do { unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ *__m &= ~(1UL << (__nr & 63)); \
+} while (0)
+#define __change_bit(X,Y) \
+do { unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ *__m ^= (1UL << (__nr & 63)); \
+} while (0)
+#define __test_and_set_bit(X,Y) \
+({ unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ long __old = *__m; \
+ long __mask = (1UL << (__nr & 63)); \
+ *__m = (__old | __mask); \
+ ((__old & __mask) != 0); \
+})
+#define __test_and_clear_bit(X,Y) \
+({ unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ long __old = *__m; \
+ long __mask = (1UL << (__nr & 63)); \
+ *__m = (__old & ~__mask); \
+ ((__old & __mask) != 0); \
+})
+#define __test_and_change_bit(X,Y) \
+({ unsigned long __nr = (X); \
+ long *__m = ((long *) (Y)) + (__nr >> 6); \
+ long __old = *__m; \
+ long __mask = (1UL << (__nr & 63)); \
+ *__m = (__old ^ __mask); \
+ ((__old & __mask) != 0); \
+})
#define smp_mb__before_clear_bit() do { } while(0)
#define smp_mb__after_clear_bit() do { } while(0)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)