<html><head></head><body>No objections.<br><br><div class="gmail_quote">Le 10 février 2020 15:39:15 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">Either we pass a cleaner (PUSH) or NULL (POP).<hr> include/vlc_threads.h | 19 ++++++-------------<br> src/missing.c | 4 ++--<br> src/os2/thread.c | 30 ++++++++++--------------------<br> src/win32/thread.c | 30 ++++++++++--------------------<br> 4 files changed, 28 insertions(+), 55 deletions(-)<br><br>diff --git a/include/vlc_threads.h b/include/vlc_threads.h<br>index 68b98b6b335..0e27ea803fa 100644<br>--- a/include/vlc_threads.h<br>+++ b/include/vlc_threads.h<br>@@ -816,13 +816,15 @@ VLC_API int vlc_savecancel(void);<br> */<br> VLC_API void vlc_restorecancel(int state);<br> <br>+typedef struct vlc_cleanup_t vlc_cleanup_t;<br>+<br> /**<br> * Internal handler for thread cancellation.<br> *<br> * Do not call this function directly. Use wrapper macros instead:<br> * vlc_cleanup_push(), vlc_cleanup_pop().<br> */<br>-VLC_API void vlc_control_cancel(int cmd, ...);<br>+VLC_API void vlc_control_cancel(vlc_cleanup_t *);<br> <br> /**<br> * Thread handle.<br>@@ -1033,12 +1035,6 @@ VLC_API unsigned vlc_timer_getoverrun(vlc_timer_t) VLC_USED;<br> */<br> VLC_API unsigned vlc_GetCPUCount(void);<br> <br>-enum<br>-{<br>- VLC_CLEANUP_PUSH,<br>- VLC_CLEANUP_POP,<br>-};<br>-<br> #if defined (LIBVLC_USE_PTHREAD_CLEANUP)<br> /**<br> * Registers a thread cancellation handler.<br>@@ -1067,9 +1063,7 @@ enum<br> */<br> # define vlc_cleanup_pop( ) pthread_cleanup_pop (0)<br> <br>-#else<br>-typedef struct vlc_cleanup_t vlc_cleanup_t;<br>-<br>+#else /* !LIBVLC_USE_PTHREAD_CLEANUP */<br> struct vlc_cleanup_t<br> {<br> vlc_cleanup_t *next;<br>@@ -1084,11 +1078,10 @@ struct vlc_cleanup_t<br> */<br> # define vlc_cleanup_push( routine, arg ) \<br> do { \<br>- vlc_control_cancel(VLC_CLEANUP_PUSH, \<br>- &(vlc_cleanup_t){ NULL, routine, arg })<br>+ vlc_control_cancel(&(vlc_cleanup_t){ NULL, routine, arg })<br> <br> # define vlc_cleanup_pop( ) \<br>- vlc_control_cancel (VLC_CLEANUP_POP); \<br>+ vlc_control_cancel (NULL); \<br> } while (0)<br> # else<br> /* Those macros do not work in C++. However common C/C++ helpers may call them<br>diff --git a/src/missing.c b/src/missing.c<br>index dcab1b1d6b7..72c60c93159 100644<br>--- a/src/missing.c<br>+++ b/src/missing.c<br>@@ -297,9 +297,9 @@ noreturn update_release_t *update_GetRelease(update_t *u)<br> <br> #include <vlc_threads.h><br> #if defined(LIBVLC_USE_PTHREAD_CLEANUP)<br>-noreturn void vlc_control_cancel (int cmd, ...)<br>+noreturn void vlc_control_cancel (vlc_cleanup_t *cleaner)<br> {<br>- (void) cmd;<br>+ (void) cleaner;<br> vlc_assert_unreachable ();<br> }<br> #endif<br>diff --git a/src/os2/thread.c b/src/os2/thread.c<br>index 98a72984afc..7975cd52a7f 100644<br>--- a/src/os2/thread.c<br>+++ b/src/os2/thread.c<br>@@ -749,36 +749,26 @@ void vlc_testcancel (void)<br> }<br> }<br> <br>-void vlc_control_cancel (int cmd, ...)<br>+void vlc_control_cancel (vlc_cleanup_t *cleaner)<br> {<br> /* NOTE: This function only modifies thread-specific data, so there is no<br> * need to lock anything. */<br>- va_list ap;<br> <br> struct vlc_thread *th = vlc_thread_self ();<br> if (th == NULL)<br> return; /* Main thread - cannot be cancelled anyway */<br> <br>- va_start (ap, cmd);<br>- switch (cmd)<br>+ if (cleaner != NULL)<br> {<br>- case VLC_CLEANUP_PUSH:<br>- {<br>- /* cleaner is a pointer to the caller stack, no need to allocate<br>- * and copy anything. As a nice side effect, this cannot fail. */<br>- vlc_cleanup_t *cleaner = va_arg (ap, vlc_cleanup_t *);<br>- cleaner->next = th->cleaners;<br>- th->cleaners = cleaner;<br>- break;<br>- }<br>-<br>- case VLC_CLEANUP_POP:<br>- {<br>- th->cleaners = th->cleaners->next;<br>- break;<br>- }<br>+ /* cleaner is a pointer to the caller stack, no need to allocate<br>+ * and copy anything. As a nice side effect, this cannot fail. */<br>+ cleaner->next = th->cleaners;<br>+ th->cleaners = cleaner;<br>+ }<br>+ else<br>+ {<br>+ th->cleaners = th->cleaners->next;<br> }<br>- va_end (ap);<br> }<br> <br> static int vlc_select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,<br>diff --git a/src/win32/thread.c b/src/win32/thread.c<br>index 994bd1631b4..7bc61965195 100644<br>--- a/src/win32/thread.c<br>+++ b/src/win32/thread.c<br>@@ -638,36 +638,26 @@ void vlc_testcancel (void)<br> _endthreadex(0);<br> }<br> <br>-void vlc_control_cancel (int cmd, ...)<br>+void vlc_control_cancel (vlc_cleanup_t *cleaner)<br> {<br> /* NOTE: This function only modifies thread-specific data, so there is no<br> * need to lock anything. */<br>- va_list ap;<br> <br> struct vlc_thread *th = vlc_thread_self();<br> if (th == NULL)<br> return; /* Main thread - cannot be cancelled anyway */<br> <br>- va_start (ap, cmd);<br>- switch (cmd)<br>+ if (cleaner != NULL)<br> {<br>- case VLC_CLEANUP_PUSH:<br>- {<br>- /* cleaner is a pointer to the caller stack, no need to allocate<br>- * and copy anything. As a nice side effect, this cannot fail. */<br>- vlc_cleanup_t *cleaner = va_arg (ap, vlc_cleanup_t *);<br>- cleaner->next = th->cleaners;<br>- th->cleaners = cleaner;<br>- break;<br>- }<br>-<br>- case VLC_CLEANUP_POP:<br>- {<br>- th->cleaners = th->cleaners->next;<br>- break;<br>- }<br>+ /* cleaner is a pointer to the caller stack, no need to allocate<br>+ * and copy anything. As a nice side effect, this cannot fail. */<br>+ cleaner->next = th->cleaners;<br>+ th->cleaners = cleaner;<br>+ }<br>+ else<br>+ {<br>+ th->cleaners = th->cleaners->next;<br> }<br>- va_end (ap);<br> }<br> <br> void vlc_cancel_addr_set(atomic_uint *addr)</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>