]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 2003 07:19:17 +0000 (07:19 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 2003 07:19:17 +0000 (07:19 +0000)
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

25 files changed:
ChangeLog
Makefile
bits/atomic.h [moved from nptl/sysdeps/i386/i586/bits/atomic.h with 59% similarity]
elf/dl-profile.c
gmon/mcount.c
include/atomic.h [moved from nptl/atomic.h with 100% similarity]
malloc/set-freeres.c
nptl/ChangeLog
nscd/cache.c
stdlib/cxa_finalize.c
sysdeps/generic/bits/atomic.h [moved from nptl/sysdeps/i386/i686/bits/atomic.h with 59% similarity]
sysdeps/i386/i486/atomicity.h [deleted file]
sysdeps/i386/i486/bits/atomic.h [moved from nptl/sysdeps/i386/i486/bits/atomic.h with 100% similarity]
sysdeps/ia64/atomicity.h [deleted file]
sysdeps/ia64/bits/atomic.h [moved from nptl/sysdeps/ia64/bits/atomic.h with 100% similarity]
sysdeps/powerpc/bits/atomic.h [moved from nptl/sysdeps/powerpc/bits/atomic.h with 100% similarity]
sysdeps/powerpc/powerpc32/atomicity.h [deleted file]
sysdeps/powerpc/powerpc64/atomicity.h [deleted file]
sysdeps/s390/bits/atomic.h [moved from nptl/sysdeps/s390/bits/atomic.h with 100% similarity]
sysdeps/s390/s390-32/atomicity.h [deleted file]
sysdeps/s390/s390-64/atomicity.h [deleted file]
sysdeps/sh/bits/atomic.h [moved from nptl/sysdeps/sh/bits/atomic.h with 100% similarity]
sysdeps/unix/sysv/linux/getsysstats.c
sysdeps/x86_64/atomicity.h [deleted file]
sysdeps/x86_64/bits/atomic.h [moved from nptl/sysdeps/x86_64/bits/atomic.h with 100% similarity]

index 1adf4cb4f542b4b4c092e5c71009026afb1d8725..6c0eb64d3c605fbb31109f7aa781f679ac560c7c 100644 (file)
--- 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.
 
index 3270a8019a5a187a1440bef7371ac72cdc0d3d2d..d09792c2137cb5c274f3e1ce2ac37bf917f4b6ee 100644 (file)
--- 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           \
similarity index 59%
rename from nptl/sysdeps/i386/i586/bits/atomic.h
rename to bits/atomic.h
index 9cb58d5f32f4fa5ea310a5b61ab3560c6d5fd54a..7595b407ca1c2faecfcfc8f1b697aa9aade75411 100644 (file)
@@ -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
    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 */
index 3a18881d263b07a83d158fe5b200dd9f82cdbce2..be706cefbf763dfea8f52f1bccb550a0bffec213 100644 (file)
@@ -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:
   ;
index 8e54812d75c3f1e021e1b80a9c83b0b2615aada6..c14665073d7bfd3eda1a37bf9e4c59416470b845 100644 (file)
@@ -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;
 
        /*
similarity index 100%
rename from nptl/atomic.h
rename to include/atomic.h
index 67488a821489b9ae4f1df3c44ff600db42575782..1c0733ec194824c1a00e0dc00527a907f0f984f7 100644 (file)
@@ -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;
 
index 0ff78787a6ce538706d6031e12d3a2a575561c0b..ccdc2dacb005e8bafc1bc1f3419f2bcf843b8ff4 100644 (file)
@@ -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.
 
index d8339e915d24459c0254522030e52dbbba781f1b..788d47bbd901960d1c80e6bf44f21f638820b478 100644 (file)
@@ -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)
index 16f50286e1f41d35e9281e404f15c992cd63b795..19d65678c9b57829a915da8de8f3dce2aab581f0 100644 (file)
@@ -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);
     }
 
similarity index 59%
rename from nptl/sysdeps/i386/i686/bits/atomic.h
rename to sysdeps/generic/bits/atomic.h
index 9cb58d5f32f4fa5ea310a5b61ab3560c6d5fd54a..7595b407ca1c2faecfcfc8f1b697aa9aade75411 100644 (file)
@@ -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
    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 (file)
index df2fb81..0000000
+++ /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/sysdeps/ia64/atomicity.h b/sysdeps/ia64/atomicity.h
deleted file mode 100644 (file)
index 615befd..0000000
+++ /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/sysdeps/powerpc/powerpc32/atomicity.h b/sysdeps/powerpc/powerpc32/atomicity.h
deleted file mode 100644 (file)
index 253bd32..0000000
+++ /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 (file)
index b9d0de0..0000000
+++ /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/sysdeps/s390/s390-32/atomicity.h b/sysdeps/s390/s390-32/atomicity.h
deleted file mode 100644 (file)
index 32a7c0f..0000000
+++ /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 (file)
index 11a5f7f..0000000
+++ /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 */
index 55ef5b661a701815485420c65304ab196415b705..c44e45ca6bf802aa4365ce361bee0ec61dd8c885 100644 (file)
@@ -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 (file)
index 925c9f9..0000000
+++ /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 */