Whole document tree
    

Whole document tree

globals.cc Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

globals.cc

Go to the documentation of this file.
00001 // Copyright (C) 2001 Free Software Foundation, Inc.
00002 //
00003 // This file is part of the GNU ISO C++ Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the
00005 // terms of the GNU General Public License as published by the
00006 // Free Software Foundation; either version 2, or (at your option)
00007 // any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 
00014 // You should have received a copy of the GNU General Public License along
00015 // with this library; see the file COPYING.  If not, write to the Free
00016 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017 // USA.
00018 
00019 // As a special exception, you may use this file as part of a free software
00020 // library without restriction.  Specifically, if other files instantiate
00021 // templates or use macros or inline functions from this file, or you compile
00022 // this file and link it with other files to produce an executable, this
00023 // file does not by itself cause the resulting executable to be covered by
00024 // the GNU General Public License.  This exception does not however
00025 // invalidate any other reasons why the executable file might be covered by
00026 // the GNU General Public License.
00027 
00028 #include "bits/c++config.h"
00029 #include "bits/gthr.h"
00030 #include <fstream>
00031 #include <istream>
00032 #include <ostream>
00033 
00034 // On AIX, and perhaps other systems, library initialization order is
00035 // not guaranteed.  For example, the static initializers for the main
00036 // program might run before the static initializers for this library.
00037 // That means that we cannot rely on static initialization in the
00038 // library; there is no guarantee that things will get initialized in
00039 // time.  This file contains definitions of all global variables that
00040 // require initialization as arrays of characters.
00041 
00042 // Because <iostream> declares the standard streams to be [io]stream
00043 // types instead of say [io]fstream types, it is also necessary to
00044 // allocate the actual file buffers in this file.
00045 namespace std 
00046 {
00047   typedef char fake_istream[sizeof(istream)]
00048   __attribute__ ((aligned(__alignof__(istream))));
00049   typedef char fake_ostream[sizeof(ostream)] 
00050   __attribute__ ((aligned(__alignof__(ostream))));
00051   fake_istream cin;
00052   fake_ostream cout;
00053   fake_ostream cerr;
00054   fake_ostream clog;
00055 
00056   typedef char fake_filebuf[sizeof(filebuf)]
00057   __attribute__ ((aligned(__alignof__(filebuf))));
00058   fake_filebuf buf_cout;
00059   fake_filebuf buf_cin;
00060   fake_filebuf buf_cerr;
00061 
00062 #ifdef _GLIBCPP_USE_WCHAR_T
00063   typedef char fake_wistream[sizeof(wistream)] 
00064   __attribute__ ((aligned(__alignof__(wistream))));
00065   typedef char fake_wostream[sizeof(wostream)] 
00066   __attribute__ ((aligned(__alignof__(wostream))));
00067   fake_wistream wcin;
00068   fake_wostream wcout;
00069   fake_wostream wcerr;
00070   fake_wostream wclog;
00071 
00072   typedef char fake_wfilebuf[sizeof(wfilebuf)]
00073   __attribute__ ((aligned(__alignof__(wfilebuf))));
00074   fake_wfilebuf buf_wcout;
00075   fake_wfilebuf buf_wcin;
00076   fake_wfilebuf buf_wcerr;
00077 #endif
00078 
00079 // Globals for once-only runtime initialization of mutex objects.  This
00080 // allows static initialization of these objects on systems that need a
00081 // function call to initialize a mutex.  For example, see stl_threads.h.
00082 #if __GTHREADS
00083 #ifdef __GTHREAD_MUTEX_INIT
00084 // This path is not needed since static initialization of mutexs works
00085 // on this platform.
00086 #elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
00087 __gthread_once_t _GLIBCPP_once = __GTHREAD_ONCE_INIT;
00088 __gthread_mutex_t _GLIBCPP_mutex;
00089 __gthread_mutex_t *_GLIBCPP_mutex_address;
00090 
00091 // Once-only initializer function for _GLIBCPP_mutex.  
00092 void
00093 _GLIBCPP_mutex_init ()
00094 {
00095   __GTHREAD_MUTEX_INIT_FUNCTION (&_GLIBCPP_mutex);
00096 }
00097 // Once-only initializer function for _GLIBCPP_mutex_address.  
00098 void
00099 _GLIBCPP_mutex_address_init ()
00100 {
00101   __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address);
00102 }
00103 #endif
00104 #endif
00105 }

Generated on Mon Apr 8 03:11:25 2002 for libstdc++-v3 Source by doxygen1.2.15