[vlc-commits] thread: rectify atomic_uint-related assertions

Rémi Denis-Courmont git at videolan.org
Mon Feb 17 17:54:58 CET 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 16 22:29:39 2020 +0200| [a39025caa44cc5465d13b5f3093e5a1b451c3226] | committer: Rémi Denis-Courmont

thread: rectify atomic_uint-related assertions

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

 src/misc/threads.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index 82bd5b60fc..8f365efad8 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -30,6 +30,14 @@
 #include <vlc_common.h>
 #include "libvlc.h"
 
+/* <stdatomic.h> types cannot be used in the C++ view of <vlc_threads.h> */
+struct vlc_suuint { union { unsigned int value; }; };
+
+static_assert (sizeof (atomic_uint) <= sizeof (struct vlc_suuint),
+               "Size mismatch");
+static_assert (alignof (atomic_uint) <= alignof (struct vlc_suuint),
+               "Alignment mismatch");
+
 /*** Global locks ***/
 
 void vlc_global_mutex (unsigned n, bool acquire)
@@ -198,15 +206,8 @@ void (vlc_tick_sleep)(vlc_tick_t delay)
 #endif
 
 #ifdef LIBVLC_NEED_CONDVAR
-#include <stdalign.h>
-
 void vlc_cond_init(vlc_cond_t *cond)
 {
-    /* Don't use C++ atomic types in vlc_threads.h for the C atomic storage */
-    static_assert (sizeof (cond->cpp_value) <= sizeof (cond->value),
-                   "Size mismatch!");
-    static_assert ((alignof (cond->cpp_value) % alignof (cond->value)) == 0,
-                   "Alignment mismatch");
     /* Initial value is irrelevant but set it for happy debuggers */
     atomic_init(&cond->value, 0);
 }



More information about the vlc-commits mailing list