From 2c5d0ae842f692b1456cf53d2734457a8f43194f Mon Sep 17 00:00:00 2001
From: Benjamin Kosnik <bkoz@redhat.com>
Date: Fri, 27 Feb 2004 00:49:50 +0000
Subject: [PATCH] atomicity.h: New, forward declarations for __atomic_add and
 __exchange_and_add.

2004-02-25  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/atomicity.h: New, forward declarations for __atomic_add
	and __exchange_and_add.
	* config/cpu/generic/atomic_word.h: New, typdef for atomic word.
	* config/cpu/cris/atomic_word.h: Same.
	* config/cpu/sparc/atomic_word.h: Same.
	* include/bits/ios_base.h (_Callback_list::_M_remove_reference):
	Qualifiy with __gnu_cxx.
	(_Callback_list::_M_add_reference): Same.
	* include/bits/locale_classes.h (locale::facet::_M_add_reference): Add.
	(locale::facet::_M_remove_reference): Same.
	(locale::_Impl::_M_add_reference): Add.
	(locale::_Impl::_M_remove_reference): Same.
	* include/bits/basic_string.h (basic_string::_Rep::_M_refcopy): Same.
	(basic_string::_Rep::_M_dispose): Same.
	* src/ios.cc (ios_base::xalloc): Same.
	* src/ios_init.cc (ios_base::Init::Init): Same.
	(ios_base::Init::~Init): Same.
	* src/locale.cc (locale::id::_M_id): Same.
	* config/cpu/i486/atomicity.h: Use __gnu_cxx namespace. Remove
	static, and inline keyworks.
	* config/cpu/alpha/atomicity.h: Same.
	* config/cpu/cris/atomicity.h: Same.
	* config/cpu/generic/atomicity.h: Same.
	* config/cpu/hppa/atomicity.h: Same.
	* config/cpu/i386/atomicity.h: Same.
	* config/cpu/ia64/atomicity.h: Same.
	* config/cpu/m68k/atomicity.h: Same.
	* config/cpu/mips/atomicity.h: Same.
	* config/cpu/powerpc/atomicity.h: Same.
	* config/cpu/s390/atomicity.h: Same.
	* config/cpu/sparc/atomicity.h: Same.

	* src/Makefile.am (host_sources): Add atomicity.cc.
	(atomicity.cc): New rule.
	* src/Makefile.in: Regenerate.
	* include/Makefile.am (host_headers): Remove host atomicity.h.
	(host_headers): Add atomic_word.h.
	(bits_headers): Add bits atomicity.h.
	Change ATOMICITY_INC_SRCDIR to ATOMICITY_SRCDIR.
	* include/Makefile.in: Regenerate.
	* configure.host (atomic_word_dir): Add.
	* configure.ac: Substitute ATOMIC_WORD_SRCDIR. Change
	ATOMICITY_INC_SRCDIR to ATOMICITY_SRCDIR.
	* configure: Regenerate.
	* config/linker-map.gnu: Export __exchange_and_add, and __atomic_add.

	* testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust line numbers.
	* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.

