OSDN Git Service

libstdc++/5432
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / ios_base.h
index a753177..7525e7d 100644 (file)
@@ -1,6 +1,7 @@
 // Iostreams base classes -*- C++ -*-
 
-// Copyright (C) 1997-1999 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// 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
 // ISO C++ 14882: 27.8  File-based streams
 //
 
+/** @file ios_base.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
 #ifndef _CPP_BITS_IOSBASE_H
 #define _CPP_BITS_IOSBASE_H 1
 
-namespace std {
+#pragma GCC system_header
+
+#include <bits/atomicity.h>
 
+namespace std
+{
   // The following definitions of bitmask types are enums, not ints,
   // as permitted (but not required) in the standard, in order to provide
   // better type safety in iostream calls.  A side effect is that
   // expressions involving them are no longer compile-time constants.
-  enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1<<16 };
+  enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1L << 16 };
 
   inline _Ios_Fmtflags 
   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
@@ -71,7 +81,7 @@ namespace std {
   { return _Ios_Fmtflags(~static_cast<int>(__a)); }
 
 
-  enum _Ios_Openmode { _S_ios_openmode_end = 1<<16 };
+  enum _Ios_Openmode { _M_ios_openmode_end = 1L << 16 };
 
   inline _Ios_Openmode 
   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
@@ -102,7 +112,7 @@ namespace std {
   { return _Ios_Openmode(~static_cast<int>(__a)); }
 
 
-  enum _Ios_Iostate { _S_ios_iostate_end = 1<<16 };
+  enum _Ios_Iostate { _M_ios_iostate_end = 1L << 16 };
 
   inline _Ios_Iostate 
   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
@@ -132,27 +142,27 @@ namespace std {
   operator~(_Ios_Iostate __a)
   { return _Ios_Iostate(~static_cast<int>(__a)); }
 
-  enum _Ios_Seekdir { _S_ios_Seekdir_end = 1<<16 };
+  enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
 
   // 27.4.2  Class ios_base
   class ios_base
   {
   public:
-
+    
     // 27.4.2.1.1  Class ios_base::failure
     class failure : public exception
     {
     public:
 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
-      // Can't do exception(_msg) as defined in 27.4.2.1.1
+      //48.  Use of non-existent exception constructor
       explicit 
-      failure(const string& __str);
+      failure(const string& __str) throw();
 
       virtual 
-      ~failure() { };
+      ~failure() throw();
 
-      virtual const 
-      char* what() const throw() { return _M_name; }
+      virtual const char*
+      what() const throw();
       
     private:
       enum { _M_bufsize = 256 };
@@ -229,26 +239,26 @@ namespace std {
     streamsize                 _M_width;
     fmtflags           _M_flags;
 
-     // 27.4.2.6  Members for callbacks
+    // 27.4.2.6  Members for callbacks
     // 27.4.2.6  ios_base callbacks
-
     struct _Callback_list
     {
       // Data Members
       _Callback_list*          _M_next;
       ios_base::event_callback         _M_fn;
       int                      _M_index;
-      int                      _M_refcount;  // 0 means one reference.
+      _Atomic_word             _M_refcount;  // 0 means one reference.
     
       _Callback_list(ios_base::event_callback __fn, int __index, 
                     _Callback_list* __cb)
       : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
       
       void 
-      _M_add_reference() { ++_M_refcount; } // XXX MT
-      
+      _M_add_reference() { __atomic_add(&_M_refcount, 1); }
+
       int 
-      _M_remove_reference() { return _M_refcount--; }  // 0 => OK to delete
+      _M_remove_reference() { return __exchange_and_add(&_M_refcount, -1); }
+      // 0 => OK to delete
     };
 
      _Callback_list*   _M_callbacks;
@@ -259,7 +269,7 @@ namespace std {
     void 
     _M_dispose_callbacks(void);
 
-   // 27.4.2.5  Members for iword/pword storage
+    // 27.4.2.5  Members for iword/pword storage
     struct _Words 
     { 
       void*    _M_pword; 
@@ -282,27 +292,27 @@ namespace std {
     _M_init();
 
   public:
+
     // 27.4.2.1.6  Class ios_base::Init
     // Used to initialize standard streams. In theory, g++ could use
     // -finit-priority to order this stuff correctly without going
     // through these machinations. 
-
     class Init 
     {
       friend class ios_base;
     public:
       Init();
       ~Init();
+      
+      static void
+      _S_ios_create(bool __sync);
+      
+      static void
+      _S_ios_destroy();
+
     private:
       static int       _S_ios_base_init;
-      filebuf*                 _M_cout;
-      filebuf*                 _M_cin;
-      filebuf*                 _M_cerr;
-#ifdef _GLIBCPP_USE_WCHAR_T
-      wfilebuf*        _M_wcout;
-      wfilebuf*                _M_wcin;
-      wfilebuf*        _M_wcerr;
-#endif
+      static bool      _S_synced_with_stdio;
     };
 
     // Fmtflags state:
@@ -362,7 +372,7 @@ namespace std {
     static bool 
     sync_with_stdio(bool __sync = true);
 
-   // Locales:
+    // Locales:
     locale 
     imbue(const locale& __loc);
 
@@ -396,6 +406,7 @@ namespace std {
     ios_base();
 
 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+  //50.  Copy constructor and assignment operator of ios_base
   private:
     ios_base(const ios_base&);
 
@@ -566,11 +577,3 @@ namespace std {
 
 #endif /* _CPP_BITS_IOSBASE_H */
 
-
-
-
-
-
-
-
-