1169691Skan// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
2169691Skan// Free Software Foundation, Inc.
3132720Skan//
4132720Skan// This file is part of the GNU ISO C++ Library.  This library is free
5132720Skan// software; you can redistribute it and/or modify it under the
6132720Skan// terms of the GNU General Public License as published by the
7132720Skan// Free Software Foundation; either version 2, or (at your option)
8132720Skan// any later version.
9132720Skan
10132720Skan// This library is distributed in the hope that it will be useful,
11132720Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of
12132720Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13132720Skan// GNU General Public License for more details.
14132720Skan
15132720Skan// You should have received a copy of the GNU General Public License along
16132720Skan// with this library; see the file COPYING.  If not, write to the Free
17169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18132720Skan// USA.
19132720Skan
20132720Skan// As a special exception, you may use this file as part of a free software
21132720Skan// library without restriction.  Specifically, if other files instantiate
22132720Skan// templates or use macros or inline functions from this file, or you compile
23132720Skan// this file and link it with other files to produce an executable, this
24132720Skan// file does not by itself cause the resulting executable to be covered by
25132720Skan// the GNU General Public License.  This exception does not however
26132720Skan// invalidate any other reasons why the executable file might be covered by
27132720Skan// the GNU General Public License.
28132720Skan
29132720Skan#include "bits/c++config.h"
30132720Skan#include <fstream>
31132720Skan#include <istream>
32132720Skan#include <ostream>
33132720Skan#include <ext/stdio_filebuf.h>
34132720Skan#include <ext/stdio_sync_filebuf.h>
35132720Skan
36132720Skan// On AIX, and perhaps other systems, library initialization order is
37132720Skan// not guaranteed.  For example, the static initializers for the main
38132720Skan// program might run before the static initializers for this library.
39132720Skan// That means that we cannot rely on static initialization in the
40132720Skan// library; there is no guarantee that things will get initialized in
41132720Skan// time.  This file contains definitions of all global variables that
42132720Skan// require initialization as arrays of characters.
43132720Skan
44132720Skan// NB: asm directives can rename these non-exported, namespace
45132720Skan// __gnu_cxx symbols into exported, namespace std symbols with the
46132720Skan// appropriate symbol version name.
47132720Skan// The rename syntax is
48132720Skan//   asm (".symver currentname,oldname@@GLIBCXX_3.2")
49132720Skan// In macro form:
50132720Skan// _GLIBCXX_ASM_SYMVER(currentname, oldname, GLIBCXX_3.2)
51132720Skan
52169691Skan_GLIBCXX_BEGIN_NAMESPACE(std)
53169691Skan
54132720Skan  // Standard stream objects.
55132720Skan  // NB: Iff <iostream> is included, these definitions become wonky.
56132720Skan  typedef char fake_istream[sizeof(istream)]
57132720Skan  __attribute__ ((aligned(__alignof__(istream))));
58132720Skan  typedef char fake_ostream[sizeof(ostream)]
59132720Skan  __attribute__ ((aligned(__alignof__(ostream))));
60132720Skan  fake_istream cin;
61132720Skan  fake_ostream cout;
62132720Skan  fake_ostream cerr;
63132720Skan  fake_ostream clog;
64132720Skan
65132720Skan#ifdef _GLIBCXX_USE_WCHAR_T
66132720Skan  typedef char fake_wistream[sizeof(wistream)]
67132720Skan  __attribute__ ((aligned(__alignof__(wistream))));
68132720Skan  typedef char fake_wostream[sizeof(wostream)]
69132720Skan  __attribute__ ((aligned(__alignof__(wostream))));
70132720Skan  fake_wistream wcin;
71132720Skan  fake_wostream wcout;
72132720Skan  fake_wostream wcerr;
73132720Skan  fake_wostream wclog;
74132720Skan#endif
75132720Skan
76169691Skan_GLIBCXX_END_NAMESPACE
77169691Skan
78169691Skannamespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
79132720Skan{
80132720Skan  using namespace std;
81132720Skan  using namespace __gnu_cxx;
82132720Skan
83132720Skan  // We use different stream buffer types depending on whether
84132720Skan  // ios_base::sync_with_stdio(false) has been called.
85132720Skan  typedef char fake_stdiobuf[sizeof(stdio_sync_filebuf<char>)]
86132720Skan  __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<char>))));
87132720Skan  fake_stdiobuf buf_cout_sync;
88132720Skan  fake_stdiobuf buf_cin_sync;
89132720Skan  fake_stdiobuf buf_cerr_sync;
90132720Skan
91132720Skan  typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
92132720Skan  __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
93132720Skan  fake_filebuf buf_cout;
94132720Skan  fake_filebuf buf_cin;
95132720Skan  fake_filebuf buf_cerr;
96132720Skan
97132720Skan#ifdef _GLIBCXX_USE_WCHAR_T
98132720Skan  typedef char fake_wstdiobuf[sizeof(stdio_sync_filebuf<wchar_t>)]
99132720Skan  __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<wchar_t>))));
100132720Skan  fake_wstdiobuf buf_wcout_sync;
101132720Skan  fake_wstdiobuf buf_wcin_sync;
102132720Skan  fake_wstdiobuf buf_wcerr_sync;
103132720Skan
104132720Skan  typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
105132720Skan  __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
106132720Skan  fake_wfilebuf buf_wcout;
107132720Skan  fake_wfilebuf buf_wcin;
108132720Skan  fake_wfilebuf buf_wcerr;
109132720Skan#endif
110132720Skan} // namespace __gnu_internal
111