patch-2.4.6 linux/include/asm-ppc/bitops.h
Next file: linux/include/asm-ppc/bootinfo.h
Previous file: linux/include/asm-parisc/termios.h
Back to the patch index
Back to the overall index
- Lines: 94
- Date:
Mon Jun 11 19:15:27 2001
- Orig file:
v2.4.5/linux/include/asm-ppc/bitops.h
- Orig date:
Mon May 21 15:02:06 2001
diff -u --recursive --new-file v2.4.5/linux/include/asm-ppc/bitops.h linux/include/asm-ppc/bitops.h
@@ -1,5 +1,5 @@
/*
- * BK Id: SCCS/s.bitops.h 1.7 05/17/01 18:14:24 cort
+ * BK Id: SCCS/s.bitops.h 1.9 05/26/01 14:48:14 paulus
*/
/*
* bitops.h: Bit string operations on the ppc
@@ -24,12 +24,9 @@
#define SMP_MB
#endif /* CONFIG_SMP */
-#define __INLINE_BITOPS 1
-
-#if __INLINE_BITOPS
/*
* These used to be if'd out here because using : "cc" as a constraint
- * resulted in errors from egcs. Things may be OK with gcc-2.95.
+ * resulted in errors from egcs. Things appear to be OK with gcc-2.95.
*/
static __inline__ void set_bit(int nr, volatile void * addr)
{
@@ -80,6 +77,17 @@
: "cc");
}
+/*
+ * non-atomic version
+ */
+static __inline__ void __clear_bit(int nr, volatile void *addr)
+{
+ unsigned long mask = 1 << (nr & 0x1f);
+ unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
+
+ *p &= ~mask;
+}
+
static __inline__ void change_bit(int nr, volatile void *addr)
{
unsigned long old;
@@ -97,6 +105,17 @@
}
/*
+ * non-atomic version
+ */
+static __inline__ void __change_bit(int nr, volatile void *addr)
+{
+ unsigned long mask = 1 << (nr & 0x1f);
+ unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
+
+ *p ^= mask;
+}
+
+/*
* test_and_*_bit do imply a memory barrier (?)
*/
static __inline__ int test_and_set_bit(int nr, volatile void *addr)
@@ -181,16 +200,19 @@
return (old & mask) != 0;
}
-#else /* __INLINE_BITOPS */
-extern void set_bit(int nr, volatile void *addr);
-extern void clear_bit(int nr, volatile void *addr);
-extern void change_bit(int nr, volatile void *addr);
-extern int test_and_set_bit(int nr, volatile void *addr);
-extern int test_and_clear_bit(int nr, volatile void *addr);
-extern int test_and_change_bit(int nr, volatile void *addr);
+/*
+ * non-atomic version
+ */
+static __inline__ int __test_and_change_bit(int nr, volatile void *addr)
+{
+ unsigned long mask = 1 << (nr & 0x1f);
+ unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
+ unsigned long old = *p;
-#endif /* __INLINE_BITOPS */
+ *p = old ^ mask;
+ return (old & mask) != 0;
+}
static __inline__ int test_bit(int nr, __const__ volatile void *addr)
{
@@ -283,8 +305,6 @@
return result + ffz(tmp);
}
-
-#define _EXT2_HAVE_ASM_BITOPS_
#ifdef __KERNEL__
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)