1 | // Copyright (C) 2001, 2002 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 "bits/c++config.h"
|
---|
29 | #include "bits/gthr.h"
|
---|
30 | #include <fstream>
|
---|
31 | #include <istream>
|
---|
32 | #include <ostream>
|
---|
33 | #include <locale>
|
---|
34 | #include <ext/stdio_filebuf.h>
|
---|
35 |
|
---|
36 | // On AIX, and perhaps other systems, library initialization order is
|
---|
37 | // not guaranteed. For example, the static initializers for the main
|
---|
38 | // program might run before the static initializers for this library.
|
---|
39 | // That means that we cannot rely on static initialization in the
|
---|
40 | // library; there is no guarantee that things will get initialized in
|
---|
41 | // time. This file contains definitions of all global variables that
|
---|
42 | // require initialization as arrays of characters.
|
---|
43 |
|
---|
44 | // Because <iostream> declares the standard streams to be [io]stream
|
---|
45 | // types instead of say [io]fstream types, it is also necessary to
|
---|
46 | // allocate the actual file buffers in this file.
|
---|
47 | namespace __gnu_cxx
|
---|
48 | {
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | typedef char fake_facet_name[sizeof(char*)]
|
---|
52 | __attribute__ ((aligned(__alignof__(char*))));
|
---|
53 | fake_facet_name facet_name[6 + _GLIBCPP_NUM_CATEGORIES];
|
---|
54 |
|
---|
55 | typedef char fake_locale_Impl[sizeof(locale::_Impl)]
|
---|
56 | __attribute__ ((aligned(__alignof__(locale::_Impl))));
|
---|
57 | fake_locale_Impl c_locale_impl;
|
---|
58 |
|
---|
59 |
|
---|
60 | // NB: The asm directives renames these non-exported, namespace
|
---|
61 | // __gnu_cxx symbols into the mistakenly exported, namespace std
|
---|
62 | // symbols in GLIBCPP_3.2.
|
---|
63 | // The rename syntax is
|
---|
64 | // asm (".symver currentname,oldname@@GLIBCPP_3.2")
|
---|
65 | // At the same time, these new __gnu_cxx symbols are not exported.
|
---|
66 | // In the future, GLIBCXX_ABI > 5 should remove all uses of
|
---|
67 | // _GLIBCPP_ASM_SYMVER in this file.
|
---|
68 | typedef char fake_locale[sizeof(locale)]
|
---|
69 | __attribute__ ((aligned(__alignof__(locale))));
|
---|
70 | fake_locale c_locale;
|
---|
71 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8c_localeE, _ZSt8c_locale, GLIBCPP_3.2)
|
---|
72 |
|
---|
73 | // GLIBCXX_ABI > 5 will not need this symbol at all.
|
---|
74 | // It's here just as a placeholder, as the size of this exported
|
---|
75 | // object changed. The new symbol is not exported.
|
---|
76 | const int o = sizeof(locale::_Impl) - sizeof(char*[_GLIBCPP_NUM_CATEGORIES]);
|
---|
77 | typedef char fake_locale_Impl_compat[o]
|
---|
78 | __attribute__ ((aligned(__alignof__(o))));
|
---|
79 | fake_locale_Impl_compat c_locale_impl_compat;
|
---|
80 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx20c_locale_impl_compatE, _ZSt13c_locale_impl, GLIBCPP_3.2)
|
---|
81 |
|
---|
82 | typedef char fake_facet_vec[sizeof(locale::facet*)]
|
---|
83 | __attribute__ ((aligned(__alignof__(locale::facet*))));
|
---|
84 | fake_facet_vec facet_vec[_GLIBCPP_NUM_FACETS];
|
---|
85 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9facet_vecE, _ZSt9facet_vec, GLIBCPP_3.2)
|
---|
86 |
|
---|
87 | // To support combined facets and caches in facet array
|
---|
88 | typedef char fake_facet_cache_vec[sizeof(locale::facet*)]
|
---|
89 | __attribute__ ((aligned(__alignof__(locale::facet*))));
|
---|
90 | fake_facet_cache_vec facet_cache_vec[2 * _GLIBCPP_NUM_FACETS];
|
---|
91 |
|
---|
92 | typedef char fake_ctype_c[sizeof(std::ctype<char>)]
|
---|
93 | __attribute__ ((aligned(__alignof__(std::ctype<char>))));
|
---|
94 | fake_ctype_c ctype_c;
|
---|
95 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx7ctype_cE, _ZSt7ctype_c, GLIBCPP_3.2)
|
---|
96 |
|
---|
97 | typedef char fake_collate_c[sizeof(std::collate<char>)]
|
---|
98 | __attribute__ ((aligned(__alignof__(std::collate<char>))));
|
---|
99 | fake_collate_c collate_c;
|
---|
100 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9collate_cE, _ZSt9collate_c, GLIBCPP_3.2)
|
---|
101 |
|
---|
102 | typedef char fake_numpunct_c[sizeof(numpunct<char>)]
|
---|
103 | __attribute__ ((aligned(__alignof__(numpunct<char>))));
|
---|
104 | fake_numpunct_c numpunct_c;
|
---|
105 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10numpunct_cE, _ZSt10numpunct_c, GLIBCPP_3.2)
|
---|
106 |
|
---|
107 | typedef char fake_num_get_c[sizeof(num_get<char>)]
|
---|
108 | __attribute__ ((aligned(__alignof__(num_get<char>))));
|
---|
109 | fake_num_get_c num_get_c;
|
---|
110 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9num_get_cE, _ZSt9num_get_c, GLIBCPP_3.2)
|
---|
111 |
|
---|
112 | typedef char fake_num_put_c[sizeof(num_put<char>)]
|
---|
113 | __attribute__ ((aligned(__alignof__(num_put<char>))));
|
---|
114 | fake_num_put_c num_put_c;
|
---|
115 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9num_put_cE, _ZSt9num_put_c, GLIBCPP_3.2)
|
---|
116 |
|
---|
117 | typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
|
---|
118 | __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
|
---|
119 | fake_codecvt_c codecvt_c;
|
---|
120 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9codecvt_cE, _ZSt9codecvt_c, GLIBCPP_3.2)
|
---|
121 |
|
---|
122 | typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
|
---|
123 | __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
|
---|
124 | fake_moneypunct_c moneypunct_tc;
|
---|
125 | fake_moneypunct_c moneypunct_fc;
|
---|
126 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx13moneypunct_tcE,\
|
---|
127 | _ZSt13moneypunct_tc, GLIBCPP_3.2)
|
---|
128 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx13moneypunct_fcE,\
|
---|
129 | _ZSt13moneypunct_fc, GLIBCPP_3.2)
|
---|
130 |
|
---|
131 | typedef char fake_money_get_c[sizeof(money_get<char>)]
|
---|
132 | __attribute__ ((aligned(__alignof__(money_get<char>))));
|
---|
133 | fake_money_get_c money_get_c;
|
---|
134 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11money_get_cE, _ZSt11money_get_c, GLIBCPP_3.2)
|
---|
135 |
|
---|
136 | typedef char fake_money_put_c[sizeof(money_put<char>)]
|
---|
137 | __attribute__ ((aligned(__alignof__(money_put<char>))));
|
---|
138 | fake_money_put_c money_put_c;
|
---|
139 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11money_put_cE, _ZSt11money_put_c, GLIBCPP_3.2)
|
---|
140 |
|
---|
141 | typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
|
---|
142 | __attribute__ ((aligned(__alignof__(__timepunct<char>))));
|
---|
143 | fake_timepunct_c timepunct_c;
|
---|
144 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11timepunct_cE, _ZSt11timepunct_c, GLIBCPP_3.2)
|
---|
145 |
|
---|
146 | typedef char fake_time_get_c[sizeof(time_get<char>)]
|
---|
147 | __attribute__ ((aligned(__alignof__(time_get<char>))));
|
---|
148 | fake_time_get_c time_get_c;
|
---|
149 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10time_get_cE, _ZSt10time_get_c, GLIBCPP_3.2)
|
---|
150 |
|
---|
151 | typedef char fake_time_put_c[sizeof(time_put<char>)]
|
---|
152 | __attribute__ ((aligned(__alignof__(time_put<char>))));
|
---|
153 | fake_time_put_c time_put_c;
|
---|
154 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10time_put_cE, _ZSt10time_put_c, GLIBCPP_3.2)
|
---|
155 |
|
---|
156 | typedef char fake_messages_c[sizeof(messages<char>)]
|
---|
157 | __attribute__ ((aligned(__alignof__(messages<char>))));
|
---|
158 | fake_messages_c messages_c;
|
---|
159 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10messages_cE, _ZSt10messages_c, GLIBCPP_3.2)
|
---|
160 |
|
---|
161 | #ifdef _GLIBCPP_USE_WCHAR_T
|
---|
162 | typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
|
---|
163 | __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
|
---|
164 | fake_wtype_w ctype_w;
|
---|
165 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx7ctype_wE, _ZSt7ctype_w, GLIBCPP_3.2)
|
---|
166 |
|
---|
167 | typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
|
---|
168 | __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
|
---|
169 | fake_wollate_w collate_w;
|
---|
170 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9collate_wE, _ZSt9collate_w, GLIBCPP_3.2)
|
---|
171 |
|
---|
172 | typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
|
---|
173 | __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
|
---|
174 | fake_numpunct_w numpunct_w;
|
---|
175 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10numpunct_wE, _ZSt10numpunct_w, GLIBCPP_3.2)
|
---|
176 |
|
---|
177 | typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
|
---|
178 | __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
|
---|
179 | fake_num_get_w num_get_w;
|
---|
180 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9num_get_wE, _ZSt9num_get_w, GLIBCPP_3.2)
|
---|
181 |
|
---|
182 | typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
|
---|
183 | __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
|
---|
184 | fake_num_put_w num_put_w;
|
---|
185 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9num_put_wE, _ZSt9num_put_w, GLIBCPP_3.2)
|
---|
186 |
|
---|
187 | typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
|
---|
188 | __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
|
---|
189 | fake_wodecvt_w codecvt_w;
|
---|
190 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9codecvt_wE, _ZSt9codecvt_w, GLIBCPP_3.2)
|
---|
191 |
|
---|
192 | typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
|
---|
193 | __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
|
---|
194 | fake_moneypunct_w moneypunct_tw;
|
---|
195 | fake_moneypunct_w moneypunct_fw;
|
---|
196 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx13moneypunct_twE,\
|
---|
197 | _ZSt13moneypunct_tw, GLIBCPP_3.2)
|
---|
198 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx13moneypunct_fwE,\
|
---|
199 | _ZSt13moneypunct_fw, GLIBCPP_3.2)
|
---|
200 |
|
---|
201 | typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
|
---|
202 | __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
|
---|
203 | fake_money_get_w money_get_w;
|
---|
204 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11money_get_wE, _ZSt11money_get_w, GLIBCPP_3.2)
|
---|
205 |
|
---|
206 | typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
|
---|
207 | __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
|
---|
208 | fake_money_put_w money_put_w;
|
---|
209 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11money_put_wE, _ZSt11money_put_w, GLIBCPP_3.2)
|
---|
210 |
|
---|
211 | typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
|
---|
212 | __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
|
---|
213 | fake_timepunct_w timepunct_w;
|
---|
214 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx11timepunct_wE, _ZSt11timepunct_w, GLIBCPP_3.2)
|
---|
215 |
|
---|
216 | typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
|
---|
217 | __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
|
---|
218 | fake_time_get_w time_get_w;
|
---|
219 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10time_get_wE, _ZSt10time_get_w, GLIBCPP_3.2)
|
---|
220 |
|
---|
221 | typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
|
---|
222 | __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
|
---|
223 | fake_time_put_w time_put_w;
|
---|
224 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10time_put_wE, _ZSt10time_put_w, GLIBCPP_3.2)
|
---|
225 |
|
---|
226 | typedef char fake_messages_w[sizeof(messages<wchar_t>)]
|
---|
227 | __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
|
---|
228 | fake_messages_w messages_w;
|
---|
229 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx10messages_wE, _ZSt10messages_w, GLIBCPP_3.2)
|
---|
230 | #endif
|
---|
231 |
|
---|
232 | // Storage for static C locale caches
|
---|
233 | typedef char fake_locale_cache_np_c[sizeof(std::__locale_cache<numpunct<char> >)]
|
---|
234 | __attribute__ ((aligned(__alignof__(std::__locale_cache<numpunct<char> >))));
|
---|
235 | fake_locale_cache_np_c locale_cache_np_c;
|
---|
236 |
|
---|
237 | #ifdef _GLIBCPP_USE_WCHAR_T
|
---|
238 | typedef char fake_locale_cache_np_w[sizeof(std::__locale_cache<numpunct<wchar_t> >)]
|
---|
239 | __attribute__ ((aligned(__alignof__(std::__locale_cache<numpunct<wchar_t> >))));
|
---|
240 | fake_locale_cache_np_w locale_cache_np_w;
|
---|
241 | #endif
|
---|
242 |
|
---|
243 | typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
|
---|
244 | __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
|
---|
245 | fake_filebuf buf_cout;
|
---|
246 | fake_filebuf buf_cin;
|
---|
247 | fake_filebuf buf_cerr;
|
---|
248 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8buf_coutE, _ZSt8buf_cout, GLIBCPP_3.2)
|
---|
249 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx7buf_cinE, _ZSt7buf_cin, GLIBCPP_3.2)
|
---|
250 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8buf_cerrE, _ZSt8buf_cerr, GLIBCPP_3.2)
|
---|
251 |
|
---|
252 | #ifdef _GLIBCPP_USE_WCHAR_T
|
---|
253 | typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
|
---|
254 | __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
|
---|
255 | fake_wfilebuf buf_wcout;
|
---|
256 | fake_wfilebuf buf_wcin;
|
---|
257 | fake_wfilebuf buf_wcerr;
|
---|
258 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9buf_wcoutE, _ZSt9buf_wcout, GLIBCPP_3.2)
|
---|
259 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8buf_wcinE, _ZSt8buf_wcin, GLIBCPP_3.2)
|
---|
260 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx9buf_wcerrE, _ZSt9buf_wcerr, GLIBCPP_3.2)
|
---|
261 | #endif
|
---|
262 |
|
---|
263 | // Globals for once-only runtime initialization of mutex objects. This
|
---|
264 | // allows static initialization of these objects on systems that need a
|
---|
265 | // function call to initialize a mutex. For example, see stl_threads.h.
|
---|
266 | #ifdef __GTHREAD_MUTEX_INIT
|
---|
267 | // Need to provide explicit instantiations of static data for
|
---|
268 | // systems with broken weak linkage support.
|
---|
269 | template __gthread_mutex_t _Swap_lock_struct<0>::_S_swap_lock;
|
---|
270 | #elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
|
---|
271 | __gthread_once_t _GLIBCPP_once = __GTHREAD_ONCE_INIT;
|
---|
272 | __gthread_mutex_t _GLIBCPP_mutex;
|
---|
273 | __gthread_mutex_t *_GLIBCPP_mutex_address;
|
---|
274 |
|
---|
275 | // Once-only initializer function for _GLIBCPP_mutex.
|
---|
276 | void
|
---|
277 | _GLIBCPP_mutex_init ()
|
---|
278 | { __GTHREAD_MUTEX_INIT_FUNCTION (&_GLIBCPP_mutex); }
|
---|
279 |
|
---|
280 | // Once-only initializer function for _GLIBCPP_mutex_address.
|
---|
281 | void
|
---|
282 | _GLIBCPP_mutex_address_init ()
|
---|
283 | { __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address); }
|
---|
284 | #endif
|
---|
285 |
|
---|
286 | // GLIBCXX_ABI.
|
---|
287 | struct __compat
|
---|
288 | {
|
---|
289 | static const char _S_atoms[];
|
---|
290 | };
|
---|
291 | const char __compat::_S_atoms[] = "0123456789eEabcdfABCDF";
|
---|
292 | _GLIBCPP_ASM_SYMVER(_ZN9__gnu_cxx8__compat8_S_atomsE, _ZNSt10__num_base8_S_atomsE, GLIBCPP_3.2)
|
---|
293 | } // namespace __gnu_cxx
|
---|
294 |
|
---|
295 | namespace std
|
---|
296 | {
|
---|
297 | // Standard stream objects.
|
---|
298 | typedef char fake_istream[sizeof(istream)]
|
---|
299 | __attribute__ ((aligned(__alignof__(istream))));
|
---|
300 | typedef char fake_ostream[sizeof(ostream)]
|
---|
301 | __attribute__ ((aligned(__alignof__(ostream))));
|
---|
302 | fake_istream cin;
|
---|
303 | fake_ostream cout;
|
---|
304 | fake_ostream cerr;
|
---|
305 | fake_ostream clog;
|
---|
306 |
|
---|
307 | #ifdef _GLIBCPP_USE_WCHAR_T
|
---|
308 | typedef char fake_wistream[sizeof(wistream)]
|
---|
309 | __attribute__ ((aligned(__alignof__(wistream))));
|
---|
310 | typedef char fake_wostream[sizeof(wostream)]
|
---|
311 | __attribute__ ((aligned(__alignof__(wostream))));
|
---|
312 | fake_wistream wcin;
|
---|
313 | fake_wostream wcout;
|
---|
314 | fake_wostream wcerr;
|
---|
315 | fake_wostream wclog;
|
---|
316 | #endif
|
---|
317 | } // namespace std
|
---|