patch-2.1.23 linux/include/asm-sparc/bitops.h

Next file: linux/include/asm-sparc/poll.h
Previous file: linux/include/asm-sparc/atomic.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.22/linux/include/asm-sparc/bitops.h linux/include/asm-sparc/bitops.h
@@ -1,4 +1,4 @@
-/* $Id: bitops.h,v 1.41 1996/12/28 18:14:25 davem Exp $
+/* $Id: bitops.h,v 1.43 1997/01/25 04:42:51 davem Exp $
  * bitops.h: Bit string operations on the Sparc.
  *
  * Copyright 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -97,110 +97,56 @@
 
 extern __inline__ unsigned long set_bit(unsigned long nr, __SMPVOL void *addr)
 {
-	int mask;
-	unsigned long *ADDR = (unsigned long *) addr;
+	register unsigned long mask asm("g2");
+	register unsigned long *ADDR asm("g1");
 
-	ADDR += nr >> 5;
+	ADDR = ((unsigned long *) addr) + (nr >> 5);
 	mask = 1 << (nr & 31);
 	__asm__ __volatile__("
-	rd	%%psr, %%g3
-	andcc	%%g3, %3, %%g0
-	bne	1f
-	 nop
-	wr	%%g3, %3, %%psr
-	nop
-	nop
-	nop
-1:
-	ld	[%0], %%g4
-	or	%%g4, %2, %%g2
-	andcc	%%g3, %3, %%g0
-	st	%%g2, [%0]
-	bne	1f
-	 nop
-	wr	%%g3, 0x0, %%psr
-	nop
-	nop
-	nop
-1:
-	and	%%g4, %2, %0
-"	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask), "i" (PSR_PIL)
-	: "g2", "g3", "g4");
+	mov	%%o7, %%g4
+	call	___set_bit
+	 add	%%o7, 8, %%o7
+"	: "=&r" (mask)
+	: "0" (mask), "r" (ADDR)
+	: "g3", "g4", "g5", "g7");
 
-	return (unsigned long) ADDR;
+	return mask;
 }
 
 extern __inline__ unsigned long clear_bit(unsigned long nr, __SMPVOL void *addr)
 {
-	int mask;
-	unsigned long *ADDR = (unsigned long *) addr;
+	register unsigned long mask asm("g2");
+	register unsigned long *ADDR asm("g1");
 
-	ADDR += nr >> 5;
+	ADDR = ((unsigned long *) addr) + (nr >> 5);
 	mask = 1 << (nr & 31);
 	__asm__ __volatile__("
-	rd	%%psr, %%g3
-	andcc	%%g3, %3, %%g0
-	bne	1f
-	 nop
-	wr	%%g3, %3, %%psr
-	nop
-	nop
-	nop
-1:
-	ld	[%0], %%g4
-	andn	%%g4, %2, %%g2
-	andcc	%%g3, %3, %%g0
-	st	%%g2, [%0]
-	bne	1f
-	 nop
-	wr	%%g3, 0x0, %%psr
-	nop
-	nop
-	nop
-1:
-	and	%%g4, %2, %0
-"	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask), "i" (PSR_PIL)
-	: "g2", "g3", "g4");
+	mov	%%o7, %%g4
+	call	___clear_bit
+	 add	%%o7, 8, %%o7
+"	: "=&r" (mask)
+	: "0" (mask), "r" (ADDR)
+	: "g3", "g4", "g5", "g7");
 
-	return (unsigned long) ADDR;
+	return mask;
 }
 
 extern __inline__ unsigned long change_bit(unsigned long nr, __SMPVOL void *addr)
 {
-	int mask;
-	unsigned long *ADDR = (unsigned long *) addr;
+	register unsigned long mask asm("g2");
+	register unsigned long *ADDR asm("g1");
 
-	ADDR += nr >> 5;
+	ADDR = ((unsigned long *) addr) + (nr >> 5);
 	mask = 1 << (nr & 31);
 	__asm__ __volatile__("
-	rd	%%psr, %%g3
-	andcc	%%g3, %3, %%g0
-	bne	1f
-	 nop
-	wr	%%g3, %3, %%psr
-	nop
-	nop
-	nop
-1:
-	ld	[%0], %%g4
-	xor	%%g4, %2, %%g2
-	andcc	%%g3, %3, %%g0
-	st	%%g2, [%0]
-	bne	1f
-	 nop
-	wr	%%g3, 0x0, %%psr
-	nop
-	nop
-	nop
-1:
-	and	%%g4, %2, %0
-"	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask), "i" (PSR_PIL)
-	: "g2", "g3", "g4");
+	mov	%%o7, %%g4
+	call	___change_bit
+	 add	%%o7, 8, %%o7
+"	: "=&r" (mask)
+	: "0" (mask), "r" (ADDR)
+	: "g3", "g4", "g5", "g7");
 
-	return (unsigned long) ADDR;
+	return mask;
 }
 
 #endif /* __KERNEL__ */