From-SVN: r78544
---
 libstdc++-v3/ChangeLog                        |  51 +++++
 libstdc++-v3/aclocal.m4                       |   4 +-
 libstdc++-v3/config/cpu/alpha/atomicity.h     |  41 ++--
 libstdc++-v3/config/cpu/cris/atomic_word.h    |  36 ++++
 libstdc++-v3/config/cpu/cris/atomicity.h      |  41 ++--
 libstdc++-v3/config/cpu/generic/atomic_word.h |  35 ++++
 libstdc++-v3/config/cpu/generic/atomicity.h   |  51 ++---
 libstdc++-v3/config/cpu/hppa/atomicity.h      | 166 ++++++++--------
 libstdc++-v3/config/cpu/i386/atomicity.h      |  90 ++++-----
 libstdc++-v3/config/cpu/i486/atomicity.h      |  45 ++---
 libstdc++-v3/config/cpu/ia64/atomicity.h      |  31 ++-
 libstdc++-v3/config/cpu/m68k/atomicity.h      | 186 +++++++++--------
 libstdc++-v3/config/cpu/mips/atomicity.h      |  96 +++++----
 libstdc++-v3/config/cpu/powerpc/atomicity.h   |  82 ++++----
 libstdc++-v3/config/cpu/s390/atomicity.h      |  54 +++--
 libstdc++-v3/config/cpu/sparc/atomic_word.h   |  39 ++++
 libstdc++-v3/config/cpu/sparc/atomicity.h     | 188 +++++++++---------
 libstdc++-v3/config/linker-map.gnu            |   8 +-
 libstdc++-v3/configure                        |  11 +-
 libstdc++-v3/configure.ac                     |   8 +-
 libstdc++-v3/configure.host                   |  31 ++-
 libstdc++-v3/include/Makefile.am              |   3 +-
 libstdc++-v3/include/Makefile.in              |   8 +-
 libstdc++-v3/include/bits/atomicity.h         |  46 +++++
 libstdc++-v3/include/bits/basic_string.h      |   4 +-
 libstdc++-v3/include/bits/ios_base.h          |   7 +-
 libstdc++-v3/include/bits/locale_classes.h    |   8 +-
 libstdc++-v3/src/Makefile.am                  |   7 +-
 libstdc++-v3/src/Makefile.in                  |  27 ++-
 libstdc++-v3/src/ios.cc                       |   4 +-
 libstdc++-v3/src/ios_init.cc                  |   8 +-
 libstdc++-v3/src/locale.cc                    |   4 +-
 .../27_io/ios_base/cons/assign_neg.cc         |   4 +-
 .../testsuite/27_io/ios_base/cons/copy_neg.cc |   4 +-
 34 files changed, 811 insertions(+), 617 deletions(-)
 create mode 100644 libstdc++-v3/config/cpu/cris/atomic_word.h
 create mode 100644 libstdc++-v3/config/cpu/generic/atomic_word.h
 create mode 100644 libstdc++-v3/config/cpu/sparc/atomic_word.h
 create mode 100644 libstdc++-v3/include/bits/atomicity.h

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a09a97d4aeeb..39782cd3d796 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,54 @@
+2004-02-25  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* include/bits/atomicity.h: New, forward declarations for __atomic_add
+	and __exchange_and_add.
+	* config/cpu/generic/atomic_word.h: New, typdef for atomic word.
+	* config/cpu/cris/atomic_word.h: Same.
+	* config/cpu/sparc/atomic_word.h: Same.
+	* include/bits/ios_base.h (_Callback_list::_M_remove_reference):
+	Qualifiy with __gnu_cxx.
+	(_Callback_list::_M_add_reference): Same.
+	* include/bits/locale_classes.h (locale::facet::_M_add_reference): Add.
+	(locale::facet::_M_remove_reference): Same.
+	(locale::_Impl::_M_add_reference): Add.
+	(locale::_Impl::_M_remove_reference): Same.
+	* include/bits/basic_string.h (basic_string::_Rep::_M_refcopy): Same.
+	(basic_string::_Rep::_M_dispose): Same.
+	* src/ios.cc (ios_base::xalloc): Same.
+	* src/ios_init.cc (ios_base::Init::Init): Same.
+	(ios_base::Init::~Init): Same.
+	* src/locale.cc (locale::id::_M_id): Same.
+	* config/cpu/i486/atomicity.h: Use __gnu_cxx namespace. Remove
+	static, and inline keyworks.
+	* config/cpu/alpha/atomicity.h: Same.
+	* config/cpu/cris/atomicity.h: Same.
+	* config/cpu/generic/atomicity.h: Same.
+	* config/cpu/hppa/atomicity.h: Same.
+	* config/cpu/i386/atomicity.h: Same.
+	* config/cpu/ia64/atomicity.h: Same.
+	* config/cpu/m68k/atomicity.h: Same.
+	* config/cpu/mips/atomicity.h: Same.
+	* config/cpu/powerpc/atomicity.h: Same.
+	* config/cpu/s390/atomicity.h: Same.
+	* config/cpu/sparc/atomicity.h: Same.
+	
+	* src/Makefile.am (host_sources): Add atomicity.cc.
+	(atomicity.cc): New rule.
+	* src/Makefile.in: Regenerate.
+	* include/Makefile.am (host_headers): Remove host atomicity.h.
+	(host_headers): Add atomic_word.h.
+	(bits_headers): Add bits atomicity.h.
+	Change ATOMICITY_INC_SRCDIR to ATOMICITY_SRCDIR.
+	* include/Makefile.in: Regenerate.
+	* configure.host (atomic_word_dir): Add.
+	* configure.ac: Substitute ATOMIC_WORD_SRCDIR. Change
+	ATOMICITY_INC_SRCDIR to ATOMICITY_SRCDIR.
+	* configure: Regenerate.
+	* config/linker-map.gnu: Export __exchange_and_add, and __atomic_add.
+
+	* testsuite/27_io/ios_base/cons/assign_neg.cc: Adjust line numbers.
+	* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.	
+	
 2004-02-25  Jonathan Wakely  <redi@gcc.gnu.org>
 
 	* docs/html/20_util/howto.html, docs/html/20_util/allocator.html,
diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4
index 723aa803fa7c..5be03557f9ed 100644
--- a/libstdc++-v3/aclocal.m4
+++ b/libstdc++-v3/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.7.9 -*- Autoconf -*-
+# generated automatically by aclocal 1.7.8 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
@@ -1997,7 +1997,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.7.9])])
+	 [AM_AUTOMAKE_VERSION([1.7.8])])
 
 # Helper functions for option handling.                    -*- Autoconf -*-
 
diff --git a/libstdc++-v3/config/cpu/alpha/atomicity.h b/libstdc++-v3/config/cpu/alpha/atomicity.h
index cb071cdae971..4eb311b509a4 100644
--- a/libstdc++-v3/config/cpu/alpha/atomicity.h
+++ b/libstdc++-v3/config/cpu/alpha/atomicity.h
@@ -1,6 +1,6 @@
 // Low-level functions for atomic operations: Alpha version  -*- C++ -*-
 
