OSDN Git Service

2001-06-05 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / globals.cc
1 // Copyright (C) 2001 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library.  This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING.  If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
18
19 // As a special exception, you may use this file as part of a free software
20 // library without restriction.  Specifically, if other files instantiate
21 // templates or use macros or inline functions from this file, or you compile
22 // this file and link it with other files to produce an executable, this
23 // file does not by itself cause the resulting executable to be covered by
24 // the GNU General Public License.  This exception does not however
25 // invalidate any other reasons why the executable file might be covered by
26 // the GNU General Public License.
27
28 #include <fstream>
29 #include <istream>
30 #include <ostream>
31
32 // On AIX, and perhaps other systems, library initialization order is
33 // not guaranteed.  For example, the static initializers for the main
34 // program might run before the static initializers for this library.
35 // That means that we cannot rely on static initialization in the
36 // library; there is no guarantee that things will get initialized in
37 // time.  This file contains definitions of all global variables that
38 // require initialization as arrays of characters.
39
40 // Because <iostream> declares the standard streams to be [io]stream
41 // types instead of say [io]fstream types, it is also necessary to
42 // allocate the actual file buffers in this file.
43 namespace std 
44 {
45   typedef char fake_istream[sizeof(istream)]
46   __attribute__ ((aligned(__alignof__(istream))));
47   typedef char fake_ostream[sizeof(ostream)] 
48   __attribute__ ((aligned(__alignof__(ostream))));
49   fake_istream cin;
50   fake_ostream cout;
51   fake_ostream cerr;
52   fake_ostream clog;
53
54   typedef char fake_filebuf[sizeof(filebuf)]
55   __attribute__ ((aligned(__alignof__(filebuf))));
56   fake_filebuf buf_cout;
57   fake_filebuf buf_cin;
58   fake_filebuf buf_cerr;
59
60 #ifdef _GLIBCPP_USE_WCHAR_T
61   typedef char fake_wistream[sizeof(wistream)] 
62   __attribute__ ((aligned(__alignof__(wistream))));
63   typedef char fake_wostream[sizeof(wostream)] 
64   __attribute__ ((aligned(__alignof__(wostream))));
65   fake_wistream wcin;
66   fake_wostream wcout;
67   fake_wostream wcerr;
68   fake_wostream wclog;
69
70   typedef char fake_wfilebuf[sizeof(wfilebuf)]
71   __attribute__ ((aligned(__alignof__(wfilebuf))));
72   fake_wfilebuf buf_wcout;
73   fake_wfilebuf buf_wcin;
74   fake_wfilebuf buf_wcerr;
75 #endif
76 }