xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/src/c++98/globals_io.cc (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // Copyright (C) 2001-2018 Free Software Foundation, Inc.
2*38fd1498Szrj //
3*38fd1498Szrj // This file is part of the GNU ISO C++ Library.  This library is free
4*38fd1498Szrj // software; you can redistribute it and/or modify it under the
5*38fd1498Szrj // terms of the GNU General Public License as published by the
6*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option)
7*38fd1498Szrj // any later version.
8*38fd1498Szrj 
9*38fd1498Szrj // This library is distributed in the hope that it will be useful,
10*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
11*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*38fd1498Szrj // GNU General Public License for more details.
13*38fd1498Szrj 
14*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
15*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
16*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
17*38fd1498Szrj 
18*38fd1498Szrj // You should have received a copy of the GNU General Public License and
19*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
20*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21*38fd1498Szrj // <http://www.gnu.org/licenses/>.
22*38fd1498Szrj 
23*38fd1498Szrj #include "bits/c++config.h"
24*38fd1498Szrj #include <fstream>
25*38fd1498Szrj #include <istream>
26*38fd1498Szrj #include <ostream>
27*38fd1498Szrj #include <ext/stdio_filebuf.h>
28*38fd1498Szrj #include <ext/stdio_sync_filebuf.h>
29*38fd1498Szrj 
30*38fd1498Szrj // On AIX, and perhaps other systems, library initialization order is
31*38fd1498Szrj // not guaranteed.  For example, the static initializers for the main
32*38fd1498Szrj // program might run before the static initializers for this library.
33*38fd1498Szrj // That means that we cannot rely on static initialization in the
34*38fd1498Szrj // library; there is no guarantee that things will get initialized in
35*38fd1498Szrj // time.  This file contains definitions of all global variables that
36*38fd1498Szrj // require initialization as arrays of characters.
37*38fd1498Szrj 
38*38fd1498Szrj // NB: asm directives can rename these non-exported, namespace
39*38fd1498Szrj // __gnu_cxx symbols into exported, namespace std symbols with the
40*38fd1498Szrj // appropriate symbol version name.
41*38fd1498Szrj // The rename syntax is
42*38fd1498Szrj //   asm (".symver currentname,oldname@@GLIBCXX_3.2")
43*38fd1498Szrj // In macro form:
44*38fd1498Szrj // _GLIBCXX_ASM_SYMVER(currentname, oldname, GLIBCXX_3.2)
45*38fd1498Szrj 
46*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default)
47*38fd1498Szrj {
48*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_VERSION
49*38fd1498Szrj 
50*38fd1498Szrj   // Standard stream objects.
51*38fd1498Szrj   // NB: Iff <iostream> is included, these definitions become wonky.
52*38fd1498Szrj   typedef char fake_istream[sizeof(istream)]
53*38fd1498Szrj   __attribute__ ((aligned(__alignof__(istream))));
54*38fd1498Szrj   typedef char fake_ostream[sizeof(ostream)]
55*38fd1498Szrj   __attribute__ ((aligned(__alignof__(ostream))));
56*38fd1498Szrj   fake_istream cin;
57*38fd1498Szrj   fake_ostream cout;
58*38fd1498Szrj   fake_ostream cerr;
59*38fd1498Szrj   fake_ostream clog;
60*38fd1498Szrj 
61*38fd1498Szrj #ifdef _GLIBCXX_USE_WCHAR_T
62*38fd1498Szrj   typedef char fake_wistream[sizeof(wistream)]
63*38fd1498Szrj   __attribute__ ((aligned(__alignof__(wistream))));
64*38fd1498Szrj   typedef char fake_wostream[sizeof(wostream)]
65*38fd1498Szrj   __attribute__ ((aligned(__alignof__(wostream))));
66*38fd1498Szrj   fake_wistream wcin;
67*38fd1498Szrj   fake_wostream wcout;
68*38fd1498Szrj   fake_wostream wcerr;
69*38fd1498Szrj   fake_wostream wclog;
70*38fd1498Szrj #endif
71*38fd1498Szrj 
72*38fd1498Szrj _GLIBCXX_END_NAMESPACE_VERSION
73*38fd1498Szrj } // namespace
74*38fd1498Szrj 
75*38fd1498Szrj namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
76*38fd1498Szrj {
77*38fd1498Szrj   using namespace std;
78*38fd1498Szrj   using namespace __gnu_cxx;
79*38fd1498Szrj 
80*38fd1498Szrj   // We use different stream buffer types depending on whether
81*38fd1498Szrj   // ios_base::sync_with_stdio(false) has been called.
82*38fd1498Szrj   typedef char fake_stdiobuf[sizeof(stdio_sync_filebuf<char>)]
83*38fd1498Szrj   __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<char>))));
84*38fd1498Szrj   fake_stdiobuf buf_cout_sync;
85*38fd1498Szrj   fake_stdiobuf buf_cin_sync;
86*38fd1498Szrj   fake_stdiobuf buf_cerr_sync;
87*38fd1498Szrj 
88*38fd1498Szrj   typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
89*38fd1498Szrj   __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
90*38fd1498Szrj   fake_filebuf buf_cout;
91*38fd1498Szrj   fake_filebuf buf_cin;
92*38fd1498Szrj   fake_filebuf buf_cerr;
93*38fd1498Szrj 
94*38fd1498Szrj #ifdef _GLIBCXX_USE_WCHAR_T
95*38fd1498Szrj   typedef char fake_wstdiobuf[sizeof(stdio_sync_filebuf<wchar_t>)]
96*38fd1498Szrj   __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<wchar_t>))));
97*38fd1498Szrj   fake_wstdiobuf buf_wcout_sync;
98*38fd1498Szrj   fake_wstdiobuf buf_wcin_sync;
99*38fd1498Szrj   fake_wstdiobuf buf_wcerr_sync;
100*38fd1498Szrj 
101*38fd1498Szrj   typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
102*38fd1498Szrj   __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
103*38fd1498Szrj   fake_wfilebuf buf_wcout;
104*38fd1498Szrj   fake_wfilebuf buf_wcin;
105*38fd1498Szrj   fake_wfilebuf buf_wcerr;
106*38fd1498Szrj #endif
107*38fd1498Szrj } // namespace __gnu_internal
108