-// Copyright (C) 1999, 2000, 2001, 2003 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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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/libstdc++-v3/config/cpu/cris/atomic_word.h b/libstdc++-v3/config/cpu/cris/atomic_word.h
new file mode 100644
index 000000000000..dd2cf6b834bb
--- /dev/null
+++ b/libstdc++-v3/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/libstdc++-v3/config/cpu/cris/atomicity.h b/libstdc++-v3/config/cpu/cris/atomicity.h
index fecb9dc186f4..965e0da6ea01 100644
--- a/libstdc++-v3/config/cpu/cris/atomicity.h
+++ b/libstdc++-v3/config/cpu/cris/atomicity.h
@@ -1,6 +1,6 @@
 // Low-level functions for atomic operations: CRIS version  -*- C++ -*-
 
-// Copyright (C) 2001, 2003 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,19 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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;
+  static inline _Atomic_word
+  __attribute__ ((__unused__))
+  __exchange_and_add(_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"
@@ -53,7 +51,7 @@ __exchange_and_add(_Atomic_word* __mem, int __val)
 			:  "=&r" (__result), "=m" (*__mem), "=&r" (__tmp)
 			: "r" (__mem), "g" (__val), "m" (*__mem));
 #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"
@@ -65,14 +63,11 @@ __exchange_and_add(_Atomic_word* __mem, int __val)
 			: "r9");
 #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
+  __attribute__ ((__unused__))
+  __atomic_add(_Atomic_word* __mem, int __val)
+  { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/libstdc++-v3/config/cpu/generic/atomic_word.h b/libstdc++-v3/config/cpu/generic/atomic_word.h
new file mode 100644
index 000000000000..b46adc2a4743
--- /dev/null
+++ b/libstdc++-v3/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/libstdc++-v3/config/cpu/generic/atomicity.h b/libstdc++-v3/config/cpu/generic/atomicity.h
index 1bee9ea6b0c6..84817903bf5f 100644
--- a/libstdc++-v3/config/cpu/generic/atomicity.h
+++ b/libstdc++-v3/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,15 +27,11 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_ATOMICITY_H	1
-
+#include <bits/atomicity.h>
 #include <bits/gthr.h>
 
 #define _GLIBCXX_NEED_GENERIC_MUTEX
 
-typedef int _Atomic_word;
-
 namespace __gnu_cxx
 {
   extern __gthread_mutex_t _Atomic_add_mutex;
@@ -44,34 +40,27 @@ namespace __gnu_cxx
   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)
-{
+  _Atomic_word
+  __attribute__ ((__unused__))
+  __exchange_and_add(volatile _Atomic_word* __mem, int __val)
+  {
 #ifndef __GTHREAD_MUTEX_INIT
-  __gthread_once(&__gnu_cxx::_Atomic_add_mutex_once,
-		 __gnu_cxx::__gthread_atomic_add_mutex_once);
+    __gthread_once(&__gnu_cxx::_Atomic_add_mutex_once,
+		   __gnu_cxx::__gthread_atomic_add_mutex_once);
 #endif
 
-  _Atomic_word __result;
-
-  __gthread_mutex_lock(&__gnu_cxx::_Atomic_add_mutex);
+    _Atomic_word __result;
+    __gthread_mutex_lock(&__gnu_cxx::_Atomic_add_mutex);
+    __result = *__mem;
+    *__mem += __val;
 
-  __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)
-{
-  (void) __exchange_and_add(__mem, __val);
-}
+    __gthread_mutex_unlock(&__gnu_cxx::_Atomic_add_mutex);
+    return __result;
+  }
 
-#endif /* atomicity.h */
+  void
+  __attribute__ ((__unused__))
+  __atomic_add(volatile _Atomic_word* __mem, int __val)
+  { __exchange_and_add(__mem, __val); }
+} // namespace __gnu_cxx
diff --git a/libstdc++-v3/config/cpu/hppa/atomicity.h b/libstdc++-v3/config/cpu/hppa/atomicity.h
index b07414246af0..4e0c2525a709 100644
--- a/libstdc++-v3/config/cpu/hppa/atomicity.h
+++ b/libstdc++-v3/config/cpu/hppa/atomicity.h
@@ -1,90 +1,98 @@
-/* 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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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/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
-   in src/misc-inst.cc when _GLIBCXX_INST_ATOMICITY_LOCK
-   is defined.  */
+  /* 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 _GLIBCXX_INST_ATOMICITY_LOCK
+     is defined.  */
 #ifndef _GLIBCXX_INST_ATOMICITY_LOCK
-template volatile int __Atomicity_lock<0>::_S_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(_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/libstdc++-v3/config/cpu/i386/atomicity.h b/libstdc++-v3/config/cpu/i386/atomicity.h
index 7a949c30fa5f..968bd249db2d 100644
--- a/libstdc++-v3/config/cpu/i386/atomicity.h
+++ b/libstdc++-v3/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,50 +27,48 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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)
+namespace __gnu_cxx
 {
-  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;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add(volatile _Atomic_word* __mem, int __val)
-{
-  __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/libstdc++-v3/config/cpu/i486/atomicity.h b/libstdc++-v3/config/cpu/i486/atomicity.h
index 06ab866bbe39..5700bf39a7f2 100644
--- a/libstdc++-v3/config/cpu/i486/atomicity.h
+++ b/libstdc++-v3/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,28 +27,27 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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), "m" (*__mem));
-  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), "m" (*__mem));
-}
+  _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
 
