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