[FFmpeg-devel] [PATCH 5/7] avfilter/avfilter: convert to stdatomic

wm4 nfxjfg at googlemail.com
Thu Mar 23 08:16:29 EET 2017


On Wed, 22 Mar 2017 20:34:10 -0300
James Almer <jamrial at gmail.com> wrote:

> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavfilter/avfilter.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index b431990edc..049c5ff47c 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -19,7 +19,8 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> -#include "libavutil/atomic.h"
> +#include <stdatomic.h>
> +
>  #include "libavutil/avassert.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/buffer.h"
> @@ -580,13 +581,14 @@ AVFilter *avfilter_get_by_name(const char *name)
>  int avfilter_register(AVFilter *filter)
>  {
>      AVFilter **f = last_filter;
> +    const AVFilter *cmp = NULL;
>  
>      /* the filter must select generic or internal exclusively */
>      av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != AVFILTER_FLAG_SUPPORT_TIMELINE);
>  
>      filter->next = NULL;
>  
> -    while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
> +    while(*f || !atomic_compare_exchange_strong(f, &cmp, filter))
>          f = &(*f)->next;
>      last_filter = &filter->next;
>  

Patches 2-5 are OK, but work only with real atomics. (All this
"lock free" code is another case of having to deal with barely justified
messes that were committed before, instead of having implemented a
cleaner solution, but whatever.)


More information about the ffmpeg-devel mailing list