[vlc-devel] [PATCH 2/2] win32: implement vlc_assert_locked()
Steve Lhomme
robux4 at videolabs.io
Wed Jun 22 14:00:13 CEST 2016
On Tue, Jun 21, 2016 at 12:56 PM, Steve Lhomme <robux4 at videolabs.io> wrote:
> --
> simple rebase of https://patches.videolan.org/patch/13640/
> ---
> src/libvlc.h | 2 +-
> src/win32/thread.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/src/libvlc.h b/src/libvlc.h
> index 63d8b54..86f31fc 100644
> --- a/src/libvlc.h
> +++ b/src/libvlc.h
> @@ -62,7 +62,7 @@ void vlc_threads_setup (libvlc_int_t *);
> void vlc_trace (const char *fn, const char *file, unsigned line);
> #define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
>
> -#if (defined (LIBVLC_USE_PTHREAD) || defined(__ANDROID__)) && !defined (NDEBUG)
> +#if (defined (LIBVLC_USE_PTHREAD) || defined(__ANDROID__) || defined(_WIN32)) && !defined (NDEBUG)
> void vlc_assert_locked (vlc_mutex_t *);
> #else
> # define vlc_assert_locked( m ) (void)m
> diff --git a/src/win32/thread.c b/src/win32/thread.c
> index 8d53185..6fafbfa 100644
> --- a/src/win32/thread.c
> +++ b/src/win32/thread.c
> @@ -187,6 +187,25 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
> LeaveCriticalSection (&p_mutex->mutex);
> }
>
> +#ifndef NDEBUG
> +void vlc_assert_locked (vlc_mutex_t *p_mutex)
> +{
> + if (!p_mutex->dynamic)
> + { /* static mutexes */
> + assert (p_mutex != &super_mutex); /* this one cannot be static */
> +
> + vlc_mutex_lock (&super_mutex);
Oops, a rebase is not sufficient. super_mutex is now a critical section.
> + assert (p_mutex->locked);
> + vlc_mutex_unlock (&super_mutex);
> + return;
> + }
> +
> + int ret = TryEnterCriticalSection (&p_mutex->mutex);
> + assert(ret != 0 && p_mutex->locked);
> + LeaveCriticalSection (&p_mutex->mutex);
> +}
> +#endif
> +
> /*** Semaphore ***/
> #if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
> # include <stdalign.h>
> --
> 2.8.2
>
More information about the vlc-devel
mailing list