diff options
author | David Robillard <d@drobilla.net> | 2008-11-16 20:42:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-11-16 20:42:11 +0000 |
commit | 4f43c8357f109ab8f7b0886a41ae11ac4d07a830 (patch) | |
tree | 53a09a703e80ef7f6707354208b74673219adeaf | |
parent | dfd472bbedf71c41dbb464aa60b35d1712cbd7ad (diff) | |
download | raul-4f43c8357f109ab8f7b0886a41ae11ac4d07a830.tar.gz raul-4f43c8357f109ab8f7b0886a41ae11ac4d07a830.tar.bz2 raul-4f43c8357f109ab8f7b0886a41ae11ac4d07a830.zip |
Cast glib operations to compile on annoying platforms.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@1732 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | raul/AtomicInt.hpp | 28 | ||||
-rw-r--r-- | raul/AtomicPtr.hpp | 13 |
2 files changed, 21 insertions, 20 deletions
diff --git a/raul/AtomicInt.hpp b/raul/AtomicInt.hpp index cb0591d..a07ec3c 100644 --- a/raul/AtomicInt.hpp +++ b/raul/AtomicInt.hpp @@ -27,22 +27,22 @@ class AtomicInt { public: inline AtomicInt(int val) - { g_atomic_int_set(&_val, val); } + { g_atomic_int_set(static_cast<volatile gint*>(&_val), (gint)val); } inline AtomicInt(const AtomicInt& copy) - { g_atomic_int_set(&_val, copy.get()); } + { g_atomic_int_set(static_cast<volatile gint*>(&_val), (gint)copy.get()); } inline int get() const - { return g_atomic_int_get(&_val); } + { return g_atomic_int_get(static_cast<volatile gint*>(&_val)); } inline void operator=(int val) - { g_atomic_int_set(&_val, val); } + { g_atomic_int_set(static_cast<volatile gint*>(&_val), (gint)val); } inline void operator+=(int val) - { g_atomic_int_add(&_val, val); } + { g_atomic_int_add(static_cast<volatile gint*>(&_val), (gint)val); } inline void operator-=(int val) - { g_atomic_int_add(&_val, -val); } + { g_atomic_int_add(static_cast<volatile gint*>(&_val), (gint)-val); } inline bool operator==(int val) const { return get() == val; } @@ -51,28 +51,28 @@ public: { return get() + val; } inline AtomicInt& operator++() // prefix - { g_atomic_int_inc(&_val); return *this; } + { g_atomic_int_inc(static_cast<volatile gint*>(&_val)); return *this; } inline AtomicInt& operator--() // prefix - { g_atomic_int_add(&_val, -1); return *this; } + { g_atomic_int_add(static_cast<volatile gint*>(&_val), -1); return *this; } - /** Set value to newval iff current value is oldval. - * @return whether set succeeded. + /** Set value to @a val iff current value is @a old. + * @return true iff set succeeded. */ - inline bool compare_and_exchange(int oldval, int newval) - { return g_atomic_int_compare_and_exchange(&_val, oldval, newval); } + inline bool compare_and_exchange(int old, int val) + { return g_atomic_int_compare_and_exchange(static_cast<volatile gint*>(&_val), old, val); } /** Add val to value. * @return value immediately before addition took place. */ inline int exchange_and_add(int val) - { return g_atomic_int_exchange_and_add(&_val, val); } + { return g_atomic_int_exchange_and_add(static_cast<volatile gint*>(&_val), val); } /** Decrement value. * @return true if value is now 0, otherwise false. */ inline bool decrement_and_test() - { return g_atomic_int_dec_and_test(&_val); } + { return g_atomic_int_dec_and_test(static_cast<volatile gint*>(&_val)); } private: volatile mutable int _val; diff --git a/raul/AtomicPtr.hpp b/raul/AtomicPtr.hpp index 365b25d..ae51cf0 100644 --- a/raul/AtomicPtr.hpp +++ b/raul/AtomicPtr.hpp @@ -28,23 +28,24 @@ class AtomicPtr { public: inline AtomicPtr() - { g_atomic_pointer_set(&_val, NULL); } + { g_atomic_pointer_set((volatile gpointer*)&_val, NULL); } inline AtomicPtr(const AtomicPtr& copy) - { g_atomic_pointer_set(&_val, copy.get()); } + { g_atomic_pointer_set((volatile gpointer*)(&_val), (gpointer)copy.get()); } inline T* get() const - { return (T*)g_atomic_pointer_get(&_val); } + { return (T*)g_atomic_pointer_get((volatile gpointer*)(&_val)); } inline void operator=(T* val) - { g_atomic_pointer_set(&_val, val); } + { g_atomic_pointer_set((volatile gpointer*)(&_val), (gpointer)val); } /** Set value to newval iff current value is oldval */ inline bool compare_and_exchange(int oldval, int newval) - { return g_atomic_pointer_compare_and_exchange(&_val, oldval, newval); } + { return g_atomic_pointer_compare_and_exchange((volatile gpointer*)(&_val), oldval, newval); } private: - mutable T volatile* _val; + //mutable T* volatile _val; + mutable T* volatile _val; }; |