aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-03-20 07:19:17 +0000
committerUlrich Drepper <drepper@redhat.com>2003-03-20 07:19:17 +0000
commit4009bf404450e4ad7b72140d7bae3226fad3468c (patch)
tree175b2211f0ae10f837a3822c08cb2b989663725a
parent85b5767c57eecaad6aea0967444f5e5d42a4cc17 (diff)
downloadglibc-4009bf404450e4ad7b72140d7bae3226fad3468c.zip
glibc-4009bf404450e4ad7b72140d7bae3226fad3468c.tar.gz
glibc-4009bf404450e4ad7b72140d7bae3226fad3468c.tar.bz2
Update.
2003-03-19 Ulrich Drepper <drepper@redhat.com> * Makefile (distribute): Add include/atomic.h and bits/atomic.h. * include/atomic.h: New file. * sysdeps/i386/i486/bits/atomic.h: New file. * sysdeps/x86_64/bits/atomic.h: New file. * sysdeps/s390/bits/atomic.h: New file. * sysdeps/sh/bits/atomic.h: New file. * sysdeps/ia64/bits/atomic.h: New file. * sysdeps/powerpc/bits/atomic.h: New file. * sysdeps/generic/bits/atomic.h: New file. * sysdeps/i386/i486/atomicity.h: Removed. * sysdeps/x86_64/atomicity.h: Removed. * sysdeps/s390/s390-32/atomicity.h: Removed. * sysdeps/s390/s390-64/atomicity.h: Removed. * sysdeps/ia64/atomicity.h: Removed. * sysdeps/powerpc/powerpc32/atomicity.h: Removed. * sysdeps/powerpc/powerpc64/atomicity.h: Removed. * elf/dl-profile.c: Use atomic.h instead of atomicity.h. Adjust use of macros from atomicity.h to new names and semantics. * gmon_mcount.c: Likewise. * malloc/set-freeres.c: Likewise. * nscd/cache.c: Likewise. * stdlib/cxa_finalize.c: Likewise. * sysdeps/unix/sysv/linux/getsysstats.c: Likewise. * sysdeps/mips/ieee754.h: New file, suitable to replace both * stdlib/strtod.c (INTERNAL): While eating trailing zeros handle
-rw-r--r--ChangeLog30
-rw-r--r--Makefile1
-rw-r--r--bits/atomic.h (renamed from nptl/sysdeps/i386/i586/bits/atomic.h)17
-rw-r--r--elf/dl-profile.c16
-rw-r--r--gmon/mcount.c5
-rw-r--r--include/atomic.h (renamed from nptl/atomic.h)0
-rw-r--r--malloc/set-freeres.c6
-rw-r--r--nptl/ChangeLog10
-rw-r--r--nscd/cache.c6
-rw-r--r--stdlib/cxa_finalize.c7
-rw-r--r--sysdeps/generic/bits/atomic.h (renamed from nptl/sysdeps/i386/i686/bits/atomic.h)17
-rw-r--r--sysdeps/i386/i486/atomicity.h57
-rw-r--r--sysdeps/i386/i486/bits/atomic.h (renamed from nptl/sysdeps/i386/i486/bits/atomic.h)0
-rw-r--r--sysdeps/ia64/atomicity.h48
-rw-r--r--sysdeps/ia64/bits/atomic.h (renamed from nptl/sysdeps/ia64/bits/atomic.h)0
-rw-r--r--sysdeps/powerpc/bits/atomic.h (renamed from nptl/sysdeps/powerpc/bits/atomic.h)0
-rw-r--r--sysdeps/powerpc/powerpc32/atomicity.h98
-rw-r--r--sysdeps/powerpc/powerpc64/atomicity.h132
-rw-r--r--sysdeps/s390/bits/atomic.h (renamed from nptl/sysdeps/s390/bits/atomic.h)0
-rw-r--r--sysdeps/s390/s390-32/atomicity.h76
-rw-r--r--sysdeps/s390/s390-64/atomicity.h76
-rw-r--r--sysdeps/sh/bits/atomic.h (renamed from nptl/sysdeps/sh/bits/atomic.h)0
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c7
-rw-r--r--sysdeps/x86_64/atomicity.h57
-rw-r--r--sysdeps/x86_64/bits/atomic.h (renamed from nptl/sysdeps/x86_64/bits/atomic.h)0
25 files changed, 91 insertions, 575 deletions
diff --git a/ChangeLog b/ChangeLog
index 1adf4cb..6c0eb64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,38 @@
+2003-03-19 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (distribute): Add include/atomic.h and bits/atomic.h.
+ * include/atomic.h: New file.
+ * sysdeps/i386/i486/bits/atomic.h: New file.
+ * sysdeps/x86_64/bits/atomic.h: New file.
+ * sysdeps/s390/bits/atomic.h: New file.
+ * sysdeps/sh/bits/atomic.h: New file.
+ * sysdeps/ia64/bits/atomic.h: New file.
+ * sysdeps/powerpc/bits/atomic.h: New file.
+ * sysdeps/generic/bits/atomic.h: New file.
+ * sysdeps/i386/i486/atomicity.h: Removed.
+ * sysdeps/x86_64/atomicity.h: Removed.
+ * sysdeps/s390/s390-32/atomicity.h: Removed.
+ * sysdeps/s390/s390-64/atomicity.h: Removed.
+ * sysdeps/ia64/atomicity.h: Removed.
+ * sysdeps/powerpc/powerpc32/atomicity.h: Removed.
+ * sysdeps/powerpc/powerpc64/atomicity.h: Removed.
+ * elf/dl-profile.c: Use atomic.h instead of atomicity.h. Adjust
+ use of macros from atomicity.h to new names and semantics.
+ * gmon_mcount.c: Likewise.
+ * malloc/set-freeres.c: Likewise.
+ * nscd/cache.c: Likewise.
+ * stdlib/cxa_finalize.c: Likewise.
+ * sysdeps/unix/sysv/linux/getsysstats.c: Likewise.
+
2003-03-19 Alexandre Oliva <aoliva@redhat.com>
- * sysdeps/mips/ieee754.h: New file, suitable to replace both
+ * sysdeps/mips/ieee754.h: New file, suitable to replace both
../ieee754/ieee754.h and ../ieee754/ldbl-128/ieee754.h, kept
mips-specific for now.
2003-03-19 Ulrich Drepper <drepper@redhat.com>
- * stdlib/strtod.c (INTERNAL): While eating trailing zeros handling
+ * stdlib/strtod.c (INTERNAL): While eating trailing zeros handle
hexdigits correctly. Reported by Fred Tydeman <tydeman@tybor.com>.
* stdlib/tst-strtod.c: Add test for the bug.
diff --git a/Makefile b/Makefile
index 3270a80..d09792c 100644
--- a/Makefile
+++ b/Makefile
@@ -274,6 +274,7 @@ distribute := README README.libm INSTALL FAQ FAQ.in NOTES NEWS BUGS \
include/shlib-compat.h include/pthread.h Versions.def \
cppflags-iterator.mk tls.make.c \
include/stubs-prologue.h include/gnu/stubs.h \
+ include/atomic.h bits/atomic.h \
INTERFACE CONFORMANCE NAMESPACE LICENSES \
$(addprefix scripts/, \
rellns-sh config.sub config.guess \
diff --git a/nptl/sysdeps/i386/i586/bits/atomic.h b/bits/atomic.h
index 9cb58d5..7595b40 100644
--- a/nptl/sysdeps/i386/i586/bits/atomic.h
+++ b/bits/atomic.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+ 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
@@ -17,4 +17,15 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include "../../i486/bits/atomic.h"
+#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 arch_compare_and_exchange_acq(mem, newval, oldval) \
+ ({ *(mem) == (oldval) ? 1 : (*(mem) = (newval), 0); })
+
+#endif /* bits/atomic.h */
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 3a18881..be706ce 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -1,5 +1,5 @@
/* Profiling of shared libraries.
- Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc.
+ Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Based on the BSD mcount implementation.
@@ -34,7 +34,7 @@
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <atomicity.h>
+#include <atomic.h>
/* The LD_PROFILE feature has to be implemented different to the
normal profiling using the gmon/ functions. The problem is that an
@@ -516,24 +516,24 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
size_t newfromidx;
to_index = (data[narcs].self_pc
/ (hashfraction * sizeof (*tos)));
- newfromidx = exchange_and_add (&fromidx, 1) + 1;
+ newfromidx = atomic_exchange_and_add (&fromidx, 1) + 1;
froms[newfromidx].here = &data[narcs];
froms[newfromidx].link = tos[to_index];
tos[to_index] = newfromidx;
- atomic_add (&narcs, 1);
+ atomic_increment (&narcs);
}
/* If we still have no entry stop searching and insert. */
if (*topcindex == 0)
{
- uint_fast32_t newarc = exchange_and_add (narcsp, 1);
+ uint_fast32_t newarc = atomic_exchange_and_add (narcsp, 1);
/* In rare cases it could happen that all entries in FROMS are
occupied. So we cannot count this anymore. */
if (newarc >= fromlimit)
goto done;
- *topcindex = exchange_and_add (&fromidx, 1) + 1;
+ *topcindex = atomic_exchange_and_add (&fromidx, 1) + 1;
fromp = &froms[*topcindex];
fromp->here = &data[newarc];
@@ -541,7 +541,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
data[newarc].self_pc = selfpc;
data[newarc].count = 0;
fromp->link = 0;
- atomic_add (&narcs, 1);
+ atomic_increment (&narcs);
break;
}
@@ -554,7 +554,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
}
/* Increment the counter. */
- atomic_add (&fromp->here->count, 1);
+ atomic_increment (&fromp->here->count);
done:
;
diff --git a/gmon/mcount.c b/gmon/mcount.c
index 8e54812..c146650 100644
--- a/gmon/mcount.c
+++ b/gmon/mcount.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
and MCOUNT macros. */
#include "machine-gmon.h"
-#include <atomicity.h>
+#include <atomic.h>
/*
* mcount is called on entry to each function compiled with the profiling
@@ -69,7 +69,8 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
* check that we are profiling
* and that we aren't recursively invoked.
*/
- if (! compare_and_swap (&p->state, GMON_PROF_ON, GMON_PROF_BUSY))
+ if (atomic_compare_and_exchange_acq (&p->state, GMON_PROF_BUSY,
+ GMON_PROF_ON))
return;
/*
diff --git a/nptl/atomic.h b/include/atomic.h
index 813fb80..813fb80 100644
--- a/nptl/atomic.h
+++ b/include/atomic.h
diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c
index 67488a8..1c0733e 100644
--- a/malloc/set-freeres.c
+++ b/malloc/set-freeres.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,7 +16,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <atomicity.h>
+#include <atomic.h>
#include <stdlib.h>
#include <set-hooks.h>
#include <libc-internal.h>
@@ -36,7 +36,7 @@ __libc_freeres (void)
protect for multiple executions since these are fatal. */
static long int already_called;
- if (compare_and_swap (&already_called, 0, 1))
+ if (! atomic_compare_and_exchange_acq (&already_called, 1, 0))
{
void * const *p;
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 0ff7878..ccdc2da 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,5 +1,15 @@
2003-03-19 Ulrich Drepper <drepper@redhat.com>
+ * sysdeps/i386/i686/bits/atomic.h: Removed.
+ * sysdeps/i386/i586/bits/atomic.h: Removed.
+ * sysdeps/i386/i486/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/x86_64/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/s390/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/sh/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/ia64/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/powerpc/bits/atomic.h: Removed. Moved to glibc.
+ * atomic.h: Removed. Moved to glibc.
+
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Add
support for clock selection.
diff --git a/nscd/cache.c b/nscd/cache.c
index d8339e9..788d47b 100644
--- a/nscd/cache.c
+++ b/nscd/cache.c
@@ -17,7 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <atomicity.h>
+#include <atomic.h>
#include <errno.h>
#include <error.h>
#include <limits.h>
@@ -101,8 +101,8 @@ cache_add (int type, void *key, size_t len, const void *packet, size_t total,
/* Put the new entry in the first position. */
do
newp->next = table->array[hash];
- while (! compare_and_swap ((volatile long int *) &table->array[hash],
- (long int) newp->next, (long int) newp));
+ while (atomic_compare_and_exchange_acq (&table->array[hash], newp,
+ newp->next));
/* Update the statistics. */
if (data == (void *) -1)
diff --git a/stdlib/cxa_finalize.c b/stdlib/cxa_finalize.c
index 16f5028..19d6567 100644
--- a/stdlib/cxa_finalize.c
+++ b/stdlib/cxa_finalize.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,7 +18,7 @@
#include <assert.h>
#include <stdlib.h>
-#include <atomicity.h>
+#include <atomic.h>
#include "exit.h"
#include <fork.h>
@@ -36,7 +36,8 @@ __cxa_finalize (void *d)
for (f = &funcs->fns[funcs->idx - 1]; f >= &funcs->fns[0]; --f)
if ((d == NULL || d == f->func.cxa.dso_handle)
/* We don't want to run this cleanup more than once. */
- && compare_and_swap (&f->flavor, ef_cxa, ef_free))
+ && (atomic_compare_and_exchange_acq (&f->flavor, ef_free, ef_cxa)
+ == 0))
(*f->func.cxa.fn) (f->func.cxa.arg, 0);
}
diff --git a/nptl/sysdeps/i386/i686/bits/atomic.h b/sysdeps/generic/bits/atomic.h
index 9cb58d5..7595b40 100644
--- a/nptl/sysdeps/i386/i686/bits/atomic.h
+++ b/sysdeps/generic/bits/atomic.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+ 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
@@ -17,4 +17,15 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include "../../i486/bits/atomic.h"
+#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 arch_compare_and_exchange_acq(mem, newval, oldval) \
+ ({ *(mem) == (oldval) ? 1 : (*(mem) = (newval), 0); })
+
+#endif /* bits/atomic.h */
diff --git a/sysdeps/i386/i486/atomicity.h b/sysdeps/i386/i486/atomicity.h
deleted file mode 100644
index df2fb81..0000000
--- a/sysdeps/i386/i486/atomicity.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Low-level functions for atomic operations. ix86 version, x >= 4.
- Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-
-static inline uint32_t
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, uint32_t val)
-{
- register uint32_t result;
- __asm__ __volatile__ ("lock; xaddl %0,%1"
- : "=r" (result), "=m" (*mem) : "0" (val), "1" (*mem));
- return result;
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- __asm__ __volatile__ ("lock; addl %1,%0"
- : "=m" (*mem) : "ir" (val), "0" (*mem));
-}
-
-static inline char
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- char ret;
- long int readval;
-
- __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
- : "=q" (ret), "=m" (*p), "=a" (readval)
- : "r" (newval), "1" (*p), "a" (oldval));
- return ret;
-}
-
-#endif /* atomicity.h */
diff --git a/nptl/sysdeps/i386/i486/bits/atomic.h b/sysdeps/i386/i486/bits/atomic.h
index 80a4987..80a4987 100644
--- a/nptl/sysdeps/i386/i486/bits/atomic.h
+++ b/sysdeps/i386/i486/bits/atomic.h
diff --git a/sysdeps/ia64/atomicity.h b/sysdeps/ia64/atomicity.h
deleted file mode 100644
index 615befd..0000000
--- a/sysdeps/ia64/atomicity.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Low-level functions for atomic operations. IA-64 version.
- Copyright (C) 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-#include <ia64intrin.h>
-
-
-static inline uint32_t
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, uint32_t val)
-{
- return __sync_fetch_and_add (mem, val);
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- __sync_fetch_and_add (mem, val);
-}
-
-static inline int
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- return __sync_bool_compare_and_swap (p, oldval, newval);
-}
-
-#endif /* atomicity.h */
diff --git a/nptl/sysdeps/ia64/bits/atomic.h b/sysdeps/ia64/bits/atomic.h
index fab2307..fab2307 100644
--- a/nptl/sysdeps/ia64/bits/atomic.h
+++ b/sysdeps/ia64/bits/atomic.h
diff --git a/nptl/sysdeps/powerpc/bits/atomic.h b/sysdeps/powerpc/bits/atomic.h
index af61563..af61563 100644
--- a/nptl/sysdeps/powerpc/bits/atomic.h
+++ b/sysdeps/powerpc/bits/atomic.h
diff --git a/sysdeps/powerpc/powerpc32/atomicity.h b/sysdeps/powerpc/powerpc32/atomicity.h
deleted file mode 100644
index 253bd32..0000000
--- a/sysdeps/powerpc/powerpc32/atomicity.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Low-level functions for atomic operations. PowerPC version.
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-static inline int
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, int val)
-{
- int tmp, result;
- __asm__ ("\n\
-0: lwarx %0,0,%2 \n\
- add%I3 %1,%0,%3 \n\
- stwcx. %1,0,%2 \n\
- bne- 0b \n\
-" : "=&b"(result), "=&r"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
- return result;
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- int tmp;
- __asm__ ("\n\
-0: lwarx %0,0,%1 \n\
- add%I2 %0,%0,%2 \n\
- stwcx. %0,0,%1 \n\
- bne- 0b \n\
-" : "=&b"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
-}
-
-static inline int
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- int result;
- __asm__ ("\n\
-0: lwarx %0,0,%1 \n\
- sub%I2c. %0,%0,%2 \n\
- cntlzw %0,%0 \n\
- bne- 1f \n\
- stwcx. %3,0,%1 \n\
- bne- 0b \n\
-1: \n\
-" : "=&b"(result) : "r"(p), "Ir"(oldval), "r"(newval) : "cr0", "memory");
- return result >> 5;
-}
-
-static inline long int
-__attribute__ ((unused))
-always_swap (volatile long int *p, long int newval)
-{
- long int result;
- __asm__ ("\n\
-0: lwarx %0,0,%1 \n\
- stwcx. %2,0,%1 \n\
- bne- 0b \n\
-" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory");
- return result;
-}
-
-static inline int
-__attribute__ ((unused))
-test_and_set (volatile long int *p, long int newval)
-{
- int result;
- __asm__ ("\n\
-0: lwarx %0,0,%1 \n\
- cmpwi %0,0 \n\
- bne- 1f \n\
- stwcx. %2,0,%1 \n\
- bne- 0b \n\
-1: \n\
-" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory");
- return result;
-}
-
-#endif /* atomicity.h */
diff --git a/sysdeps/powerpc/powerpc64/atomicity.h b/sysdeps/powerpc/powerpc64/atomicity.h
deleted file mode 100644
index b9d0de0..0000000
--- a/sysdeps/powerpc/powerpc64/atomicity.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Low-level functions for atomic operations. PowerPC64 version.
- Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-#if BROKEN_PPC_ASM_CR0
-# define __ATOMICITY_INLINE /* nothing */
-#else
-# define __ATOMICITY_INLINE inline
-#endif
-
-static __ATOMICITY_INLINE int
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, int val)
-{
- int tmp, result;
- __asm__ ("\n\
-0: lwarx %0,0,%2 \n\
- add%I3 %1,%0,%3 \n\
- stwcx. %1,0,%2 \n\
- bne- 0b \n\
-" : "=&b"(result), "=&r"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
- return result;
-}
-
-static __ATOMICITY_INLINE void
-__attribute__ ((unused))
-atomic_add_long (volatile long *mem, int val)
-{
- int tmp;
- __asm__ ("\n\
-0: ldarx %0,0,%1 \n\
- add%I2 %0,%0,%2 \n\
- stdcx. %0,0,%1 \n\
- bne- 0b \n\
-" : "=&b"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
-}
-
-
-static __ATOMICITY_INLINE int
-__attribute__ ((unused))
-exchange_and_add_long (volatile long *mem, int val)
-{
- int tmp, result;
- __asm__ ("\n\
-0: ldarx %0,0,%2 \n\
- add%I3 %1,%0,%3 \n\
- stdcx. %1,0,%2 \n\
- bne- 0b \n\
-" : "=&b"(result), "=&r"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
- return result;
-}
-
-static __ATOMICITY_INLINE void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- int tmp;
- __asm__ ("\n\
-0: lwarx %0,0,%1 \n\
- add%I2 %0,%0,%2 \n\
- stwcx. %0,0,%1 \n\
- bne- 0b \n\
-" : "=&b"(tmp) : "r" (mem), "Ir"(val) : "cr0", "memory");
-}
-
-static __ATOMICITY_INLINE int
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- int result;
- __asm__ ("\n\
-0: ldarx %0,0,%1 \n\
- sub%I2c. %0,%0,%2 \n\
- cntlzw %0,%0 \n\
- bne- 1f \n\
- stdcx. %3,0,%1 \n\
- bne- 0b \n\
-1: \n\
-" : "=&b"(result) : "r"(p), "Ir"(oldval), "r"(newval) : "cr0", "memory");
- return result >> 5;
-}
-
-static __ATOMICITY_INLINE long int
-__attribute__ ((unused))
-always_swap (volatile long int *p, long int newval)
-{
- long int result;
- __asm__ ("\n\
-0: ldarx %0,0,%1 \n\
- stdcx. %2,0,%1 \n\
- bne- 0b \n\
-" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory");
- return result;
-}
-
-static __ATOMICITY_INLINE int
-__attribute__ ((unused))
-test_and_set (volatile long int *p, long int newval)
-{
- int result;
- __asm__ ("\n\
-0: ldarx %0,0,%1 \n\
- cmpdi %0,0 \n\
- bne- 1f \n\
- stdcx. %2,0,%1 \n\
- bne- 0b \n\
-1: \n\
-" : "=&r"(result) : "r"(p), "r"(newval) : "cr0", "memory");
- return result;
-}
-
-#endif /* atomicity.h */
diff --git a/nptl/sysdeps/s390/bits/atomic.h b/sysdeps/s390/bits/atomic.h
index 375ae0d..375ae0d 100644
--- a/nptl/sysdeps/s390/bits/atomic.h
+++ b/sysdeps/s390/bits/atomic.h
diff --git a/sysdeps/s390/s390-32/atomicity.h b/sysdeps/s390/s390-32/atomicity.h
deleted file mode 100644
index 32a7c0f..0000000
--- a/sysdeps/s390/s390-32/atomicity.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Low-level functions for atomic operations. S390 version.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-static inline int
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, int val)
-{
- int result;
- __asm__ __volatile__(
- " L %0,%2\n"
- " LA 2,%1\n"
- "0: LR 0,%0\n"
- " AR 0,%3\n"
- " CS %0,0,0(2)\n"
- " JL 0b"
- : "=&d" (result), "=m" (*mem)
- : "1" (*mem), "d" (val) : "0", "1", "2" );
- return result;
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- __asm__ __volatile__(
- " LA 2,%0\n"
- "0: L 0,%1\n"
- " LR 1,0\n"
- " AR 1,%2\n"
- " CS 0,1,0(2)\n"
- " JL 0b"
- : "=m" (*mem) : "0" (*mem), "d" (val) : "0", "1", "2" );
-}
-
-static inline int
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- int retval;
-
- __asm__ __volatile__(
- " la 1,%1\n"
- " lr 0,%2\n"
- " cs 0,%3,0(1)\n"
- " ipm %0\n"
- " srl %0,28\n"
- "0:"
- : "=&r" (retval), "+m" (*p)
- : "d" (oldval) , "d" (newval)
- : "memory", "0", "1", "cc");
- return !retval;
-}
-
-#endif /* atomicity.h */
diff --git a/sysdeps/s390/s390-64/atomicity.h b/sysdeps/s390/s390-64/atomicity.h
deleted file mode 100644
index 11a5f7f..0000000
--- a/sysdeps/s390/s390-64/atomicity.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Low-level functions for atomic operations. 64 bit S/390 version.
- Copyright (C) 2001 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-static inline int
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, int val)
-{
- int result;
- __asm__ __volatile__(
- " L %0,%2\n"
- " LA 2,%1\n"
- "0: LR 0,%0\n"
- " AR 0,%3\n"
- " CS %0,0,0(2)\n"
- " JL 0b"
- : "=&d" (result), "=m" (*mem)
- : "1" (*mem), "d" (val) : "0", "1", "2" );
- return result;
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- __asm__ __volatile__(
- " LA 2,%0\n"
- "0: L 0,%1\n"
- " LR 1,0\n"
- " AR 1,%2\n"
- " CS 0,1,0(2)\n"
- " JL 0b"
- : "=m" (*mem) : "0" (*mem), "d" (val) : "0", "1", "2" );
-}
-
-static inline int
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- int retval;
-
- __asm__ __volatile__(
- " la 1,%1\n"
- " lgr 0,%2\n"
- " csg 0,%3,0(1)\n"
- " ipm %0\n"
- " srl %0,28\n"
- "0:"
- : "=&r" (retval), "+m" (*p)
- : "d" (oldval) , "d" (newval)
- : "memory", "0", "1", "cc");
- return !retval;
-}
-
-#endif /* atomicity.h */
diff --git a/nptl/sysdeps/sh/bits/atomic.h b/sysdeps/sh/bits/atomic.h
index de176ca..de176ca 100644
--- a/nptl/sysdeps/sh/bits/atomic.h
+++ b/sysdeps/sh/bits/atomic.h
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 55ef5b6..c44e45c 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -1,5 +1,5 @@
/* Determine various system internal values, Linux version.
- Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -31,7 +31,7 @@
#include <unistd.h>
#include <sys/sysinfo.h>
-#include <atomicity.h>
+#include <atomic.h>
/* The default value for the /proc filesystem mount point. */
@@ -85,8 +85,7 @@ get_proc_path (char *buffer, size_t bufsize)
/* Now store the copied value. But do it atomically. */
assert (sizeof (long int) == sizeof (void *__unbounded));
- if (compare_and_swap ((long int *) &mount_proc, (long int) 0,
- (long int) copy_result) == 0)
+ if (atomic_compare_and_exchange_acq (&mount_proc, copy_result, NULL) == 0)
/* Replacing the value failed. This means another thread was
faster and we don't need the copy anymore. */
free (copy_result);
diff --git a/sysdeps/x86_64/atomicity.h b/sysdeps/x86_64/atomicity.h
deleted file mode 100644
index 925c9f9..0000000
--- a/sysdeps/x86_64/atomicity.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Low-level functions for atomic operations. x86-64 version.
- Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _ATOMICITY_H
-#define _ATOMICITY_H 1
-
-#include <inttypes.h>
-
-
-static inline uint32_t
-__attribute__ ((unused))
-exchange_and_add (volatile uint32_t *mem, uint32_t val)
-{
- register uint32_t result;
- __asm__ __volatile__ ("lock; xaddl %0,%1"
- : "=r" (result), "=m" (*mem) : "0" (val), "1" (*mem));
- return result;
-}
-
-static inline void
-__attribute__ ((unused))
-atomic_add (volatile uint32_t *mem, int val)
-{
- __asm__ __volatile__ ("lock; addl %1,%0"
- : "=m" (*mem) : "er" (val), "0" (*mem));
-}
-
-static inline char
-__attribute__ ((unused))
-compare_and_swap (volatile long int *p, long int oldval, long int newval)
-{
- char ret;
- long int readval;
-
- __asm__ __volatile__ ("lock; cmpxchgq %3, %1; sete %0"
- : "=q" (ret), "=m" (*p), "=a" (readval)
- : "r" (newval), "1" (*p), "a" (oldval));
- return ret;
-}
-
-#endif /* atomicity.h */
diff --git a/nptl/sysdeps/x86_64/bits/atomic.h b/sysdeps/x86_64/bits/atomic.h
index f72f16c..f72f16c 100644
--- a/nptl/sysdeps/x86_64/bits/atomic.h
+++ b/sysdeps/x86_64/bits/atomic.h