[parisc-linux-cvs] implement __change_bit()

Paul Bame bame@fc.hp.com
Thu, 05 Jul 2001 20:11:42 -0600


Index: bitops.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/bitops.h,v
retrieving revision 1.11
diff -u -r1.11 bitops.h
--- bitops.h	2001/06/10 16:11:33	1.11
+++ bitops.h	2001/07/06 02:10:07
@@ -77,6 +77,26 @@
 	return oldbit;
 }
 
+/**
+ * __change_bit - Toggle a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ *
+ * Unlike change_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static __inline__ void __change_bit(int nr, void * address)
+{
+	unsigned long mask;
+	unsigned long *addr = (unsigned long *) address;
+
+	addr += (nr >> SHIFT_PER_LONG);
+
+	mask = 1L << CHOP_SHIFTCOUNT(nr);
+	*addr ^= mask;
+}
+
 /* again, the read-only case doesn't have to do any locking */
 
 static __inline__ int test_bit(int nr, const volatile void *address)