Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
/* atomic_add */
static inline __attribute__((always_inline))
-unsigned long _atomic_add(volatile void *addr, unsigned long val, int len)
+void _atomic_add(volatile void *addr, unsigned long val, int len)
{
switch (len) {
case 1:
/* generate an illegal instruction. Cannot catch this with linker tricks
* when optimizations are disabled. */
__asm__ __volatile__("ud2");
- return 0;
+ return;
}
#define atomic_add(addr, v) \
urcutorture-yield: urcutorture.c ${URCU_SIGNAL_YIELD} rcutorture.h api.h
$(CC) -DDEBUG_YIELD ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP)
+test_atomic: test_atomic.c ../arch_atomic.h
+ $(CC) ${CFLAGS} $(LDFLAGS) -o $@ $(SRC_DEP)
+
,PHONY: clean
clean:
--- /dev/null
+#include <stdio.h>
+#include <arch_atomic.h>
+#include <assert.h>
+
+struct testvals {
+ unsigned char c;
+ unsigned short s;
+ unsigned int i;
+ unsigned long l;
+};
+
+static struct testvals vals;
+
+int main(int argc, void **argv)
+{
+ atomic_add(&vals.c, 10);
+ assert(vals.c == 10);
+ atomic_add(&vals.c, -11);
+ assert((char)vals.c == -1);
+}