-#endif /* atomicity.h */
diff --git a/libstdc++-v3/config/cpu/ia64/atomicity.h b/libstdc++-v3/config/cpu/ia64/atomicity.h
index 4408d06718d9..0c3ab3343e92 100644
--- a/libstdc++-v3/config/cpu/ia64/atomicity.h
+++ b/libstdc++-v3/config/cpu/ia64/atomicity.h
@@ -1,6 +1,6 @@
 // Low-level functions for atomic operations: IA64 version  -*- C++ -*-
 
-// Copyright (C) 2000, 2001, 2003 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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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/libstdc++-v3/config/cpu/m68k/atomicity.h b/libstdc++-v3/config/cpu/m68k/atomicity.h
index eb801dec50cf..b5827320c801 100644
--- a/libstdc++-v3/config/cpu/m68k/atomicity.h
+++ b/libstdc++-v3/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,113 +27,107 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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 %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;
-}
+  // 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
+  
+  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)
   {
-    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 (not SMP-safe)
+    _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).
+    __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.
+    __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");
+    __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 /* !_GLIBCXX_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/libstdc++-v3/config/cpu/mips/atomicity.h b/libstdc++-v3/config/cpu/mips/atomicity.h
index 3d0c7a10e092..087134289de7 100644
--- a/libstdc++-v3/config/cpu/mips/atomicity.h
+++ b/libstdc++-v3/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, 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,57 +27,55 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-#ifndef _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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"
+  _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"
+       ".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;
-}
-
-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"
+       "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"
+       ".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)
+       "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));
-}
-
-#endif /* atomicity.h */
+  }
+} // namespace __gnu_cxx
diff --git a/libstdc++-v3/config/cpu/powerpc/atomicity.h b/libstdc++-v3/config/cpu/powerpc/atomicity.h
index 3b44b7daf929..73149441dd83 100644
--- a/libstdc++-v3/config/cpu/powerpc/atomicity.h
+++ b/libstdc++-v3/config/cpu/powerpc/atomicity.h
@@ -1,6 +1,6 @@
 // Low-level functions for atomic operations: PowerPC version  -*- C++ -*-
 
-// Copyright (C) 1999, 2000, 2001, 2003 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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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,%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;
-}
-
-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,%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");
-}
-
-#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/libstdc++-v3/config/cpu/s390/atomicity.h b/libstdc++-v3/config/cpu/s390/atomicity.h
index 8647c7635eab..b979e3abd33c 100644
--- a/libstdc++-v3/config/cpu/s390/atomicity.h
+++ b/libstdc++-v3/config/cpu/s390/atomicity.h
@@ -1,6 +1,6 @@
 // Low-level functions for atomic operations: S/390 version  -*- C++ -*-
 
