OSDN Git Service

2011-05-26 Jonathan Wakely <jwakely.gcc@gmail.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / ios.cc
index 70b22f6..292f1f8 100644 (file)
@@ -1,12 +1,13 @@
 // Iostreams base classes -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007, 2008, 2009, 2010
 // 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)
+// Free Software Foundation; either version 3, or (at your option)
 // any later version.
 
 // This library is distributed in the hope that it will be useful,
 // 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.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
 
-// 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.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
 
 //
 // ISO C++ 14882: 27.4  Iostreams base classes
 
 #include <ios>
 #include <limits>
-#include <bits/atomicity.h>
-
-namespace std 
-{  
-  // XXX GLIBCXX_ABI Deprecated
-   // Definitions for static const data members of __ios_flags.
-  const __ios_flags::__int_type __ios_flags::_S_boolalpha;
-  const __ios_flags::__int_type __ios_flags::_S_dec;
-  const __ios_flags::__int_type __ios_flags::_S_fixed;
-  const __ios_flags::__int_type __ios_flags::_S_hex;
-  const __ios_flags::__int_type __ios_flags::_S_internal;
-  const __ios_flags::__int_type __ios_flags::_S_left;
-  const __ios_flags::__int_type __ios_flags::_S_oct;
-  const __ios_flags::__int_type __ios_flags::_S_right;
-  const __ios_flags::__int_type __ios_flags::_S_scientific;
-  const __ios_flags::__int_type __ios_flags::_S_showbase;
-  const __ios_flags::__int_type __ios_flags::_S_showpoint;
-  const __ios_flags::__int_type __ios_flags::_S_showpos;
-  const __ios_flags::__int_type __ios_flags::_S_skipws;
-  const __ios_flags::__int_type __ios_flags::_S_unitbuf;
-  const __ios_flags::__int_type __ios_flags::_S_uppercase;
-  const __ios_flags::__int_type __ios_flags::_S_adjustfield;
-  const __ios_flags::__int_type __ios_flags::_S_basefield;
-  const __ios_flags::__int_type __ios_flags::_S_floatfield;
-
-  const __ios_flags::__int_type __ios_flags::_S_badbit;
-  const __ios_flags::__int_type __ios_flags::_S_eofbit;
-  const __ios_flags::__int_type __ios_flags::_S_failbit;
-
-  const __ios_flags::__int_type __ios_flags::_S_app;
-  const __ios_flags::__int_type __ios_flags::_S_ate;
-  const __ios_flags::__int_type __ios_flags::_S_bin;
-  const __ios_flags::__int_type __ios_flags::_S_in;
-  const __ios_flags::__int_type __ios_flags::_S_out;
-  const __ios_flags::__int_type __ios_flags::_S_trunc;
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Definitions for static const members of ios_base.
   const ios_base::fmtflags ios_base::boolalpha;
@@ -106,13 +71,11 @@ namespace std
   const ios_base::seekdir ios_base::cur;
   const ios_base::seekdir ios_base::end;
 
-  const int ios_base::_S_local_word_size;
-
   _Atomic_word ios_base::Init::_S_refcount;
 
   bool ios_base::Init::_S_synced_with_stdio = true;
 
-  ios_base::ios_base() 
+  ios_base::ios_base() throw()
   : _M_precision(), _M_width(), _M_flags(), _M_exception(), 
   _M_streambuf_state(), _M_callbacks(0), _M_word_zero(), 
   _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
@@ -141,7 +104,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 __gnu_cxx::__exchange_and_add(&_S_top, 1) + 4;
+    return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
   }
 
   void 
@@ -160,14 +123,14 @@ namespace std
        if (__ix < numeric_limits<int>::max())
          {
            __newsize = __ix + 1;
-           try
+           __try
              { __words = new _Words[__newsize]; }
-           catch (...)
+           __catch(const std::bad_alloc&)
              {
                _M_streambuf_state |= badbit;
                if (_M_streambuf_state & _M_exception)
                  __throw_ios_failure(__N("ios_base::_M_grow_words "
-                                     "allocation failed"));
+                                         "allocation failed"));
                if (__iword)
                  _M_word_zero._M_iword = 0;
                else
@@ -205,16 +168,16 @@ namespace std
     _Callback_list* __p = _M_callbacks;
     while (__p)
       {
-       try 
+       __try 
          { (*__p->_M_fn) (__e, *this, __p->_M_index); } 
-       catch (...) 
+       __catch(...) 
          { }
        __p = __p->_M_next;
       }
   }
 
   void 
-  ios_base::_M_dispose_callbacks(void)
+  ios_base::_M_dispose_callbacks(void) throw()
   {
     _Callback_list* __p = _M_callbacks;
     while (__p && __p->_M_remove_reference() == 0)
@@ -225,4 +188,6 @@ namespace std
       }
     _M_callbacks = 0;
   }
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace