<html><head></head><body>IMU, compare-exchange with comparand equal to assignment value makes no sense, since it's just an over-comlicated load.<br><br><div class="gmail_quote">Le 10 mai 2018 14:41:46 GMT+02:00, KO Myung-Hun <komh78@gmail.com> 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">---<br> include/vlc_threads.h | 6 ++++++<br> src/os2/thread.c | 20 ++++++++++++++++++++<br> 2 files changed, 26 insertions(+)<br><br>diff --git a/include/vlc_threads.h b/include/vlc_threads.h<br>index 508ddbc001..b0891ac88c 100644<br>--- a/include/vlc_threads.h<br>+++ b/include/vlc_threads.h<br>@@ -125,6 +125,12 @@ typedef struct<br> #define VLC_STATIC_COND { NULLHANDLE, 0, NULLHANDLE, 0 }<br> #define LIBVLC_NEED_SEMAPHORE<br> #define LIBVLC_NEED_RWLOCK<br>+typedef struct<br>+{<br>+ unsigned done;<br>+ vlc_mutex_t mutex;<br>+} vlc_once_t;<br>+#define VLC_STATIC_ONCE { 0, VLC_STATIC_MUTEX }<br> typedef struct vlc_threadvar *vlc_threadvar_t;<br> typedef struct vlc_timer *vlc_timer_t;<br> <br>diff --git a/src/os2/thread.c b/src/os2/thread.c<br>index 3b435bfad8..000c3068b3 100644<br>--- a/src/os2/thread.c<br>+++ b/src/os2/thread.c<br>@@ -429,6 +429,26 @@ int vlc_cond_timedwait_daytime (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,<br> return vlc_cond_wait_common (p_condvar, p_mutex, ulTimeout);<br> }<br> <br>+void vlc_once(vlc_once_t *once, void (*cb)(void))<br>+{<br>+ /* once->done is 0 ? */<br>+ if( __atomic_cmpxchg32( &once->done, 0, 0 ))<br>+ {<br>+ vlc_mutex_lock( &once->mutex );<br>+<br>+ /* still once->done is 0 ? */<br>+ if( __atomic_cmpxchg32( &once->done, 0, 0 ))<br>+ {<br>+ cb();<br>+<br>+ /* set once->done to 1 */<br>+ __atomic_xchg( &once->done, 1 );<br>+ }<br>+<br>+ vlc_mutex_unlock( &once->mutex );<br>+ }<br>+}<br>+<br> /*** Thread-specific variables (TLS) ***/<br> struct vlc_threadvar<br> {</pre></blockquote></div><br>
-- <br>
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>