@@ -319,74 +265,38 @@
 
 extern __inline__ int set_le_bit(int nr,void * addr)
 {
-	int		mask;
-	unsigned char	*ADDR = (unsigned char *) addr;
+	register int mask asm("g2");
+	register unsigned char *ADDR asm("g1");
 
-	ADDR += nr >> 3;
+	ADDR = ((unsigned char *) addr) + (nr >> 3);
 	mask = 1 << (nr & 0x07);
 	__asm__ __volatile__("
-	rd	%%psr, %%g3
-	andcc	%%g3, %3, %%g0
-	bne	1f
-	 nop
-	wr	%%g3, %3, %%psr
-	nop
-	nop
-	nop
-1:
-	ldub	[%0], %%g4
-	or	%%g4, %2, %%g2
-	andcc	%%g3, %3, %%g0
-	stb	%%g2, [%0]
-	bne	1f
-	 nop
-	wr	%%g3, 0x0, %%psr
-	nop
-	nop
-	nop
-1:
-	and	%%g4, %2, %0
-"	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask), "i" (PSR_PIL)
-	: "g2", "g3", "g4");
+	mov	%%o7, %%g4
+	call	___set_le_bit
+	 add	%%o7, 8, %%o7
+"	: "=&r" (mask)
+	: "0" (mask), "r" (ADDR)
+	: "g3", "g4", "g5", "g7");
 
-	return (int) ADDR;
+	return mask;
 }
 
 extern __inline__ int clear_le_bit(int nr, void * addr)
 {
-	int		mask;
-	unsigned char	*ADDR = (unsigned char *) addr;
+	register int mask asm("g2");
+	register unsigned char *ADDR asm("g1");
 
-	ADDR += nr >> 3;
+	ADDR = ((unsigned char *) addr) + (nr >> 3);
 	mask = 1 << (nr & 0x07);
 	__asm__ __volatile__("
-	rd	%%psr, %%g3
-	andcc	%%g3, %3, %%g0
-	bne	1f
-	 nop
-	wr	%%g3, %3, %%psr
-	nop
-	nop
-	nop
-1:
-	ldub	[%0], %%g4
-	andn	%%g4, %2, %%g2
-	andcc	%%g3, %3, %%g0
-	stb	%%g2, [%0]
-	bne	1f
-	 nop
-	wr	%%g3, 0x0, %%psr
-	nop
-	nop
-	nop
-1:
-	and	%%g4, %2, %0
-"	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask), "i" (PSR_PIL)
-	: "g2", "g3", "g4");
+	mov	%%o7, %%g4
+	call	___clear_le_bit
+	 add	%%o7, 8, %%o7
+"	: "=&r" (mask)
+	: "0" (mask), "r" (ADDR)
+	: "g3", "g4", "g5", "g7");
 
-	return (int) ADDR;
+	return mask;
 }
 
 #endif /* __KERNEL__ */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov