<html><head></head><body>LGTM but I'll probably erase the code soon either way<br><br><div class="gmail_quote">Le 10 février 2020 15:39:12 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">We can include stdatomic.h in the headers, we do it in many places. But we<br>can't use it with C++ because the std:atomic_int storage is likely different<br>and can be initialized/released the same way.<br><br>We change the static assert in the core to make sure the type in the union that<br>will be used for storage by C++ modules is correct.<br><br>In C++11 there is std::condition_variable anyway. The vlc_cond_t would only be<br>useful to share it with C code in a module or legacy C++ code.<hr> include/vlc_threads.h | 7 ++++++-<br> src/misc/threads.c    | 8 ++++----<br> 2 files changed, 10 insertions(+), 5 deletions(-)<br><br>diff --git a/include/vlc_threads.h b/include/vlc_threads.h<br>index 1598c9c804d..68b98b6b335 100644<br>--- a/include/vlc_threads.h<br>+++ b/include/vlc_threads.h<br>@@ -357,7 +357,12 @@ typedef struct vlc_timer *vlc_timer_t;<br> <br> typedef struct<br> {<br>-    unsigned value;<br>+    union {<br>+#ifndef __cplusplus<br>+        atomic_uint value;<br>+#endif<br>+        int        cpp_value;<br>+    };<br> } vlc_cond_t;<br> # define VLC_STATIC_COND { 0 }<br> #endif<br>diff --git a/src/misc/threads.c b/src/misc/threads.c<br>index b40348ca903..7edb369bed4 100644<br>--- a/src/misc/threads.c<br>+++ b/src/misc/threads.c<br>@@ -200,12 +200,12 @@ void (vlc_tick_sleep)(vlc_tick_t delay)<br> <br> static inline atomic_uint *vlc_cond_value(vlc_cond_t *cond)<br> {<br>-    /* XXX: ugly but avoids including stdatomic.h in vlc_threads.h */<br>-    static_assert (sizeof (cond->value) <= sizeof (atomic_uint),<br>+    /* Don't use C++ atomic types in vlc_threads.h for the C atomic storage */<br>+    static_assert (sizeof (cond->cpp_value) <= sizeof (cond->value),<br>                    "Size mismatch!");<br>-    static_assert ((alignof (cond->value) % alignof (atomic_uint)) == 0,<br>+    static_assert ((alignof (cond->cpp_value) % alignof (cond->value)) == 0,<br>                    "Alignment mismatch");<br>-    return (atomic_uint *)&cond->value;<br>+    return &cond->value;<br> }<br> <br> void vlc_cond_init(vlc_cond_t *cond)</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>