patch-1.3.93 linux/include/asm-sparc/atomic.h

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

diff -u --recursive --new-file v1.3.92/linux/include/asm-sparc/atomic.h linux/include/asm-sparc/atomic.h
@@ -0,0 +1,60 @@
+/* atomic.h: These really suck for now.
+ *
+ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
+ */
+
+#ifndef __ARCH_SPARC_ATOMIC__
+#define __ARCH_SPARC_ATOMIC__
+
+#ifdef __SMP__
+#include <asm/smp.h>
+#include <asm/smp_lock.h>
+#endif
+
+typedef int atomic_t;
+
+static __inline__ void atomic_add(atomic_t i, atomic_t *v)
+{
+	unsigned long flags;
+
+	save_flags(flags); cli();
+	*v += i;
+	restore_flags(flags);
+}
+
+static __inline__ void atomic_sub(atomic_t i, atomic_t *v)
+{
+	unsigned long flags;
+
+	save_flags(flags); cli();
+	*v -= i;
+	restore_flags(flags);
+}
+
+static __inline__ int atomic_sub_and_test(atomic_t i, atomic_t *v)
+{
+	unsigned long flags, result;
+
+	save_flags(flags); cli();
+	*v -= i;
+	result = (*v == 0);
+	restore_flags(flags);
+	return result;
+}
+
+static __inline__ void atomic_inc(atomic_t *v)
+{
+	atomic_add(1, v);
+}
+
+static __inline__ void atomic_dec(atomic_t *v)
+{
+	atomic_sub(1, v);
+}
+
+static __inline__ int atomic_dec_and_test(atomic_t *v)
+{
+	return atomic_sub_and_test(1, v);
+}
+
+#endif /* !(__ARCH_SPARC_ATOMIC__) */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this