patch-2.1.31 linux/include/asm-alpha/atomic.h
Next file: linux/include/asm-alpha/bitops.h
Previous file: linux/fs/super.c
Back to the patch index
Back to the overall index
- Lines: 146
- Date:
Fri Mar 28 10:52:25 1997
- Orig file:
v2.1.30/linux/include/asm-alpha/atomic.h
- Orig date:
Wed Sep 11 11:41:51 1996
diff -u --recursive --new-file v2.1.30/linux/include/asm-alpha/atomic.h linux/include/asm-alpha/atomic.h
@@ -1,14 +1,16 @@
-#ifndef __ARCH_ALPHA_ATOMIC__
-#define __ARCH_ALPHA_ATOMIC__
+#ifndef _ALPHA_ATOMIC_H
+#define _ALPHA_ATOMIC_H
/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc...
*
- * But use these as seldom as possible since they are much more slower
+ * But use these as seldom as possible since they are much slower
* than regular operations.
*/
+typedef int atomic_t;
+
/*
* Make sure gcc doesn't try to be clever and move things around
* on us. We need to use _exactly_ the address the user gave us,
@@ -16,38 +18,40 @@
*/
#define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
-typedef int atomic_t;
+/*
+ * To get proper branch prediction for the main line, we must branch
+ * forward to code at the end of this object's .text section, then
+ * branch back to restart the operation.
+ */
extern __inline__ void atomic_add(atomic_t i, atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
- "\n1:\t"
- "ldl_l %0,%1\n\t"
- "addl %0,%2,%0\n\t"
- "stl_c %0,%1\n\t"
- "beq %0,1b\n"
- "2:"
- :"=&r" (temp),
- "=m" (__atomic_fool_gcc(v))
- :"Ir" (i),
- "m" (__atomic_fool_gcc(v)));
+ "1: ldl_l %0,%1\n"
+ " addl %0,%2,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ ".text 2\n"
+ "2: br 1b\n"
+ ".text"
+ :"=&r" (temp), "=m" (__atomic_fool_gcc(v))
+ :"Ir" (i), "m" (__atomic_fool_gcc(v)));
}
extern __inline__ void atomic_sub(atomic_t i, atomic_t * v)
{
unsigned long temp;
__asm__ __volatile__(
- "\n1:\t"
- "ldl_l %0,%1\n\t"
- "subl %0,%2,%0\n\t"
- "stl_c %0,%1\n\t"
- "beq %0,1b\n"
- "2:"
- :"=&r" (temp),
- "=m" (__atomic_fool_gcc(v))
- :"Ir" (i),
- "m" (__atomic_fool_gcc(v)));
+ "1: ldl_l %0,%1\n"
+ " subl %0,%2,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ ".text 2\n"
+ "2: br 1b\n"
+ ".text"
+ :"=&r" (temp), "=m" (__atomic_fool_gcc(v))
+ :"Ir" (i), "m" (__atomic_fool_gcc(v)));
}
/*
@@ -57,18 +61,16 @@
{
long temp, result;
__asm__ __volatile__(
- "\n1:\t"
- "ldl_l %0,%1\n\t"
- "addl %0,%3,%0\n\t"
- "bis %0,%0,%2\n\t"
- "stl_c %0,%1\n\t"
- "beq %0,1b\n"
- "2:"
- :"=&r" (temp),
- "=m" (__atomic_fool_gcc(v)),
- "=&r" (result)
- :"Ir" (i),
- "m" (__atomic_fool_gcc(v)));
+ "1: ldl_l %0,%1\n"
+ " addl %0,%3,%0\n"
+ " mov %0,%2\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ ".text 2\n"
+ "2: br 1b\n"
+ ".text"
+ :"=&r" (temp), "=m" (__atomic_fool_gcc(v)), "=&r" (result)
+ :"Ir" (i), "m" (__atomic_fool_gcc(v)));
return result;
}
@@ -76,18 +78,16 @@
{
long temp, result;
__asm__ __volatile__(
- "\n1:\t"
- "ldl_l %0,%1\n\t"
- "subl %0,%3,%0\n\t"
- "bis %0,%0,%2\n\t"
- "stl_c %0,%1\n\t"
- "beq %0,1b\n"
- "2:"
- :"=&r" (temp),
- "=m" (__atomic_fool_gcc(v)),
- "=&r" (result)
- :"Ir" (i),
- "m" (__atomic_fool_gcc(v)));
+ "1: ldl_l %0,%1\n"
+ " subl %0,%3,%0\n"
+ " mov %0,%2\n"
+ " stl_c %0,%1\n"
+ " beq %0,2f\n"
+ ".text 2\n"
+ "2: br 1b\n"
+ ".text"
+ :"=&r" (temp), "=m" (__atomic_fool_gcc(v)), "=&r" (result)
+ :"Ir" (i), "m" (__atomic_fool_gcc(v)));
return result;
}
@@ -100,4 +100,4 @@
#define atomic_inc(v) atomic_add(1,(v))
#define atomic_dec(v) atomic_sub(1,(v))
-#endif
+#endif /* _ALPHA_ATOMIC_H */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov