[FFmpeg-devel] [PATCH 6/7] avutil/opencl: convert to stdatomic

Wei Gao highgod0401 at gmail.com
Tue Aug 15 06:03:42 EEST 2017


2017-03-23 7:34 GMT+08:00 James Almer <jamrial at gmail.com>:

> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavutil/opencl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/opencl.c b/libavutil/opencl.c
> index af35770e06..9b6c8d10d8 100644
> --- a/libavutil/opencl.c
> +++ b/libavutil/opencl.c
> @@ -29,7 +29,7 @@
>
>  #if HAVE_THREADS
>  #include "thread.h"
> -#include "atomic.h"
> +#include <stdatomic.h>
>
>  static pthread_mutex_t * volatile atomic_opencl_lock = NULL;
>  #define LOCK_OPENCL pthread_mutex_lock(atomic_opencl_lock)
> @@ -351,13 +351,14 @@ static inline int init_opencl_mtx(void)
>      if (!atomic_opencl_lock) {
>          int err;
>          pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t));
> +        const pthread_mutex_t *cmp = NULL;
>          if (!tmp)
>              return AVERROR(ENOMEM);
>          if ((err = pthread_mutex_init(tmp, NULL))) {
>              av_free(tmp);
>              return AVERROR(err);
>          }
> -        if (avpriv_atomic_ptr_cas((void * volatile *)&atomic_opencl_lock,
> NULL, tmp)) {
> +        if (!atomic_compare_exchange_strong(&atomic_opencl_lock, &cmp,
> tmp)) {
>              pthread_mutex_destroy(tmp);
>              av_free(tmp);
>          }
> --
> 2.12.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Hi
Looks good to me, thanks


More information about the ffmpeg-devel mailing list