globals.cc

00001 // Copyright (C) 2001, 2002 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 #include <locale>
00034 #include <ext/stdio_filebuf.h>
00035 
00036 // On AIX, and perhaps other systems, library initialization order is
00037 // not guaranteed.  For example, the static initializers for the main
00038 // program might run before the static initializers for this library.
00039 // That means that we cannot rely on static initialization in the
00040 // library; there is no guarantee that things will get initialized in
00041 // time.  This file contains definitions of all global variables that
00042 // require initialization as arrays of characters.
00043 
00044 // Because <iostream> declares the standard streams to be [io]stream
00045 // types instead of say [io]fstream types, it is also necessary to
00046 // allocate the actual file buffers in this file.
00047 namespace std 
00048 {
00049   // Standard "C" locale.
00050   typedef char fake_locale[sizeof(locale)]
00051   __attribute__ ((aligned(__alignof__(locale))));
00052   fake_locale c_locale;
00053 
00054   typedef char fake_locale_Impl[sizeof(locale::_Impl)]
00055   __attribute__ ((aligned(__alignof__(locale::_Impl))));
00056   fake_locale_Impl c_locale_impl;
00057   
00058   typedef char fake_facet_vec[sizeof(locale::facet*)]
00059   __attribute__ ((aligned(__alignof__(locale::facet*))));
00060   fake_facet_vec facet_vec[_GLIBCPP_NUM_FACETS];
00061 
00062   typedef char fake_ctype_c[sizeof(std::ctype<char>)]
00063   __attribute__ ((aligned(__alignof__(std::ctype<char>))));
00064   fake_ctype_c ctype_c;
00065 
00066   typedef char fake_collate_c[sizeof(std::collate<char>)]
00067   __attribute__ ((aligned(__alignof__(std::collate<char>))));
00068   fake_collate_c collate_c;
00069 
00070   typedef char fake_numpunct_c[sizeof(numpunct<char>)]
00071   __attribute__ ((aligned(__alignof__(numpunct<char>))));
00072   fake_numpunct_c numpunct_c;
00073 
00074   typedef char fake_num_get_c[sizeof(num_get<char>)]
00075   __attribute__ ((aligned(__alignof__(num_get<char>))));
00076   fake_num_get_c num_get_c;
00077 
00078   typedef char fake_num_put_c[sizeof(num_put<char>)]
00079   __attribute__ ((aligned(__alignof__(num_put<char>))));
00080   fake_num_put_c num_put_c;
00081 
00082   typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
00083   __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
00084   fake_codecvt_c codecvt_c;
00085 
00086   typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
00087   __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
00088   fake_moneypunct_c moneypunct_tc;
00089   fake_moneypunct_c moneypunct_fc;
00090 
00091   typedef char fake_money_get_c[sizeof(money_get<char>)]
00092   __attribute__ ((aligned(__alignof__(money_get<char>))));
00093   fake_money_get_c money_get_c;
00094   
00095   typedef char fake_money_put_c[sizeof(money_put<char>)]
00096   __attribute__ ((aligned(__alignof__(money_put<char>))));
00097   fake_money_put_c money_put_c;
00098 
00099   typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
00100   __attribute__ ((aligned(__alignof__(__timepunct<char>))));
00101   fake_timepunct_c timepunct_c;
00102 
00103   typedef char fake_time_get_c[sizeof(time_get<char>)]
00104   __attribute__ ((aligned(__alignof__(time_get<char>))));
00105   fake_time_get_c time_get_c;
00106 
00107   typedef char fake_time_put_c[sizeof(time_put<char>)]
00108   __attribute__ ((aligned(__alignof__(time_put<char>))));
00109   fake_time_put_c time_put_c;
00110 
00111   typedef char fake_messages_c[sizeof(messages<char>)]
00112   __attribute__ ((aligned(__alignof__(messages<char>))));
00113   fake_messages_c messages_c;
00114 
00115 #ifdef  _GLIBCPP_USE_WCHAR_T
00116   typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
00117   __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
00118   fake_wtype_w ctype_w;
00119 
00120   typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
00121   __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
00122   fake_wollate_w collate_w;
00123 
00124   typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
00125   __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
00126   fake_numpunct_w numpunct_w;
00127 
00128   typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
00129   __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
00130   fake_num_get_w num_get_w;
00131 
00132   typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
00133   __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
00134   fake_num_put_w num_put_w;
00135 
00136   typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
00137   __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
00138   fake_wodecvt_w codecvt_w;
00139 
00140   typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
00141   __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
00142   fake_moneypunct_w moneypunct_tw;
00143   fake_moneypunct_w moneypunct_fw;
00144 
00145   typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
00146   __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
00147   fake_money_get_w money_get_w;
00148   
00149   typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
00150   __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
00151   fake_money_put_w money_put_w;
00152 
00153   typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
00154   __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
00155   fake_timepunct_w timepunct_w;
00156 
00157   typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
00158   __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
00159   fake_time_get_w time_get_w;
00160 
00161   typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
00162   __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
00163   fake_time_put_w time_put_w;
00164 
00165   typedef char fake_messages_w[sizeof(messages<wchar_t>)]
00166   __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
00167   fake_messages_w messages_w;
00168 #endif
00169 
00170   // Standard stream objects.
00171   typedef char fake_istream[sizeof(istream)]
00172   __attribute__ ((aligned(__alignof__(istream))));
00173   typedef char fake_ostream[sizeof(ostream)] 
00174   __attribute__ ((aligned(__alignof__(ostream))));
00175   fake_istream cin;
00176   fake_ostream cout;
00177   fake_ostream cerr;
00178   fake_ostream clog;
00179 
00180   typedef char fake_filebuf[sizeof(__gnu_cxx::stdio_filebuf<char>)]
00181   __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<char>))));
00182   fake_filebuf buf_cout;
00183   fake_filebuf buf_cin;
00184   fake_filebuf buf_cerr;
00185 
00186 #ifdef _GLIBCPP_USE_WCHAR_T
00187   typedef char fake_wistream[sizeof(wistream)] 
00188   __attribute__ ((aligned(__alignof__(wistream))));
00189   typedef char fake_wostream[sizeof(wostream)] 
00190   __attribute__ ((aligned(__alignof__(wostream))));
00191   fake_wistream wcin;
00192   fake_wostream wcout;
00193   fake_wostream wcerr;
00194   fake_wostream wclog;
00195 
00196   typedef char fake_wfilebuf[sizeof(__gnu_cxx::stdio_filebuf<wchar_t>)]
00197   __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<wchar_t>))));
00198   fake_wfilebuf buf_wcout;
00199   fake_wfilebuf buf_wcin;
00200   fake_wfilebuf buf_wcerr;
00201 #endif
00202 
00203 
00204   // Globals for once-only runtime initialization of mutex objects.  This
00205   // allows static initialization of these objects on systems that need a
00206   // function call to initialize a mutex.  For example, see stl_threads.h.
00207 #ifdef __GTHREAD_MUTEX_INIT
00208   // Need to provide explicit instantiations of static data for
00209   // systems with broken weak linkage support.
00210   template __gthread_mutex_t _Swap_lock_struct<0>::_S_swap_lock;
00211 #elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
00212   __gthread_once_t _GLIBCPP_once = __GTHREAD_ONCE_INIT;
00213   __gthread_mutex_t _GLIBCPP_mutex;
00214   __gthread_mutex_t *_GLIBCPP_mutex_address;
00215   
00216   // Once-only initializer function for _GLIBCPP_mutex.  
00217   void
00218   _GLIBCPP_mutex_init ()
00219   { __GTHREAD_MUTEX_INIT_FUNCTION (&_GLIBCPP_mutex); }
00220 
00221   // Once-only initializer function for _GLIBCPP_mutex_address.  
00222   void
00223   _GLIBCPP_mutex_address_init ()
00224   { __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address); }
00225 #endif
00226 }

Generated on Wed May 1 19:19:31 2002 for libstdc++-v3 Source by doxygen1.2.15