From patchwork Wed Mar 22 23:34:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 3072 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp543731vsy; Wed, 22 Mar 2017 16:35:44 -0700 (PDT) X-Received: by 10.28.8.147 with SMTP id 141mr10468074wmi.43.1490225744128; Wed, 22 Mar 2017 16:35:44 -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 k133si9415565wmf.44.2017.03.22.16.35.43; Wed, 22 Mar 2017 16:35:44 -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 DE36568974E; Thu, 23 Mar 2017 01:34:43 +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 3FD1E689221 for ; Thu, 23 Mar 2017 01:34:35 +0200 (EET) Received: by mail-qk0-f196.google.com with SMTP id p22so644414qka.0 for ; Wed, 22 Mar 2017 16:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=5djslKCYVMXgpM9H0gm8H4fu9vAZmvxFv4CeV9E8zPE=; b=uVfDxbcUQp9Gl0epwHNQcEl5tVPGNLW4EFHjx8zCeBReEuaG14xR4qlg4MoqlpjBXY 3c8JI1dHD65w/IHON7txFq9G6IBTJ00eYev0QB39t2JXSrDVs9EyZp2XjQKKS9YE2jpX FEwnzYk5FawKpCL8VgOyUn9xXUcNr++Svm2jG1nA/KAL6Zwu+1Xr8F3xl/E5pajNkil9 wsSLDLUjefln5mozz+xmLnzDU4uupaIw5rkVjXUCvK9J4LaJqZdFJke5h1jSPslBrwN/ aeXylVaKc+oTHojABSpVUNLD68Pl5eiSx7qA8sCmGDRVrpft5Oz8waFqASvxim8LQ4n2 DFzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5djslKCYVMXgpM9H0gm8H4fu9vAZmvxFv4CeV9E8zPE=; b=VWj8n3xXn/rpMkhDASK0ECh2XklZT0S6KAN1PctfmWXB/uqBh6yjGVR1KkSAxoIgVl wFGy75Mi46v3Dljdn2+OuviFPW7MY7eZkgrxbT0lxMO6ez2JW7RvsfRCNw7TbQEtb1my IA19OOmP2yUyO0wrLfq5suDceBhCJwZz3ylddMgsYIDsPHwfa+hxeLLRNgi0XccryZII rxnSpMFhxyNBKlIX3nSI4O5LwVQI9+AGxqepULMJeCEhtfV/17pvqiLJhtdLRFRtlHx0 2NwcP/g8JVj1lq6tjmQJyWVuHFW83tJXsMw7IKeRoQwcqyVQ6eSGVUkSq9fmvF2AKDU1 EKvw== X-Gm-Message-State: AFeK/H2pT+jFpwNrAeD5ZuZrqmwsCA4qS1aZbcNAqTV65ohBSdfL/YPGcesdqsarD57Yag== X-Received: by 10.55.125.68 with SMTP id y65mr15406880qkc.83.1490225693182; Wed, 22 Mar 2017 16:34:53 -0700 (PDT) Received: from localhost.localdomain ([181.231.62.139]) by smtp.gmail.com with ESMTPSA id w55sm2055133qtw.9.2017.03.22.16.34.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 16:34:52 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Mar 2017 20:34:09 -0300 Message-Id: <20170322233412.6952-5-jamrial@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170322233412.6952-1-jamrial@gmail.com> References: <20170322233412.6952-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/7] avformat/format: convert 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- libavformat/format.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/format.c b/libavformat/format.c index 38ca2a3465..403dc41b03 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(p, &cmp, 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(p, &cmp, format)) p = &(*p)->next; if (!format->next)