[vlc-commits] Add helpers to store floats into vlc_atomic_t

Rémi Denis-Courmont git at videolan.org
Tue Aug 9 18:02:35 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug  9 18:48:13 2011 +0300| [1252a5ebffca99690899c53234e8bd92215dcc8f] | committer: Rémi Denis-Courmont

Add helpers to store floats into vlc_atomic_t

(Lets assume that uintptr_t is big enough, i.e. 32-bits).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1252a5ebffca99690899c53234e8bd92215dcc8f
---

 include/vlc_atomic.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/vlc_atomic.h b/include/vlc_atomic.h
index 39d02b4..d21c8ad 100644
--- a/include/vlc_atomic.h
+++ b/include/vlc_atomic.h
@@ -53,4 +53,21 @@ static inline uintptr_t vlc_atomic_dec (vlc_atomic_t *atom)
 VLC_API uintptr_t vlc_atomic_swap(vlc_atomic_t *, uintptr_t);
 VLC_API uintptr_t vlc_atomic_compare_swap(vlc_atomic_t *, uintptr_t, uintptr_t);
 
+/** Helper to retrieve a single precision from an atom. */
+static inline float vlc_atomic_getf(const vlc_atomic_t *atom)
+{
+    union { float f; uintptr_t i; } u;
+    u.i = vlc_atomic_get(atom);
+    return u.f;
+}
+
+/** Helper to store a single precision into an atom. */
+static inline float vlc_atomic_setf(vlc_atomic_t *atom, float f)
+{
+    union { float f; uintptr_t i; } u;
+    u.f = f;
+    vlc_atomic_set(atom, u.i);
+    return f;
+}
+
 #endif



More information about the vlc-commits mailing list