From patchwork Mon Dec 8 17:26:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torvald Riegel X-Patchwork-Id: 418763 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9BDC71400D5 for ; Tue, 9 Dec 2014 04:27:05 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:content-type:date:message-id :mime-version; q=dns; s=default; b=kudZ9PdhfnlVNMPMgUam+wKzceyV1 75JuWTFL4lmZf8A7UHZU/j+kAaCM8r8gaRafEtRJ2kUY14AUO2BaM11ohnDmMYk7 EhBetZCvp2TAVDqHF8Rb+PtGX4P7YdcTF5uqawPXFjETqr5TOUAPx85dK8/DWzxR R7PMsiGZjyNIBg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:content-type:date:message-id :mime-version; s=default; bh=VZEjVOR2aL+Wf+Q/KiWW/lsDA8o=; b=PuF 2+sQfvwn/oV4aUk5LdaGGcoy9Mqo/QWbkxBsWpW9ZD30EaiONDNiByOxlqOEX60H jUgVBi8OYMU3B2ZawDwM1m1KXR/x/fio8S728tjo01ADJZVN6nq3OH7VmCanw90Y aRKXfiCwd7Db1zfSkzR2S6BSJ1W82S/hWtFfYmaw= Received: (qmail 27018 invoked by alias); 8 Dec 2014 17:26:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27009 invoked by uid 89); 8 Dec 2014 17:26:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Subject: [PATCH] Remove incorrect default implementation of atomics. From: Torvald Riegel To: GLIBC Devel Date: Mon, 08 Dec 2014 18:26:52 +0100 Message-ID: <1418059612.25868.84.camel@triegel.csb> Mime-Version: 1.0 There's a default implementation of atomic operations that just uses sequential code. This is incorrect because it at least would need proper compiler barriers, unless the arch using this somehow (can) make(s) assumptions about the compiler's optimizations too. I don't think it's useful to keep this. Every arch should have a correct implementation of atomics; having an incorrect default implementation is just error-prone. 2014-12-09 Torvald Riegel * bits/atomic.h: Remove file. commit eb1dc68327c0d8215b0c26419317a2022337d125 Author: Torvald Riegel Date: Mon Dec 8 17:47:55 2014 +0100 Remove incorrect default implementation of atomics. diff --git a/bits/atomic.h b/bits/atomic.h deleted file mode 100644 index a3d1fa1..0000000 --- a/bits/atomic.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2003-2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2003. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -/* We have by default no support for atomic operations. So define - them non-atomic. If this is a problem somebody will have to come - up with real definitions. */ - -/* The only basic operation needed is compare and exchange. */ -#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ - ({ __typeof (mem) __gmemp = (mem); \ - __typeof (*mem) __gret = *__gmemp; \ - __typeof (*mem) __gnewval = (newval); \ - \ - if (__gret == (oldval)) \ - *__gmemp = __gnewval; \ - __gret; }) - -#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ - ({ __typeof (mem) __gmemp = (mem); \ - __typeof (*mem) __gnewval = (newval); \ - \ - *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) - -#endif /* bits/atomic.h */