This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Remove incorrect default implementation of atomics.


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  <triegel@redhat.com>

	* bits/atomic.h: Remove file.
commit eb1dc68327c0d8215b0c26419317a2022337d125
Author: Torvald Riegel <triegel@redhat.com>
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 <drepper@redhat.com>, 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
-   <http://www.gnu.org/licenses/>.  */
-
-#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 */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]