-// Copyright (C) 2001, 2003 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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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(%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;
-}
-
-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/libstdc++-v3/config/cpu/sparc/atomic_word.h b/libstdc++-v3/config/cpu/sparc/atomic_word.h
new file mode 100644
index 000000000000..941fddd2b0e5
--- /dev/null
+++ b/libstdc++-v3/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/libstdc++-v3/config/cpu/sparc/atomicity.h b/libstdc++-v3/config/cpu/sparc/atomicity.h
index 2db079c95ec0..6d4b19b75bd9 100644
--- a/libstdc++-v3/config/cpu/sparc/atomicity.h
+++ b/libstdc++-v3/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 _GLIBCXX_ATOMICITY_H
-#define _GLIBCXX_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;
-  _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;
-}
-
-static inline void
-__attribute__ ((__unused__))
-__atomic_add(volatile _Atomic_word* __mem, int __val)
+namespace __gnu_cxx
 {
-  _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));
-}
-
+#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
+  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)
   {
-    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");
-}
-
+    _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
diff --git a/libstdc++-v3/config/linker-map.gnu b/libstdc++-v3/config/linker-map.gnu
index 27227b30ee5a..c8be24240702 100644
--- a/libstdc++-v3/config/linker-map.gnu
+++ b/libstdc++-v3/config/linker-map.gnu
@@ -214,10 +214,10 @@ GLIBCXX_3.4 {
     # __gnu_cxx::stdio_sync_filebuf
     _ZTVN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE;
 
-    # Needed only when generic cpu's atomicity.h is in use.
-    _ZN9__gnu_cxx17_Atomic_add_mutexE;
-    _ZN9__gnu_cxx22_Atomic_add_mutex_onceE;
-    _ZN9__gnu_cxx31__gthread_atomic_add_mutex_onceEv;
+    # __gnu_cxx::__atomic_add
+    # __gnu_cxx::__exchange_and_add
+    _ZN9__gnu_cxx12__atomic_addEPVii;
+    _ZN9__gnu_cxx18__exchange_and_addEPVii;
 
   # DO NOT DELETE THIS LINE.  Port-specific symbols, if any, will be here.
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 9fd8dc1e3edf..538dea2b4474 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -308,7 +308,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CCODECVT_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_INC_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CCODECVT_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_SRCDIR ATOMIC_WORD_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -7439,7 +7439,7 @@ echo "${ECHO_T}$EXTRA_CXX_FLAGS" >&6
 
 
 # No surprises, no surprises...
-if test $atomicity_include_dir = cpu/generic ; then
+if test $atomicity_dir = cpu/generic ; then
   { echo "$as_me:$LINENO: WARNING: No native atomic operations are provided for this platform." >&5
 echo "$as_me: WARNING: No native atomic operations are provided for this platform." >&2;}
   if test $target_thread_file = single; then
@@ -64090,11 +64090,13 @@ done
 # Propagate the target-specific source directories through the build chain.
 # (Nothing currently uses cpu_include_dir directly; only atomicity_include_dir
 # uses it, and it only gets used in this file.)
-ATOMICITY_INC_SRCDIR=config/${atomicity_include_dir}
+ATOMICITY_SRCDIR=config/${atomicity_dir}
+ATOMIC_WORD_SRCDIR=config/${atomic_word_dir}
 OS_INC_SRCDIR=config/${os_include_dir}
 
 
 
+
 # Determine cross-compile flags and AM_CONDITIONALs.
 #AC_SUBST(GLIBCXX_IS_NATIVE)
 #AM_CONDITIONAL(CANADIAN, test $CANADIAN = yes)
@@ -65233,7 +65235,8 @@ s,@GLIBCXX_TEST_WCHAR_T_TRUE@,$GLIBCXX_TEST_WCHAR_T_TRUE,;t t
 s,@GLIBCXX_TEST_WCHAR_T_FALSE@,$GLIBCXX_TEST_WCHAR_T_FALSE,;t t
 s,@GLIBCXX_TEST_ABI_TRUE@,$GLIBCXX_TEST_ABI_TRUE,;t t
 s,@GLIBCXX_TEST_ABI_FALSE@,$GLIBCXX_TEST_ABI_FALSE,;t t
-s,@ATOMICITY_INC_SRCDIR@,$ATOMICITY_INC_SRCDIR,;t t
+s,@ATOMICITY_SRCDIR@,$ATOMICITY_SRCDIR,;t t
+s,@ATOMIC_WORD_SRCDIR@,$ATOMIC_WORD_SRCDIR,;t t
 s,@OS_INC_SRCDIR@,$OS_INC_SRCDIR,;t t
 s,@glibcxx_prefixdir@,$glibcxx_prefixdir,;t t
 s,@gxx_include_dir@,$gxx_include_dir,;t t
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index baf8d7f4b59c..006c9941b475 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -95,7 +95,7 @@ GLIBCXX_ENABLE_DEBUG([no])
 GLIBCXX_ENABLE_CXX_FLAGS
 
 # No surprises, no surprises...
-if test $atomicity_include_dir = cpu/generic ; then
+if test $atomicity_dir = cpu/generic ; then
   AC_MSG_WARN([No native atomic operations are provided for this platform.])
   if test $target_thread_file = single; then
     AC_MSG_WARN([They cannot be faked when thread support is disabled.])
@@ -268,9 +268,11 @@ GLIBCXX_CONFIGURE_TESTSUITE
 # Propagate the target-specific source directories through the build chain.
 # (Nothing currently uses cpu_include_dir directly; only atomicity_include_dir 
 # uses it, and it only gets used in this file.)
-ATOMICITY_INC_SRCDIR=config/${atomicity_include_dir}
+ATOMICITY_SRCDIR=config/${atomicity_dir}
+ATOMIC_WORD_SRCDIR=config/${atomic_word_dir}
 OS_INC_SRCDIR=config/${os_include_dir}
-AC_SUBST(ATOMICITY_INC_SRCDIR)
+AC_SUBST(ATOMICITY_SRCDIR)
+AC_SUBST(ATOMIC_WORD_SRCDIR)
 AC_SUBST(OS_INC_SRCDIR)
 
 # Determine cross-compile flags and AM_CONDITIONALs.
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index a3d32325db2f..f6492b29e5ef 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -30,9 +30,12 @@
 #   abi_baseline_pair      directory name for ABI compat testing,
 #                          defaults to host_cpu-host_os (as per config.guess)
 #
-#   atomicity_include_dir  location of atomicity.h,
+#   atomicity_dir          location of atomicity.h,
 #                          defaults to cpu_include_dir
 #
+#   atomic_word_dir        location of atomic_word.h
+#                          defaults to generic.
+#
 # It possibly modifies the following variables:
 #
 #   OPT_LDFLAGS            extra flags to pass when linking the library, of
@@ -57,6 +60,7 @@
 # systems out there.  :-)
 c_model=c_std
 c_compatibility=no
+atomic_word_dir=cpu/generic
 
 # HOST-SPECIFIC OVERRIDES
 # Set any CPU-dependent bits.
@@ -102,11 +106,22 @@ case "${host_cpu}" in
     ;;
 esac
 
+# Set specific CPU overrides for atomic_word_dir. Most can just use generic.
+# THIS TABLE IS SORTED.  KEEP IT THAT WAY.
+case "${host_cpu}" in
+  cris*)
+    atomic_word_dir=cpu/cris
+    ;;
+  sparc* | ultrasparc)
+    atomic_word_dir=cpu/sparc
+    ;;
+esac
+
 # Now look for the file(s) usually tied to a CPU model, and make
 # default choices for those if they haven't been explicitly set
 # already.  
 cpu_include_dir="cpu/${try_cpu}"
