From patchwork Thu Mar 23 03:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 3076 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp600888vsy; Wed, 22 Mar 2017 20:28:31 -0700 (PDT) X-Received: by 10.223.164.16 with SMTP id d16mr238803wra.47.1490239711154; Wed, 22 Mar 2017 20:28:31 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 71si366588wrc.318.2017.03.22.20.28.30; Wed, 22 Mar 2017 20:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C88E68833F; Thu, 23 Mar 2017 05:28:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB547680A6C for ; Thu, 23 Mar 2017 05:28:01 +0200 (EET) Received: by mail-qk0-f196.google.com with SMTP id p22so1158154qka.0 for ; Wed, 22 Mar 2017 20:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=maZk/+aGB3GrrPP6FUDs6nbzDuToNT9H+m3VcqF2x0g=; b=tiTqnuDnaT5e0Cb62asu0CgB5GSrcsgYfDjUKXiAbhyxv38T+H+u2RriAjUPeRKcfL TLlp7poZsbMLW7V5cO4UvcBhJD4H2MPtu+FulfAMneTBQmW8BKMghMDkFrmxHO4mZhkj 51gKlflBZiILvG6MtU/W5k3SN0pGNjUpuwuFg//OCNtylVaITyDMpdIjjMMLgRQUq5Nc thvO/B0WPPgDK6aGexTc+9jsKrEHcS533jTsyrRzFVV77/JCnbfmvGyJsN1yGKJf6DNU ue7TJ9q53gQoCCR8uTHpmRDrkgRFeVt6E2rkvaTdL5WHLm22p/wvMokxS/nAJO/EMYHm q7Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=maZk/+aGB3GrrPP6FUDs6nbzDuToNT9H+m3VcqF2x0g=; b=dbjwiSyHzDG9B20qQVUezw9Wuo744uiNwbocVlcIGvCe8RrcbRO2I6TPQukkvc4SDp 57vPCPULxuHzyG9/TKPhlKosWPPZ4TUr6sY8c9McFZxpp1FWS0JUHORKToVqf573JksJ pAKcuJDwJwT9oOOK1t6AGSpnNP6tPeu8lcudjabeq8Ytm62UXjEb2fYWw2yH4kkqyPNJ uAYJvMu/lNghn7SmWkAkUN+Tn0wt8AmZXKnp7m28rDI7/5+AWrkZ/+LnCKu2rfYo498d s61CYvfTTXnFwJzplTyR2gKgAcyQCx4YpbfCG8U1TL3nvpRnS7ZL+jJQQ+KJzaL17Mf0 KtZA== X-Gm-Message-State: AFeK/H0+E/lIVN4erMG1MKghmIWz8Kjmn/jbwTooVY2uGJ42Y4iSDrXK4ipDsV0/BcV6cw== X-Received: by 10.55.118.5 with SMTP id r5mr256325qkc.145.1490239699489; Wed, 22 Mar 2017 20:28:19 -0700 (PDT) Received: from [192.168.0.4] ([181.231.62.139]) by smtp.googlemail.com with ESMTPSA id x2sm2402284qkc.61.2017.03.22.20.28.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 20:28:18 -0700 (PDT) To: FFmpeg development discussions and patches References: <20170322233412.6952-1-jamrial@gmail.com> <20170323010133.GN4714@nb4> <43c1c93a-56d6-4b1e-b8ea-2c265582c472@gmail.com> From: James Almer Message-ID: Date: Thu, 23 Mar 2017 00:28:15 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <43c1c93a-56d6-4b1e-b8ea-2c265582c472@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 0/7] convert most of the remaining files to stdatomic X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 3/22/2017 11:01 PM, James Almer wrote: > On 3/22/2017 10:01 PM, Michael Niedermayer wrote: >> On Wed, Mar 22, 2017 at 08:34:05PM -0300, James Almer wrote: >>> This set deals with most of the remaining cases of libavutil/atomic.h usage. >>> "make fate THREADS=4" passes here on mingw-w64, but I'm not 100% sure fate >>> has proper coverage of some of these functions. >>> >>> Only ones remaining are Decklink (It's C++98 and I'm not sure how wise would >>> it be to include a C11 header in there, so i'm leaving that to someone else), >>> and error_resilience. >>> >>> James Almer (7): >>> avcodec/mediacodec: convert to stdatomic >>> avcodec/utils: convert to stdatomic >>> avcodec/parser: convert to stdatomic >>> avformat/format: convert to stdatomic >>> avfilter/avfilter: convert to stdatomic >>> avutil/opencl: convert to stdatomic >>> avcodec/videotoolboxenc: remove unused atomic header >>> >>> libavcodec/mediacodec.c | 5 ++--- >>> libavcodec/mediacodecdec.c | 1 - >>> libavcodec/mediacodecdec_common.c | 14 ++++++-------- >>> libavcodec/mediacodecdec_common.h | 5 +++-- >>> libavcodec/parser.c | 14 ++++++++++---- >>> libavcodec/utils.c | 19 +++++++++++-------- >>> libavcodec/videotoolboxenc.c | 1 - >>> libavfilter/avfilter.c | 6 ++++-- >>> libavformat/format.c | 9 ++++++--- >>> libavutil/opencl.c | 5 +++-- >>> 10 files changed, 45 insertions(+), 34 deletions(-) >> >> This breaks building with clang >> >> CC libavfilter/avfilter.o >> CC libavformat/format.o >> CC libavcodec/parser.o >> CC libavcodec/utils.o >> src/libavformat/format.c:68:51: error: address argument to atomic operation must be a pointer to _Atomic type ('AVInputFormat **' (aka 'struct AVInputFormat **') invalid) >> while(p != &format->next && !format->next && !__c11_atomic_compare_exchange_strong(p, &cmp, format, 5, 5)) >> ^ ~ >> src/libavformat/format.c:81:51: error: address argument to atomic operation must be a pointer to _Atomic type ('AVOutputFormat **' (aka 'struct AVOutputFormat **') invalid) >> while(p != &format->next && !format->next && !__c11_atomic_compare_exchange_strong(p, &cmp, format, 5, 5)) >> ^ ~ >> 2 errors generated. >> make: *** [libavformat/format.o] Error 1 > > Casting the first argument to (atomic_intptr_t *) on GCC 6 gives me a warning > about making integer from pointer, but still works nonetheless. > > I'm not sure how to fix this. Got any idea? Does the attached patch compile with Clang? GCC 6 seems happy with it. It's getting kind of ugly in any case. From 3bf230d5f611ae5d1511e4629f742fc96b379b7f Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 22 Mar 2017 23:43:54 -0300 Subject: [PATCH] avformat/format: convert to stdatomic --- libavformat/format.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/format.c b/libavformat/format.c index 38ca2a3465..781f341936 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -19,7 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/atomic.h" +#include + #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/opt.h" @@ -61,9 +62,10 @@ AVOutputFormat *av_oformat_next(const AVOutputFormat *f) void av_register_input_format(AVInputFormat *format) { AVInputFormat **p = last_iformat; + const AVInputFormat *cmp = NULL; // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL - while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(p != &format->next && !format->next && !atomic_compare_exchange_strong((atomic_intptr_t *)p, (intptr_t *)&cmp, (intptr_t)format)) p = &(*p)->next; if (!format->next) @@ -73,9 +75,10 @@ void av_register_input_format(AVInputFormat *format) void av_register_output_format(AVOutputFormat *format) { AVOutputFormat **p = last_oformat; + const AVOutputFormat *cmp = NULL; // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL - while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(p != &format->next && !format->next && !atomic_compare_exchange_strong((atomic_intptr_t *)p, (intptr_t *)&cmp, (intptr_t)format)) p = &(*p)->next; if (!format->next) -- 2.12.0