[vlc-devel] [PATCH 2/6] thread: add generic futex-based muteces

Marvin Scholz epirat07 at gmail.com
Fri Feb 21 01:22:31 CET 2020


Hi, I did not do a full review of this, I just applied it
and tried it out and ran into a compilation error due
to the atomic pointer.

See inline:

On 20 Feb 2020, at 20:58, Rémi Denis-Courmont wrote:

> This provides a common implementation of fast (non-debug),
> error-checking (debug) and recursive muteces on top of
> vlc_atomic_wait() and vlc_atomic_notify_one(), using Drepper's tristate
> mutex algorithm.
>
> [ … ]
>
>  /**
>   * Read/write lock.
> @@ -343,6 +335,43 @@ typedef struct vlc_timer *vlc_timer_t;
>   * \defgroup mutex Mutual exclusion locks
>   * @{
>   */
> +#ifndef LIBVLC_DONT_WANT_MUTEX
> +/**
> + * Mutex.
> + *
> + * Storage space for a mutual exclusion lock.
> + */
> +typedef struct
> +{
> +    union {
> +#ifndef __cplusplus
> +        struct {
> +            atomic_uint value;
> +            atomic_uint recursion;
> +            _Atomic const void *owner;

I believe you meant to do

    const void * _Atomic owner;

here, as you want the pointer and not void itself to be
atomic? With clang at least, _Atomic const void *owner
does not compile:

   error: _Atomic cannot be applied to incomplete type 'void'

> +        };
> +#endif
> +        struct {
> +            unsigned int value;
> +            unsigned int recursion;
> +            const void *owner;
> +        } dummy;
> +    };
> +} vlc_mutex_t;
>
> [ … ]


More information about the vlc-devel mailing list