diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-07-02 20:23:07 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-07-02 20:25:47 +0300 |
commit | 23b95bf1a15322c2f471b80c06cb65d9b2d2a282 (patch) | |
tree | 9bf12231db9591852e3b42ca24715d2cbaf6267b /include/libtf/atomic.h | |
parent | 0183e33d9a4759764716e771b85e19f7a997b8bd (diff) | |
download | libtf-23b95bf1a15322c2f471b80c06cb65d9b2d2a282.tar.bz2 libtf-23b95bf1a15322c2f471b80c06cb65d9b2d2a282.tar.xz |
the idea is to make libtf completely multi-threaded. meaning each
fiber can be running concurrently in separate thread. quite a bit
of framework is added for this and some atomic helpers are already
introduced. however, io polling is busy polling now (will be soon
in own thread) and timeouts are still more or less broken. oh, and
the multithreading core is not there yet. basically we are currently
mostly broken ;)
Diffstat (limited to 'include/libtf/atomic.h')
-rw-r--r-- | include/libtf/atomic.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/libtf/atomic.h b/include/libtf/atomic.h index ec9f1e0..8ebe5f8 100644 --- a/include/libtf/atomic.h +++ b/include/libtf/atomic.h @@ -13,7 +13,14 @@ #ifndef TF_ATOMIC_H #define TF_ATOMIC_H -#define tf_atomic_inc(var) __sync_add_and_fetch(&(var), 1) -#define tf_atomic_dec(var) __sync_add_and_fetch(&(var), -1) +#define tf_atomic_inc(var) \ + __sync_add_and_fetch(&(var), 1) +#define tf_atomic_dec(var) \ + __sync_add_and_fetch(&(var), -1) + +#define tf_atomic_cmpxchg(ptr, old, new) \ + __sync_bool_compare_and_swap(ptr, old, new) +#define tf_atomic_xchg(ptr, new) \ + ((typeof(*(ptr)))__sync_lock_test_and_set(ptr, new)) #endif |