Skip to contentSkip to conversation

added missing functions to include/asm-arm/atomic.h

PATCH New Bart Trojanowski 1 participant 1 message Apr 22, 2003 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 added missing functions to include/asm-arm/atomic.h

While porting a piece of code from i386 to arm, I've noticed that two atomic operations are missing from the asm-arm/atomic.h interface.

The patch below adds these two missing functions with an aim of filling in the compatibility hole.

Regards,
Bart.

include/asm-arm/atomic.h renamed from include/asm-arm/atomic.h.orig +26 -0
@@ -68,6 +68,32 @@
 	__restore_flags(flags);
 }
 
+static __inline__ int atomic_sub_and_test(int i, volatile atomic_t *v)
+{
+	unsigned long flags;
+	int result;
+
+	__save_flags_cli(flags);
+	v->counter -= i;
+	result = (v->counter == 0);
+	__restore_flags(flags);
+
+	return result;
+}
+
+static __inline__ int atomic_inc_and_test(volatile atomic_t *v)
+{
+	unsigned long flags;
+	int result;
+
+	__save_flags_cli(flags);
+	v->counter += 1;
+	result = (v->counter == 0);
+	__restore_flags(flags);
+
+	return result;
+}
+
 static __inline__ int atomic_dec_and_test(volatile atomic_t *v)
 {
 	unsigned long flags;