-atomicity_include_dir=$cpu_include_dir
+atomicity_dir=$cpu_include_dir
 abi_baseline_pair=${try_cpu}-${host_os}
 
 
@@ -122,16 +137,16 @@ case "${host_os}" in
     # os/aix/atomicity.h works on earlier versions of AIX 4.*, so we
     # explicitly duplicate the directory for 4.[<3].
     os_include_dir="os/aix"
-    atomicity_include_dir="os/aix"
+    atomicity_dir="os/aix"
     OPT_LDFLAGS="-Wl,-G"
     ;;
   aix4.*)
     os_include_dir="os/generic"
-    atomicity_include_dir="os/aix"
+    atomicity_dir="os/aix"
     ;;
   aix*)
     os_include_dir="os/generic"
-    atomicity_include_dir="cpu/generic"
+    atomicity_dir="cpu/generic"
     ;;
   bsd*)
     # Plain BSD attempts to share FreeBSD files.
@@ -155,11 +170,11 @@ case "${host_os}" in
   irix[1-6] | irix[1-5].* | irix6.[0-4]*)
     # This is known to work on at least IRIX 5.2 and 6.3.
     os_include_dir="os/irix/irix5.2"
-    atomicity_include_dir=$os_include_dir
+    atomicity_dir=$os_include_dir
     ;;
   irix6.5*)
     os_include_dir="os/irix/irix6.5"
-    atomicity_include_dir=$os_include_dir
+    atomicity_dir=$os_include_dir
     ;;
   mingw32*)
     os_include_dir="os/mingw32"
@@ -205,7 +220,7 @@ esac
 # THIS TABLE IS SORTED.  KEEP IT THAT WAY.
 case "${host}" in
   mips*-*-linux*)
-    atomicity_include_dir="cpu/mips"
+    atomicity_dir="cpu/mips"
     ;;
   x86_64-*-linux*)
     abi_baseline_pair="x86_64-linux-gnu"
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index f95c1a021c1c..b6b05ff30d8f 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -92,6 +92,7 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
 bits_builddir = ./bits
 bits_headers = \
 	${bits_srcdir}/allocator.h \
+	${bits_srcdir}/atomicity.h \
 	${bits_srcdir}/basic_ios.h \
 	${bits_srcdir}/basic_ios.tcc \
 	${bits_srcdir}/basic_string.h \
@@ -339,7 +340,7 @@ host_headers = \
 	${host_srcdir}/ctype_inline.h \
 	${host_srcdir}/ctype_noninline.h \
 	${host_srcdir}/os_defines.h \
