From: Brian Norris Date: Sat, 10 Mar 2012 03:00:50 +0000 (-0800) Subject: libatomic: add stub atomic lib header/source X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=060e439b9c99f4fd89060acd44913b103d983b45;hp=8eb5e06138387756462affc3d7a327d9f0cd20d3 libatomic: add stub atomic lib header/source Stub implementations, for testing. (Temporary: need to find a better generic atomic_int, atomic_long, etc. implementation) --- diff --git a/Makefile b/Makefile index 139e9540..073121e8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=gcc BIN=libthreads -SOURCE=libthreads.c schedule.c -HEADERS=libthreads.h schedule.h common.h +SOURCE=libthreads.c schedule.c libatomic.c +HEADERS=libthreads.h schedule.h common.h libatomic.h FLAGS=-Wall all: ${BIN} diff --git a/libatomic.c b/libatomic.c new file mode 100644 index 00000000..a00838e9 --- /dev/null +++ b/libatomic.c @@ -0,0 +1,13 @@ +#include "libatomic.h" +#include "libthreads.h" + +void atomic_store_explicit(struct atomic_object *obj, int value, memory_order order) +{ + thread_yield(); +} + +int atomic_load_explicit(struct atomic_object *obj, memory_order order) +{ + thread_yield(); + return 0; +} diff --git a/libatomic.h b/libatomic.h new file mode 100644 index 00000000..f861445c --- /dev/null +++ b/libatomic.h @@ -0,0 +1,22 @@ +#ifndef __LIBATOMIC_H__ +#define __LIBATOMIC_H__ + +typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst +} memory_order; + +typedef struct atomic_object { +} atomic_int; + +void atomic_store_explicit(struct atomic_object *obj, int value, memory_order order); +#define atomic_store(A, B) atomic_store_explicit((A), (B), memory_order_seq_cst) + +int atomic_load_explicit(struct atomic_object *obj, memory_order order); +#define atomic_load(A) atomic_load_explicit((A), memory_order_seq_cst) + +#endif /* __LIBATOMIC_H__ */