summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/config/cpu
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2004-07-28 03:12:05 +0000
committerkan <kan@FreeBSD.org>2004-07-28 03:12:05 +0000
commit52be83b6ad37d5dc7ac86061c4055ab726aa8a1a (patch)
tree1dd73b7d74c54007cec582fd21a4512ff318007b /contrib/libstdc++/config/cpu
parente0020c9fe3d2c91658ad0f59cb6a55c44f909db3 (diff)
parent96bad46eee8bf907dceb152bbb9d128bed5a4956 (diff)
downloadFreeBSD-src-52be83b6ad37d5dc7ac86061c4055ab726aa8a1a.zip
FreeBSD-src-52be83b6ad37d5dc7ac86061c4055ab726aa8a1a.tar.gz
This commit was generated by cvs2svn to compensate for changes in r132720,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/libstdc++/config/cpu')
-rw-r--r--contrib/libstdc++/config/cpu/alpha/atomicity.h41
-rw-r--r--contrib/libstdc++/config/cpu/cris/atomic_word.h36
-rw-r--r--contrib/libstdc++/config/cpu/cris/atomicity.h46
-rw-r--r--contrib/libstdc++/config/cpu/generic/atomic_word.h35
-rw-r--r--contrib/libstdc++/config/cpu/generic/atomicity.h69
-rw-r--r--contrib/libstdc++/config/cpu/hppa/atomicity.h167
-rw-r--r--contrib/libstdc++/config/cpu/i386/atomicity.h89
-rw-r--r--contrib/libstdc++/config/cpu/i486/atomicity.h48
-rw-r--r--contrib/libstdc++/config/cpu/ia64/atomicity.h31
-rw-r--r--contrib/libstdc++/config/cpu/m68k/atomicity.h192
-rw-r--r--contrib/libstdc++/config/cpu/mips/atomicity.h104
-rw-r--r--contrib/libstdc++/config/cpu/powerpc/atomicity.h82
-rw-r--r--contrib/libstdc++/config/cpu/s390/atomicity.h54
-rw-r--r--contrib/libstdc++/config/cpu/sparc/atomic_word.h39
-rw-r--r--contrib/libstdc++/config/cpu/sparc/atomicity.h190
15 files changed, 642 insertions, 581 deletions
diff --git a/contrib/libstdc++/config/cpu/alpha/atomicity.h b/contrib/libstdc++/config/cpu/alpha/atomicity.h
index 895d87a..4eb311b 100644
--- a/contrib/libstdc++/config/cpu/alpha/atomicity.h
+++ b/contrib/libstdc++/config/cpu/alpha/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: Alpha version -*- C++ -*-
-// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,23 +27,22 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
/* @@@ With gas we can play nice .subsection games to get the
non-predicted branch pointing forward. But Digital assemblers
don't understand those directives. This isn't a terribly
important issue, so just ignore it. */
-typedef int _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- register int __result, __tmp;
-
- __asm__ __volatile__ (
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register int __result, __tmp;
+
+ __asm__ __volatile__ (
"\n$Lxadd_%=:\n\t"
"ldl_l %0,%3\n\t"
"addl %0,%4,%1\n\t"
@@ -53,16 +52,16 @@ __exchange_and_add (volatile _Atomic_word* __mem, int __val)
: "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
: "m" (*__mem), "r"(__val));
- return __result;
-}
+ return __result;
+ }
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
-{
- register _Atomic_word __result;
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register _Atomic_word __result;
- __asm__ __volatile__ (
+ __asm__ __volatile__ (
"\n$Ladd_%=:\n\t"
"ldl_l %0,%2\n\t"
"addl %0,%3,%0\n\t"
@@ -71,6 +70,6 @@ __atomic_add (volatile _Atomic_word* __mem, int __val)
"mb"
: "=&r"(__result), "=m"(*__mem)
: "m" (*__mem), "r"(__val));
-}
+ }
+} // namespace __gnu_cxx
-#endif /* atomicity.h */
diff --git a/contrib/libstdc++/config/cpu/cris/atomic_word.h b/contrib/libstdc++/config/cpu/cris/atomic_word.h
new file mode 100644
index 0000000..dd2cf6b
--- /dev/null
+++ b/contrib/libstdc++/config/cpu/cris/atomic_word.h
@@ -0,0 +1,36 @@
+// Low-level type for atomic operations -*- C++ -*-
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _GLIBCXX_ATOMIC_WORD_H
+#define _GLIBCXX_ATOMIC_WORD_H 1
+
+// This entity must not cross a page boundary.
+typedef int _Atomic_word __attribute__ ((__aligned__ (4)));
+
+#endif
diff --git a/contrib/libstdc++/config/cpu/cris/atomicity.h b/contrib/libstdc++/config/cpu/cris/atomicity.h
index 55c374f..3162f6a 100644
--- a/contrib/libstdc++/config/cpu/cris/atomicity.h
+++ b/contrib/libstdc++/config/cpu/cris/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: CRIS version -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,21 +27,18 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-// This entity must not cross a page boundary.
-typedef int _Atomic_word __attribute__ ((__aligned__ (4)));
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (_Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- int __tmp;
- _Atomic_word __result;
+ _Atomic_word
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ int __tmp;
+ _Atomic_word __result;
#if (__CRIS_arch_version >= 10)
- __asm__ __volatile__ (" clearf \n"
+ __asm__ __volatile__ (" clearf \n"
"0: \n"
" move.d %4,%2 \n"
" move.d [%3],%0 \n"
@@ -52,9 +49,11 @@ __exchange_and_add (_Atomic_word* __mem, int __val)
" clearf \n"
: "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
: "r" (__mem), "g" (__val), "m" (*__mem)
+ /* The memory clobber must stay, regardless of
+ current uses of this function. */
: "memory");
#else
- __asm__ __volatile__ (" move $ccr,$r9 \n"
+ __asm__ __volatile__ (" move $ccr,$r9 \n"
" di \n"
" move.d %4,%2 \n"
" move.d [%3],%0 \n"
@@ -63,17 +62,16 @@ __exchange_and_add (_Atomic_word* __mem, int __val)
" move $r9,$ccr \n"
: "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
: "r" (__mem), "g" (__val), "m" (*__mem)
- : "memory", "r9");
+ : "r9",
+ /* The memory clobber must stay, regardless of
+ current uses of this function. */
+ "memory");
#endif
- return __result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (_Atomic_word* __mem, int __val)
-{
- __exchange_and_add (__mem, __val);
-}
+ return __result;
+ }
-#endif /* atomicity.h */
+ void
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/generic/atomic_word.h b/contrib/libstdc++/config/cpu/generic/atomic_word.h
new file mode 100644
index 0000000..b46adc2
--- /dev/null
+++ b/contrib/libstdc++/config/cpu/generic/atomic_word.h
@@ -0,0 +1,35 @@
+// Low-level type for atomic operations -*- C++ -*-
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _GLIBCXX_ATOMIC_WORD_H
+#define _GLIBCXX_ATOMIC_WORD_H 1
+
+typedef int _Atomic_word;
+
+#endif
diff --git a/contrib/libstdc++/config/cpu/generic/atomicity.h b/contrib/libstdc++/config/cpu/generic/atomicity.h
index 829a77c..f30005a 100644
--- a/contrib/libstdc++/config/cpu/generic/atomicity.h
+++ b/contrib/libstdc++/config/cpu/generic/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: Generic version -*- C++ -*-
-// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,51 +27,30 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
+#include <bits/concurrence.h>
-#include <bits/gthr.h>
-
-#define _GLIBCPP_NEED_GENERIC_MUTEX
-
-typedef int _Atomic_word;
-
-namespace __gnu_cxx
-{
- extern __gthread_mutex_t _Atomic_add_mutex;
-
-#ifndef __GTHREAD_MUTEX_INIT
- extern __gthread_once_t _Atomic_add_mutex_once;
- extern void __gthread_atomic_add_mutex_once();
-#endif
-}
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_internal
{
-#ifndef __GTHREAD_MUTEX_INIT
- __gthread_once (&__gnu_cxx::_Atomic_add_mutex_once,
- __gnu_cxx::__gthread_atomic_add_mutex_once);
-#endif
+ __glibcxx_mutex_define_initialized(atomic_mutex);
+} // namespace __gnu_internal
- _Atomic_word __result;
-
- __gthread_mutex_lock (&__gnu_cxx::_Atomic_add_mutex);
-
- __result = *__mem;
- *__mem += __val;
-
- __gthread_mutex_unlock (&__gnu_cxx::_Atomic_add_mutex);
- return __result;
-}
-
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- (void) __exchange_and_add (__mem, __val);
-}
-
-#endif /* atomicity.h */
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ __glibcxx_mutex_lock(__gnu_internal::atomic_mutex);
+ _Atomic_word __result;
+ __result = *__mem;
+ *__mem += __val;
+ __glibcxx_mutex_unlock(__gnu_internal::atomic_mutex);
+ return __result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/hppa/atomicity.h b/contrib/libstdc++/config/cpu/hppa/atomicity.h
index d99ac34..48c8283 100644
--- a/contrib/libstdc++/config/cpu/hppa/atomicity.h
+++ b/contrib/libstdc++/config/cpu/hppa/atomicity.h
@@ -1,90 +1,95 @@
-/* Low-level functions for atomic operations. PA-RISC version. -*- C++ -*-
- Copyright 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
+// Low-level functions for atomic operations: PA-RISC version -*- C++ -*-
- 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.
+// Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, 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.
+// This 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 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. */
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
-typedef int _Atomic_word;
+#include <bits/c++config.h>
+#include <bits/atomicity.h>
-template <int __inst>
-struct __Atomicity_lock
+namespace __gnu_cxx
{
- static volatile int _S_atomicity_lock;
-};
+ template<int _Inst>
+ struct _Atomicity_lock
+ {
+ static volatile int _S_atomicity_lock;
+ };
+
+ template<int _Inst>
+ volatile int
+ _Atomicity_lock<_Inst>::_S_atomicity_lock __attribute__ ((aligned (16))) = 1;
-template <int __inst>
-volatile int
-__Atomicity_lock<__inst>::_S_atomicity_lock __attribute__ ((aligned (16))) = 1;
+ // Because of the lack of weak support when using the hpux som
+ // linker, we explicitly instantiate the atomicity lock.
+ template volatile int _Atomicity_lock<0>::_S_atomicity_lock;
-/* Because of the lack of weak support when using the hpux
- som linker, we explicitly instantiate the atomicity lock
- in src/misc-inst.cc when _GLIBCPP_INST_ATOMICITY_LOCK
- is defined. */
-#ifndef _GLIBCPP_INST_ATOMICITY_LOCK
-template volatile int __Atomicity_lock<0>::_S_atomicity_lock;
-#endif
-
-static inline int
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
-{
- _Atomic_word result;
- int tmp;
- volatile int& lock = __Atomicity_lock<0>::_S_atomicity_lock;
-
- __asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
- "cmpib,<>,n 0,%0,.+20\n\t"
- "ldw 0(%1),%0\n\t"
- "cmpib,= 0,%0,.-4\n\t"
- "nop\n\t"
- "b,n .-20"
- : "=&r" (tmp)
- : "r" (&lock));
-
- result = *__mem;
- *__mem = result + __val;
- /* Reset lock with PA 2.0 "ordered" store. */
- __asm__ __volatile__ ("stw,ma %1,0(%0)"
- : : "r" (&lock), "r" (tmp) : "memory");
- return result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (_Atomic_word* __mem, int __val)
-{
- int tmp;
- volatile int& lock = __Atomicity_lock<0>::_S_atomicity_lock;
-
- __asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
- "cmpib,<>,n 0,%0,.+20\n\t"
- "ldw 0(%1),%0\n\t"
- "cmpib,= 0,%0,.-4\n\t"
- "nop\n\t"
- "b,n .-20"
- : "=&r" (tmp)
- : "r" (&lock));
-
- *__mem += __val;
- /* Reset lock with PA 2.0 "ordered" store. */
- __asm__ __volatile__ ("stw,ma %1,0(%0)"
- : : "r" (&lock), "r" (tmp) : "memory");
-}
-
-#endif
+ int
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word result;
+ int tmp;
+ volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock;
+
+ __asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
+ "cmpib,<>,n 0,%0,.+20\n\t"
+ "ldw 0(%1),%0\n\t"
+ "cmpib,= 0,%0,.-4\n\t"
+ "nop\n\t"
+ "b,n .-20"
+ : "=&r" (tmp)
+ : "r" (&lock));
+
+ result = *__mem;
+ *__mem = result + __val;
+ /* Reset lock with PA 2.0 "ordered" store. */
+ __asm__ __volatile__ ("stw,ma %1,0(%0)"
+ : : "r" (&lock), "r" (tmp) : "memory");
+ return result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ int tmp;
+ volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock;
+
+ __asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
+ "cmpib,<>,n 0,%0,.+20\n\t"
+ "ldw 0(%1),%0\n\t"
+ "cmpib,= 0,%0,.-4\n\t"
+ "nop\n\t"
+ "b,n .-20"
+ : "=&r" (tmp)
+ : "r" (&lock));
+
+ *__mem += __val;
+ /* Reset lock with PA 2.0 "ordered" store. */
+ __asm__ __volatile__ ("stw,ma %1,0(%0)"
+ : : "r" (&lock), "r" (tmp) : "memory");
+ }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/i386/atomicity.h b/contrib/libstdc++/config/cpu/i386/atomicity.h
index d619dbb..92c03d5 100644
--- a/contrib/libstdc++/config/cpu/i386/atomicity.h
+++ b/contrib/libstdc++/config/cpu/i386/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: x86, x >= 3 version -*- C++ -*-
-// Copyright (C) 2003 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,49 +27,48 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-typedef int _Atomic_word;
-
-template <int __inst>
-struct __Atomicity_lock
-{
- static volatile _Atomic_word _S_atomicity_lock;
-};
-
-template <int __inst>
-volatile _Atomic_word __Atomicity_lock<__inst>::_S_atomicity_lock = 0;
-
-template volatile _Atomic_word __Atomicity_lock<0>::_S_atomicity_lock;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- register _Atomic_word __result, __tmp = 1;
-
- /* obtain the atomic exchange/add spin lock */
- do {
- __asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}"
- : "+m" (__Atomicity_lock<0>::_S_atomicity_lock),
- "+r" (__tmp));
- } while (__tmp);
-
- __result = *__mem;
- *__mem += __val;
-
- /* release spin lock */
- __Atomicity_lock<0>::_S_atomicity_lock = 0;
-
- return __result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- __exchange_and_add (__mem, __val);
-}
-
-#endif /* atomicity.h */
+ template<int __inst>
+ struct _Atomicity_lock
+ {
+ static volatile _Atomic_word _S_atomicity_lock;
+ };
+
+ template<int __inst>
+ volatile _Atomic_word _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
+
+ template volatile _Atomic_word _Atomicity_lock<0>::_S_atomicity_lock;
+
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register _Atomic_word __result, __tmp = 1;
+
+ // Obtain the atomic exchange/add spin lock.
+ do
+ {
+ __asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}"
+ : "=m" (_Atomicity_lock<0>::_S_atomicity_lock),
+ "+r" (__tmp)
+ : "m" (_Atomicity_lock<0>::_S_atomicity_lock));
+ }
+ while (__tmp);
+
+ __result = *__mem;
+ *__mem += __val;
+
+ // Release spin lock.
+ _Atomicity_lock<0>::_S_atomicity_lock = 0;
+
+ return __result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/i486/atomicity.h b/contrib/libstdc++/config/cpu/i486/atomicity.h
index 7c65fab..5700bf3 100644
--- a/contrib/libstdc++/config/cpu/i486/atomicity.h
+++ b/contrib/libstdc++/config/cpu/i486/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: x86, x >= 4 version -*- C++ -*-
-// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,31 +27,27 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-typedef int _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- register _Atomic_word __result;
- __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
- : "=r" (__result), "+m" (*__mem)
- : "0" (__val)
- : "memory");
- return __result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}"
- : "+m" (*__mem) : "ir" (__val) : "memory");
-}
-
-#endif /* atomicity.h */
-
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register _Atomic_word __result;
+ __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
+ : "=r" (__result), "=m" (*__mem)
+ : "0" (__val), "m" (*__mem));
+ return __result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ __asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}"
+ : "=m" (*__mem) : "ir" (__val), "m" (*__mem));
+ }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/ia64/atomicity.h b/contrib/libstdc++/config/cpu/ia64/atomicity.h
index e28e149..0c3ab33 100644
--- a/contrib/libstdc++/config/cpu/ia64/atomicity.h
+++ b/contrib/libstdc++/config/cpu/ia64/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: IA64 version -*- C++ -*-
-// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,25 +27,18 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
-
+#include <bits/atomicity.h>
#include <ia64intrin.h>
-typedef int _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- return __sync_fetch_and_add (__mem, __val);
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- __sync_fetch_and_add (__mem, __val);
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ { return __sync_fetch_and_add(__mem, __val); }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ { __sync_fetch_and_add(__mem, __val); }
}
-
-#endif /* atomicity.h */
diff --git a/contrib/libstdc++/config/cpu/m68k/atomicity.h b/contrib/libstdc++/config/cpu/m68k/atomicity.h
index c80e2e3..0e58f3c 100644
--- a/contrib/libstdc++/config/cpu/m68k/atomicity.h
+++ b/contrib/libstdc++/config/cpu/m68k/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: m68k version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,111 +27,107 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
-
-typedef int _Atomic_word;
+#include <bits/atomicity.h>
+namespace __gnu_cxx
+{
#if ( defined(__mc68020__) || defined(__mc68030__) \
|| defined(__mc68040__) || defined(__mc68060__) ) \
&& !defined(__mcpu32__)
-// These variants support compare-and-swap.
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- register _Atomic_word __result = *__mem;
- register _Atomic_word __temp;
- __asm__ __volatile__ ("1: move%.l %0,%1\n\t"
- "add%.l %2,%1\n\t"
- "cas%.l %0,%1,%3\n\t"
- "jne 1b"
- : "=d" (__result), "=&d" (__temp)
- : "d" (__val), "m" (*__mem), "0" (__result)
- : "memory");
- return __result;
-}
+ // These variants support compare-and-swap.
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register _Atomic_word __result = *__mem;
+ register _Atomic_word __temp;
+ __asm__ __volatile__ ("1: move%.l %0,%1\n\t"
+ "add%.l %3,%1\n\t"
+ "cas%.l %0,%1,%2\n\t"
+ "jne 1b"
+ : "=d" (__result), "=&d" (__temp), "=m" (*__mem)
+ : "d" (__val), "0" (__result), "m" (*__mem));
+ return __result;
+ }
#elif defined(__rtems__)
- /*
- * TAS/JBNE is unsafe on systems with strict priority-based scheduling.
- * Disable interrupts, which we can do only from supervisor mode.
- */
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- _Atomic_word __result;
- short __level, __tmpsr;
- __asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w %1,%%sr"
- : "=d"(__level), "=d"(__tmpsr) : "1"(0x700));
-
- __result = *__mem;
- *__mem = __result + __val;
-
- __asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level));
-
- return __result;
-}
+ // TAS/JBNE is unsafe on systems with strict priority-based scheduling.
+ // Disable interrupts, which we can do only from supervisor mode.
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __result;
+ short __level, __tmpsr;
+ __asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w %1,%%sr"
+ : "=d"(__level), "=d"(__tmpsr) : "1"(0x700));
+
+ __result = *__mem;
+ *__mem = __result + __val;
+ __asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level));
+
+ return __result;
+ }
#else
-
-template <int __inst>
-struct __Atomicity_lock
-{
- static volatile unsigned char _S_atomicity_lock;
-};
-
-template <int __inst>
-volatile unsigned char __Atomicity_lock<__inst>::_S_atomicity_lock = 0;
-
-template volatile unsigned char __Atomicity_lock<0>::_S_atomicity_lock;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- _Atomic_word __result;
-
-// bset with no immediate addressing
-#if defined(__mcf5200__) || defined(__mcf5300__) || defined(__mcf5400__)
- __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b"
- : /* no outputs */
- : "a"(&__Atomicity_lock<0>::_S_atomicity_lock)
- : "cc", "memory");
-
-// bset with immediate addressing
-#elif defined(__mc68000__)
- __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
- : "+m"(__Atomicity_lock<0>::_S_atomicity_lock)
- : /* none */
- : "cc");
-
-#else // 680x0, cpu32, 5400 support test-and-set.
- __asm__ __volatile__("1: tas %0\n\tjbne 1b"
- : "+m"(__Atomicity_lock<0>::_S_atomicity_lock)
- : /* none */
- : "cc");
+
+ template<int __inst>
+ struct _Atomicity_lock
+ {
+ static volatile unsigned char _S_atomicity_lock;
+ };
+
+ template<int __inst>
+ volatile unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
+
+ template volatile unsigned char _Atomicity_lock<0>::_S_atomicity_lock;
+
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __result;
+
+ // bset with no immediate addressing (not SMP-safe)
+#if defined(__mcf5200__) || defined(__mcf5300__)
+ __asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b"
+ : /* no outputs */
+ : "a"(&_Atomicity_lock<0>::_S_atomicity_lock)
+ : "cc", "memory");
+
+ // CPU32 and MCF5400 support test-and-set (SMP-safe).
+#elif defined(__mcpu32__) || defined(__mcf5400__)
+ __asm__ __volatile__("1: tas %0\n\tjbne 1b"
+ : "+m"(_Atomicity_lock<0>::_S_atomicity_lock)
+ : /* none */
+ : "cc");
+
+ // Use bset with immediate addressing for 68000/68010 (not SMP-safe)
+ // NOTE: TAS is available on the 68000, but unsupported by some Amiga
+ // memory controllers.
+#else
+ __asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
+ : "+m"(_Atomicity_lock<0>::_S_atomicity_lock)
+ : /* none */
+ : "cc");
#endif
-
- __result = *__mem;
- *__mem = __result + __val;
-
- __Atomicity_lock<0>::_S_atomicity_lock = 0;
-
- return __result;
-}
-
+
+ __result = *__mem;
+ *__mem = __result + __val;
+
+ _Atomicity_lock<0>::_S_atomicity_lock = 0;
+
+ return __result;
+ }
+
#endif /* TAS / BSET */
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
-{
- // Careful: using add.l with a memory destination is not
- // architecturally guaranteed to be atomic.
- (void) __exchange_and_add (__mem, __val);
-}
-
-#endif /* _BITS_ATOMICITY_H */
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ // Careful: using add.l with a memory destination is not
+ // architecturally guaranteed to be atomic.
+ __exchange_and_add(__mem, __val);
+ }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/mips/atomicity.h b/contrib/libstdc++/config/cpu/mips/atomicity.h
index 7bacabd..0871342 100644
--- a/contrib/libstdc++/config/cpu/mips/atomicity.h
+++ b/contrib/libstdc++/config/cpu/mips/atomicity.h
@@ -1,6 +1,6 @@
-// Low-level functions for atomic operations.
+// Low-level functions for atomic operations: MIPS version -*- C++ -*-
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,55 +27,55 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-typedef int _Atomic_word;
-
-static inline int
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
+namespace __gnu_cxx
{
- int __result, __tmp;
-
- __asm__ __volatile__
- ("/* Inline exchange & add */\n\t"
- "1:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %0,%3\n\t"
- "addu %1,%4,%0\n\t"
- "sc %1,%2\n\t"
- ".set pop\n\t"
- "beqz %1,1b\n\t"
- "/* End exchange & add */"
- : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
- : "m" (*__mem), "r"(__val)
- : "memory");
-
- return __result;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word *__mem, int __val)
-{
- int __result;
-
- __asm__ __volatile__
- ("/* Inline atomic add */\n\t"
- "1:\n\t"
- ".set push\n\t"
- ".set mips2\n\t"
- "ll %0,%2\n\t"
- "addu %0,%3,%0\n\t"
- "sc %0,%1\n\t"
- ".set pop\n\t"
- "beqz %0,1b\n\t"
- "/* End atomic add */"
- : "=&r"(__result), "=m"(*__mem)
- : "m" (*__mem), "r"(__val)
- : "memory");
-}
-
-#endif /* atomicity.h */
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __result, __tmp;
+
+ __asm__ __volatile__
+ ("/* Inline exchange & add */\n\t"
+ "1:\n\t"
+ ".set push\n\t"
+#if _MIPS_SIM == _ABIO32
+ ".set mips2\n\t"
+#endif
+ "ll %0,%3\n\t"
+ "addu %1,%4,%0\n\t"
+ "sc %1,%2\n\t"
+ ".set pop\n\t"
+ "beqz %1,1b\n\t"
+ "/* End exchange & add */"
+ : "=&r"(__result), "=&r"(__tmp), "=m"(*__mem)
+ : "m" (*__mem), "r"(__val));
+
+ return __result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __result;
+
+ __asm__ __volatile__
+ ("/* Inline atomic add */\n\t"
+ "1:\n\t"
+ ".set push\n\t"
+#if _MIPS_SIM == _ABIO32
+ ".set mips2\n\t"
+#endif
+ "ll %0,%2\n\t"
+ "addu %0,%3,%0\n\t"
+ "sc %0,%1\n\t"
+ ".set pop\n\t"
+ "beqz %0,1b\n\t"
+ "/* End atomic add */"
+ : "=&r"(__result), "=m"(*__mem)
+ : "m" (*__mem), "r"(__val));
+ }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/powerpc/atomicity.h b/contrib/libstdc++/config/cpu/powerpc/atomicity.h
index b5370fc..7314944 100644
--- a/contrib/libstdc++/config/cpu/powerpc/atomicity.h
+++ b/contrib/libstdc++/config/cpu/powerpc/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: PowerPC version -*- C++ -*-
-// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,8 +27,7 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
#ifdef __PPC405__
#define _STWCX "sync \n\tstwcx. "
@@ -36,43 +35,42 @@
#define _STWCX "stwcx. "
#endif
-typedef int _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
-{
- _Atomic_word __tmp, __res;
- __asm__ __volatile__ (
- "/* Inline exchange & add */\n"
- "0:\t"
- "lwarx %0,0,%2 \n\t"
- "add%I3 %1,%0,%3 \n\t"
- _STWCX " %1,0,%2 \n\t"
- "bne- 0b \n\t"
- "/* End exchange & add */"
- : "=&b"(__res), "=&r"(__tmp)
- : "r" (__mem), "Ir"(__val)
- : "cr0", "memory");
- return __res;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word *__mem, int __val)
+namespace __gnu_cxx
{
- _Atomic_word __tmp;
- __asm__ __volatile__ (
- "/* Inline atomic add */\n"
- "0:\t"
- "lwarx %0,0,%1 \n\t"
- "add%I2 %0,%0,%2 \n\t"
- _STWCX " %0,0,%1 \n\t"
- "bne- 0b \n\t"
- "/* End atomic add */"
- : "=&b"(__tmp)
- : "r" (__mem), "Ir"(__val)
- : "cr0", "memory");
-}
-
-#endif /* atomicity.h */
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __tmp, __res;
+ __asm__ __volatile__ (
+ "/* Inline exchange & add */\n"
+ "0:\t"
+ "lwarx %0,0,%3 \n\t"
+ "add%I4 %1,%0,%4 \n\t"
+ _STWCX " %1,0,%3 \n\t"
+ "bne- 0b \n\t"
+ "/* End exchange & add */"
+ : "=&b"(__res), "=&r"(__tmp), "=m" (*__mem)
+ : "r" (__mem), "Ir"(__val), "m" (*__mem)
+ : "cr0");
+ return __res;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __tmp;
+ __asm__ __volatile__ (
+ "/* Inline atomic add */\n"
+ "0:\t"
+ "lwarx %0,0,%2 \n\t"
+ "add%I3 %0,%0,%3 \n\t"
+ _STWCX " %0,0,%2 \n\t"
+ "bne- 0b \n\t"
+ "/* End atomic add */"
+ : "=&b"(__tmp), "=m" (*__mem)
+ : "r" (__mem), "Ir"(__val), "m" (*__mem)
+ : "cr0");
+ }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/s390/atomicity.h b/contrib/libstdc++/config/cpu/s390/atomicity.h
index 331c29a..b979e3a 100644
--- a/contrib/libstdc++/config/cpu/s390/atomicity.h
+++ b/contrib/libstdc++/config/cpu/s390/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: S/390 version -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,34 +27,28 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-typedef int _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- register _Atomic_word __old_val, __new_val;
-
- __asm__ __volatile__ (" l %0,0(%2)\n"
- "0: lr %1,%0\n"
- " ar %1,%3\n"
- " cs %0,%1,0(%2)\n"
- " jl 0b"
- : "=&d" (__old_val), "=&d" (__new_val)
- : "a" (__mem), "d" (__val) : "cc", "memory" );
- return __old_val;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word *__mem, int __val)
+namespace __gnu_cxx
{
- __exchange_and_add (__mem, __val);
-}
-
-#endif /* atomicity.h */
-
-
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ register _Atomic_word __old_val, __new_val;
+
+ __asm__ __volatile__ (" l %0,0(%3)\n"
+ "0: lr %1,%0\n"
+ " ar %1,%4\n"
+ " cs %0,%1,0(%3)\n"
+ " jl 0b"
+ : "=&d" (__old_val), "=&d" (__new_val), "=m" (*__mem)
+ : "a" (__mem), "d" (__val), "m" (*__mem) : "cc");
+ return __old_val;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/contrib/libstdc++/config/cpu/sparc/atomic_word.h b/contrib/libstdc++/config/cpu/sparc/atomic_word.h
new file mode 100644
index 0000000..941fddd
--- /dev/null
+++ b/contrib/libstdc++/config/cpu/sparc/atomic_word.h
@@ -0,0 +1,39 @@
+// Low-level type for atomic operations -*- C++ -*-
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _GLIBCXX_ATOMIC_WORD_H
+#define _GLIBCXX_ATOMIC_WORD_H 1
+
+#ifdef __arch64__
+ typedef long _Atomic_word;
+#else
+ typedef int _Atomic_word;
+#endif
+
+#endif
diff --git a/contrib/libstdc++/config/cpu/sparc/atomicity.h b/contrib/libstdc++/config/cpu/sparc/atomicity.h
index 23804db..a39153b 100644
--- a/contrib/libstdc++/config/cpu/sparc/atomicity.h
+++ b/contrib/libstdc++/config/cpu/sparc/atomicity.h
@@ -1,6 +1,6 @@
// Low-level functions for atomic operations: Sparc version -*- C++ -*-
-// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -27,105 +27,99 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-#ifndef _BITS_ATOMICITY_H
-#define _BITS_ATOMICITY_H 1
+#include <bits/atomicity.h>
-#ifdef __arch64__
-
-typedef long _Atomic_word;
-
-static inline _Atomic_word
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word *__mem, int __val)
-{
- _Atomic_word __tmp1, __tmp2;
-
- __asm__ __volatile__("1: ldx [%2], %0\n\t"
- " add %0, %3, %1\n\t"
- " casx [%2], %0, %1\n\t"
- " sub %0, %1, %0\n\t"
- " brnz,pn %0, 1b\n\t"
- " nop"
- : "=&r" (__tmp1), "=&r" (__tmp2)
- : "r" (__mem), "r" (__val)
- : "memory");
- return __tmp2;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
{
- _Atomic_word __tmp1, __tmp2;
-
- __asm__ __volatile__("1: ldx [%2], %0\n\t"
- " add %0, %3, %1\n\t"
- " casx [%2], %0, %1\n\t"
- " sub %0, %1, %0\n\t"
- " brnz,pn %0, 1b\n\t"
- " nop"
- : "=&r" (__tmp1), "=&r" (__tmp2)
- : "r" (__mem), "r" (__val)
- : "memory");
-}
-
+#ifdef __arch64__
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __tmp1, __tmp2;
+ _Atomic_word __val_extended = __val;
+
+ __asm__ __volatile__("1: ldx [%3], %0\n\t"
+ " add %0, %4, %1\n\t"
+ " casx [%3], %0, %1\n\t"
+ " sub %0, %1, %0\n\t"
+ " brnz,pn %0, 1b\n\t"
+ " nop"
+ : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
+ : "r" (__mem), "r" (__val_extended), "m" (*__mem));
+ return __tmp2;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __tmp1, __tmp2;
+ _Atomic_word __val_extended = __val;
+
+ __asm__ __volatile__("1: ldx [%3], %0\n\t"
+ " add %0, %4, %1\n\t"
+ " casx [%3], %0, %1\n\t"
+ " sub %0, %1, %0\n\t"
+ " brnz,pn %0, 1b\n\t"
+ " nop"
+ : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
+ : "r" (__mem), "r" (__val_extended), "m" (*__mem));
+ }
+
#else /* __arch32__ */
-typedef int _Atomic_word;
-
-template <int __inst>
-struct __Atomicity_lock
-{
- static unsigned char _S_atomicity_lock;
-};
-
-template <int __inst>
-unsigned char __Atomicity_lock<__inst>::_S_atomicity_lock = 0;
-
-template unsigned char __Atomicity_lock<0>::_S_atomicity_lock;
-
-static int
-__attribute__ ((__unused__))
-__exchange_and_add (volatile _Atomic_word* __mem, int __val)
-{
- _Atomic_word __result, __tmp;
-
- __asm__ __volatile__("1: ldstub [%1], %0\n\t"
- " cmp %0, 0\n\t"
- " bne 1b\n\t"
- " nop"
- : "=&r" (__tmp)
- : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
- : "memory");
- __result = *__mem;
- *__mem += __val;
- __asm__ __volatile__("stb %%g0, [%0]"
- : /* no outputs */
- : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
- : "memory");
- return __result;
-}
-
-static void
-__attribute__ ((__unused__))
-__atomic_add (volatile _Atomic_word* __mem, int __val)
-{
- _Atomic_word __tmp;
-
- __asm__ __volatile__("1: ldstub [%1], %0\n\t"
- " cmp %0, 0\n\t"
- " bne 1b\n\t"
- " nop"
- : "=&r" (__tmp)
- : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
- : "memory");
- *__mem += __val;
- __asm__ __volatile__("stb %%g0, [%0]"
- : /* no outputs */
- : "r" (&__Atomicity_lock<0>::_S_atomicity_lock)
- : "memory");
-}
-
+ template<int __inst>
+ struct _Atomicity_lock
+ {
+ static unsigned char _S_atomicity_lock;
+ };
+
+ template<int __inst>
+ unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
+
+ template unsigned char _Atomicity_lock<0>::_S_atomicity_lock;
+
+ _Atomic_word
+ __attribute__ ((__unused__))
+ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __result, __tmp;
+
+ __asm__ __volatile__("1: ldstub [%1], %0\n\t"
+ " cmp %0, 0\n\t"
+ " bne 1b\n\t"
+ " nop"
+ : "=&r" (__tmp)
+ : "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
+ : "memory");
+ __result = *__mem;
+ *__mem += __val;
+ __asm__ __volatile__("stb %%g0, [%0]"
+ : /* no outputs */
+ : "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
+ : "memory");
+ return __result;
+ }
+
+ void
+ __attribute__ ((__unused__))
+ __atomic_add(volatile _Atomic_word* __mem, int __val)
+ {
+ _Atomic_word __tmp;
+
+ __asm__ __volatile__("1: ldstub [%1], %0\n\t"
+ " cmp %0, 0\n\t"
+ " bne 1b\n\t"
+ " nop"
+ : "=&r" (__tmp)
+ : "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
+ : "memory");
+ *__mem += __val;
+ __asm__ __volatile__("stb %%g0, [%0]"
+ : /* no outputs */
+ : "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
+ : "memory");
+ }
#endif /* __arch32__ */
-
-#endif /* atomicity.h */
+} // namespace __gnu_cxx
OpenPOWER on IntegriCloud