-	${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h 
+	${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h 
 
 # Non-installed host_header files.
 host_headers_noinst = \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 8ab2f7babfac..e0fa5c06c7b7 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -42,7 +42,8 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AR = @AR@
 AS = @AS@
-ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
+ATOMICITY_SRCDIR = @ATOMICITY_SRCDIR@
+ATOMIC_WORD_SRCDIR = @ATOMIC_WORD_SRCDIR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
@@ -287,6 +288,7 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
 bits_builddir = ./bits
 bits_headers = \
 	${bits_srcdir}/allocator.h \
+	${bits_srcdir}/atomicity.h \
 	${bits_srcdir}/basic_ios.h \
 	${bits_srcdir}/basic_ios.tcc \
 	${bits_srcdir}/basic_string.h \
@@ -524,9 +526,9 @@ debug_headers = \
 # For --enable-cheaders=c_std
 @GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
 @GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra = 
+@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = 
 
 @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
-@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = 
 
 host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
 host_builddir = ./${host_alias}/bits
@@ -535,7 +537,7 @@ host_headers = \
 	${host_srcdir}/ctype_inline.h \
 	${host_srcdir}/ctype_noninline.h \
 	${host_srcdir}/os_defines.h \
-	${glibcxx_srcdir}/$(ATOMICITY_INC_SRCDIR)/atomicity.h 
+	${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h 
 
 
 # Non-installed host_header files.
diff --git a/libstdc++-v3/include/bits/atomicity.h b/libstdc++-v3/include/bits/atomicity.h
new file mode 100644
index 000000000000..d2620b08e5dc
--- /dev/null
+++ b/libstdc++-v3/include/bits/atomicity.h
@@ -0,0 +1,46 @@
+// Low-level functions 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_ATOMICITY_H
+#define _GLIBCXX_ATOMICITY_H	1
+
+#include <bits/atomic_word.h>
+  
+namespace __gnu_cxx
+{
+  _Atomic_word 
+  __attribute__ ((__unused__))
+  __exchange_and_add(volatile _Atomic_word* __mem, int __val);
+
+  void
+  __attribute__ ((__unused__))
+  __atomic_add(volatile _Atomic_word* __mem, int __val);
+} // namespace __gnu_cxx
+
+#endif 
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 26c33429ee4f..a33cdefdb536 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -212,7 +212,7 @@ namespace std
 	_M_dispose(const _Alloc& __a)
 	{
 	  if (__builtin_expect(this != &_S_empty_rep(), false))
-	    if (__exchange_and_add(&this->_M_refcount, -1) <= 0)
+	    if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0)
 	      _M_destroy(__a);
 	}  // XXX MT
 
@@ -223,7 +223,7 @@ namespace std
 	_M_refcopy() throw()
 	{
 	  if (__builtin_expect(this != &_S_empty_rep(), false))
-            __atomic_add(&this->_M_refcount, 1);
+            __gnu_cxx::__atomic_add(&this->_M_refcount, 1);
 	  return _M_refdata();
 	}  // XXX MT
 
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index 3c05be038448..694785df1f55 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -1,6 +1,6 @@
 // Iostreams base classes -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -435,11 +435,12 @@ namespace std
       : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
 
       void
-      _M_add_reference() { __atomic_add(&_M_refcount, 1); }
+      _M_add_reference() { __gnu_cxx::__atomic_add(&_M_refcount, 1); }
 
       // 0 => OK to delete.
       int
-      _M_remove_reference() { return __exchange_and_add(&_M_refcount, -1); }
+      _M_remove_reference() 
+      { return __gnu_cxx::__exchange_and_add(&_M_refcount, -1); }
     };
 
      _Callback_list*	_M_callbacks;
diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h
index e4f5c17780e3..926ce209b24f 100644
--- a/libstdc++-v3/include/bits/locale_classes.h
+++ b/libstdc++-v3/include/bits/locale_classes.h
@@ -400,12 +400,12 @@ namespace std
   private:
     inline void
     _M_add_reference() const throw()
-    { __atomic_add(&_M_refcount, 1); }
+    { __gnu_cxx::__atomic_add(&_M_refcount, 1); }
 
     inline void
     _M_remove_reference() const throw()
     {
-      if (__exchange_and_add(&_M_refcount, -1) == 1)
+      if (__gnu_cxx::__exchange_and_add(&_M_refcount, -1) == 1)
 	{
 	  try
 	    { delete this; }
@@ -505,12 +505,12 @@ namespace std
 
     inline void
     _M_add_reference() throw()
-    { __atomic_add(&_M_refcount, 1); }
+    { __gnu_cxx::__atomic_add(&_M_refcount, 1); }
 
     inline void
     _M_remove_reference() throw()
     {
-      if (__exchange_and_add(&_M_refcount, -1) == 1)
+      if (__gnu_cxx::__exchange_and_add(&_M_refcount, -1) == 1)
 	{
 	  try
 	    { delete this; }
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index f81db905de7b..7b7f97767beb 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -48,13 +48,14 @@ endif
 # Source files linked in via configuration/make substitution for a
 # particular host.
 host_sources = \
+	atomicity.cc \
 	codecvt_members.cc \
 	collate_members.cc \
 	ctype_members.cc \
 	messages_members.cc \
 	monetary_members.cc \
 	numeric_members.cc \
-	time_members.cc
+	time_members.cc 
 
 codecvt_members.cc: ${glibcxx_srcdir}/$(CCODECVT_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CCODECVT_CC) . || true
@@ -77,6 +78,10 @@ numeric_members.cc: ${glibcxx_srcdir}/$(CNUMERIC_CC)
 time_members.cc: ${glibcxx_srcdir}/$(CTIME_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CTIME_CC) . || true
 
+atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h
+atomicity.cc: ${atomicity_file}
+	$(LN_S) ${atomicity_file} ./atomicity.cc || true
+
 # Source files linked in via configuration/make substitution for a
 # particular host, but with ad hoc naming rules.
 host_sources_extra = \
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index f4165bd10f49..24e7796175e8 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -43,7 +43,8 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AR = @AR@
 AS = @AS@
-ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
+ATOMICITY_SRCDIR = @ATOMICITY_SRCDIR@
+ATOMIC_WORD_SRCDIR = @ATOMIC_WORD_SRCDIR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
@@ -219,24 +220,27 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
 
 # Cross compiler support.
 toolexeclib_LTLIBRARIES = libstdc++.la
-@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg = 
 
 # Symbol versioning for shared libraries.
 @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_arg = -Wl,--version-script=libstdc++-symbol.ver
-@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_dep = 
+@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg = 
 @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_dep = libstdc++-symbol.ver
+@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_dep = 
 
 # Source files linked in via configuration/make substitution for a
 # particular host.
 host_sources = \
+	atomicity.cc \
 	codecvt_members.cc \
 	collate_members.cc \
 	ctype_members.cc \
 	messages_members.cc \
 	monetary_members.cc \
 	numeric_members.cc \
-	time_members.cc
+	time_members.cc 
+
 
+atomicity_file = ${glibcxx_srcdir}/$(ATOMICITY_SRCDIR)/atomicity.h
 
 # Source files linked in via configuration/make substitution for a
 # particular host, but with ad hoc naming rules.
@@ -306,13 +310,6 @@ libstdc___la_LDFLAGS = \
 # deprecated include files.
 GLIBCXX_INCLUDE_DIR = $(glibcxx_builddir)/include
 
-# Use special rules for the demangler, so that an additional implicit
-# instantiation file is not necessary.
-#demangle.lo: demangle.cc
-#	$(LTCXXCOMPILE) -fimplicit-templates -c $<
-#demangle.o: demangle.cc
-#	$(CXXCOMPILE) -fimplicit-templates -c $<
-
 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
 # modified in a per-library or per-sub-library way.  Need to manually
 # set this option because CONFIG_CXXFLAGS has to be after
@@ -364,9 +361,9 @@ CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
 
-am__objects_1 = codecvt_members.lo collate_members.lo ctype_members.lo \
-	messages_members.lo monetary_members.lo numeric_members.lo \
-	time_members.lo
+am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
+	ctype_members.lo messages_members.lo monetary_members.lo \
+	numeric_members.lo time_members.lo
 am__objects_2 = basic_file.lo c++locale.lo
 am__objects_3 = allocator.lo codecvt.lo complex_io.lo ctype.lo debug.lo \
 	demangle.lo functexcept.lo globals_locale.lo globals_io.lo \
@@ -662,6 +659,8 @@ numeric_members.cc: ${glibcxx_srcdir}/$(CNUMERIC_CC)
 
 time_members.cc: ${glibcxx_srcdir}/$(CTIME_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CTIME_CC) . || true
+atomicity.cc: ${atomicity_file}
+	$(LN_S) ${atomicity_file} ./atomicity.cc || true
 
 c++locale.cc: ${glibcxx_srcdir}/$(CLOCALE_CC)
 	$(LN_S) ${glibcxx_srcdir}/$(CLOCALE_CC) ./$@ || true
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index 6f987c22395f..0dfa482d9bb2 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -1,6 +1,6 @@
 // Iostreams base classes -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -138,7 +138,7 @@ namespace std
     // Implementation note: Initialize top to zero to ensure that
     // initialization occurs before main() is started.
     static _Atomic_word _S_top = 0; 
-    return __exchange_and_add(&_S_top, 1) + 4;
+    return __gnu_cxx::__exchange_and_add(&_S_top, 1) + 4;
   }
 
   void 
diff --git a/libstdc++-v3/src/ios_init.cc b/libstdc++-v3/src/ios_init.cc
index f6ba9183ac26..ae7b8e1b5f27 100644
--- a/libstdc++-v3/src/ios_init.cc
+++ b/libstdc++-v3/src/ios_init.cc
@@ -1,6 +1,6 @@
 // Iostreams base classes -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -82,7 +82,7 @@ namespace std
 
   ios_base::Init::Init()
   {
-    if (__exchange_and_add(&_S_refcount, 1) == 0)
+    if (__gnu_cxx::__exchange_and_add(&_S_refcount, 1) == 0)
       {
 	// Standard streams default to synced with "C" operations.
 	_S_synced_with_stdio = true;
@@ -117,13 +117,13 @@ namespace std
 	// streams are not re-initialized with uses of ios_base::Init
 	// besides <iostream> static object, ie just using <ios> with
 	// ios_base::Init objects.
-	__atomic_add(&_S_refcount, 1);
+	__gnu_cxx::__atomic_add(&_S_refcount, 1);
       }
   }
 
   ios_base::Init::~Init()
   {
-    if (__exchange_and_add(&_S_refcount, -1) == 2)
+    if (__gnu_cxx::__exchange_and_add(&_S_refcount, -1) == 2)
       {
 	// Catch any exceptions thrown by basic_ostream::flush()
 	try
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index 4e1aebb486d3..7021b65ec582 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -356,7 +356,7 @@ namespace std
   locale::id::_M_id() const
   {
     if (!_M_index)
-      _M_index = 1 + __exchange_and_add(&_S_refcount, 1);
+      _M_index = 1 + __gnu_cxx::__exchange_and_add(&_S_refcount, 1);
     return _M_index - 1;
   }
 } // namespace std
diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc
index 6e80b878fd5d..626598e13a3b 100644
--- a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc
@@ -1,6 +1,6 @@
 // { dg-do compile }
 
-// 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
@@ -41,5 +41,5 @@ void test01()
   io1 = io2;
 }
 // { dg-error "within this context" "" { target *-*-* } 41 } 
-// { dg-error "is private" "" { target *-*-* } 740 } 
+// { dg-error "is private" "" { target *-*-* } 741 } 
 // { dg-error "operator=" "" { target *-*-* } 0 } 
diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc
index b4cf359d3ac0..9df52f3997b6 100644
--- a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc
@@ -1,6 +1,6 @@
 // { dg-do compile }
 
-// 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
@@ -41,5 +41,5 @@ void test02()
   test_base io2 = io1; 
 }
 // { dg-error "within this context" "" { target *-*-* } 41 } 
-// { dg-error "is private" "" { target *-*-* } 737 } 
+// { dg-error "is private" "" { target *-*-* } 738 } 
 // { dg-error "copy constructor" "" { target *-*-* } 0 } 
-- 
GitLab