From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id D0FAC3950E73 for ; Wed, 21 Jul 2021 13:08:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0FAC3950E73 Received: by mail-wr1-x42e.google.com with SMTP id c12so2142694wrt.3 for ; Wed, 21 Jul 2021 06:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=QRMVvOpCg2ikGy+uTbZgpGfLH8B4jwzg2qC7oSi3Wwc=; b=HgFqbLfOnoF0YH+KFXMf2U8VCSyH1DJ9s6/VztzcMN2kEmbl6Sldb684nuI11u9FXG z+92uvUaMYEdgj+lo9wWpxS+HWlCKmkHIASK0HHjLqF/S3OusG+yirX3LKueis3ZjvJI iG0F3ph+hAIJf+2p4si/xN2rlFhNqSfmo8CR/rAF4ZYaJDwQILZnKnUjQn0CBi+gwFCI ibFWS/EqtvkzIqWLHQk3uUVjPxe++FTsr63IqU/tVtSDQMqLRcSpUvHlJYDWSm9CBMow d22SnRJhuw2COc3us1dFWqhYNHbS6Z1IadHEdgA+6s1FgL0tn/nfuH9I50XVfa8jNKjV 9K6Q== X-Gm-Message-State: AOAM533k57TzNCfuHfOIPX9U1OTQuM0dqwtY3F5091lfb3V6l6UgYCSV /uiR1rjaGTIUcYiuAc0a88cjnrNFkvRLjWHVZNGyKkXlSMA= X-Google-Smtp-Source: ABdhPJwqf21+k/MSw3NwitABD6tycwtMOGEzQhVVTxJisjKF0Xniisd/K+3tWel+8fqwChTI7POb05ZyE+oicxfyoq0= X-Received: by 2002:a5d:64c4:: with SMTP id f4mr42760598wri.21.1626872908831; Wed, 21 Jul 2021 06:08:28 -0700 (PDT) MIME-Version: 1.0 References: <6974-60f81a80-e4b-3b2ba4c0@223414201> In-Reply-To: <6974-60f81a80-e4b-3b2ba4c0@223414201> From: Jonathan Wakely Date: Wed, 21 Jul 2021 14:08:17 +0100 Message-ID: Subject: Re: 6.55 Built-in Functions for Memory Model Aware Atomic Operations To: Amar Memic Cc: "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 13:08:32 -0000 N.B. I already answered this when you sent it to the libstdc++ list, read past the first line of my reply: https://gcc.gnu.org/pipermail/libstdc++/2021-July/052932.html On Wed, 21 Jul 2021 at 14:00, Amar Memic wrote: > > > Hi,6.55 Built-in Functions for Memory Model Aware Atomic Operations (http= s://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html) says:Note t= hat the =E2=80=98__atomic=E2=80=99 builtins assume that programs will confo= rm to the C++11 memory model. In particular, they assume that programs are = free of data races. See the C++11 standard for detailed requirements. > > I think the second sentence is a bit misleading because atomics should ha= ndle data races. > Especially, interleaving read/write or write/write operations should be w= ell-defined. > If you assume that programs are free of data races, then you could not im= plement spinlock based on these atomics, for example. > I hope you can help me to interpret the paragraph in the right manner. > > Thanks in advance > Amar Memic