1 // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
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)
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.
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,
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.
28 #include "bits/c++config.h"
29 #include "bits/gthr.h"
34 #include <ext/stdio_filebuf.h>
35 #include <ext/stdio_sync_filebuf.h>
37 // On AIX, and perhaps other systems, library initialization order is
38 // not guaranteed. For example, the static initializers for the main
39 // program might run before the static initializers for this library.
40 // That means that we cannot rely on static initialization in the
41 // library; there is no guarantee that things will get initialized in
42 // time. This file contains definitions of all global variables that
43 // require initialization as arrays of characters.
45 // NB: asm directives can rename these non-exported, namespace
46 // __gnu_cxx symbols into exported, namespace std symbols with the
47 // appropriate symbol version name.
48 // The rename syntax is
49 // asm (".symver currentname,oldname@@GLIBCPP_3.2")
51 // _GLIBCPP_ASM_SYMVER(currentname, oldname, GLIBCPP_3.2)
55 // Standard stream objects.
56 // NB: Iff <iostream> is included, these definitions become wonky.
57 typedef char fake_istream[sizeof(istream)]
58 __attribute__ ((aligned(__alignof__(istream))));
59 typedef char fake_ostream[sizeof(ostream)]
60 __attribute__ ((aligned(__alignof__(ostream))));
66 #ifdef _GLIBCPP_USE_WCHAR_T
67 typedef char fake_wistream[sizeof(wistream)]
68 __attribute__ ((aligned(__alignof__(wistream))));
69 typedef char fake_wostream[sizeof(wostream)]
70 __attribute__ ((aligned(__alignof__(wostream))));
82 // We use different stream buffer types depending on whether
83 // ios_base::sync_with_stdio(false) has been called.
84 typedef char fake_stdiobuf[sizeof(stdio_sync_filebuf<char>)]
85 __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<char>))));
86 fake_stdiobuf buf_cout_sync;
87 fake_stdiobuf buf_cin_sync;
88 fake_stdiobuf buf_cerr_sync;
90 typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
91 __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
92 fake_filebuf buf_cout;
94 fake_filebuf buf_cerr;
96 #ifdef _GLIBCPP_USE_WCHAR_T
97 typedef char fake_wstdiobuf[sizeof(stdio_sync_filebuf<wchar_t>)]
98 __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<wchar_t>))));
99 fake_wstdiobuf buf_wcout_sync;
100 fake_wstdiobuf buf_wcin_sync;
101 fake_wstdiobuf buf_wcerr_sync;
103 typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
104 __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
105 fake_wfilebuf buf_wcout;
106 fake_wfilebuf buf_wcin;
107 fake_wfilebuf buf_wcerr;
110 typedef char fake_locale_Impl[sizeof(locale::_Impl)]
111 __attribute__ ((aligned(__alignof__(locale::_Impl))));
112 fake_locale_Impl c_locale_impl;
114 typedef char fake_locale[sizeof(locale)]
115 __attribute__ ((aligned(__alignof__(locale))));
116 fake_locale c_locale;
118 typedef char fake_name_vec[sizeof(char*)]
119 __attribute__ ((aligned(__alignof__(char*))));
120 fake_name_vec name_vec[6 + _GLIBCPP_NUM_CATEGORIES];
122 typedef char fake_names[sizeof(char[2])]
123 __attribute__ ((aligned(__alignof__(char[2]))));
124 fake_names name_c[6 + _GLIBCPP_NUM_CATEGORIES];
126 typedef char fake_facet_vec[sizeof(locale::facet*)]
127 __attribute__ ((aligned(__alignof__(locale::facet*))));
128 fake_facet_vec facet_vec[_GLIBCPP_NUM_FACETS];
130 typedef char fake_ctype_c[sizeof(std::ctype<char>)]
131 __attribute__ ((aligned(__alignof__(std::ctype<char>))));
132 fake_ctype_c ctype_c;
134 typedef char fake_collate_c[sizeof(std::collate<char>)]
135 __attribute__ ((aligned(__alignof__(std::collate<char>))));
136 fake_collate_c collate_c;
138 typedef char fake_numpunct_c[sizeof(numpunct<char>)]
139 __attribute__ ((aligned(__alignof__(numpunct<char>))));
140 fake_numpunct_c numpunct_c;
142 typedef char fake_num_get_c[sizeof(num_get<char>)]
143 __attribute__ ((aligned(__alignof__(num_get<char>))));
144 fake_num_get_c num_get_c;
146 typedef char fake_num_put_c[sizeof(num_put<char>)]
147 __attribute__ ((aligned(__alignof__(num_put<char>))));
148 fake_num_put_c num_put_c;
150 typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
151 __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
152 fake_codecvt_c codecvt_c;
154 typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
155 __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
156 fake_moneypunct_c moneypunct_tc;
157 fake_moneypunct_c moneypunct_fc;
159 typedef char fake_money_get_c[sizeof(money_get<char>)]
160 __attribute__ ((aligned(__alignof__(money_get<char>))));
161 fake_money_get_c money_get_c;
163 typedef char fake_money_put_c[sizeof(money_put<char>)]
164 __attribute__ ((aligned(__alignof__(money_put<char>))));
165 fake_money_put_c money_put_c;
167 typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
168 __attribute__ ((aligned(__alignof__(__timepunct<char>))));
169 fake_timepunct_c timepunct_c;
171 typedef char fake_time_get_c[sizeof(time_get<char>)]
172 __attribute__ ((aligned(__alignof__(time_get<char>))));
173 fake_time_get_c time_get_c;
175 typedef char fake_time_put_c[sizeof(time_put<char>)]
176 __attribute__ ((aligned(__alignof__(time_put<char>))));
177 fake_time_put_c time_put_c;
179 typedef char fake_messages_c[sizeof(messages<char>)]
180 __attribute__ ((aligned(__alignof__(messages<char>))));
181 fake_messages_c messages_c;
183 #ifdef _GLIBCPP_USE_WCHAR_T
184 typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
185 __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
186 fake_wtype_w ctype_w;
188 typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
189 __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
190 fake_wollate_w collate_w;
192 typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
193 __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
194 fake_numpunct_w numpunct_w;
196 typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
197 __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
198 fake_num_get_w num_get_w;
200 typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
201 __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
202 fake_num_put_w num_put_w;
204 typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
205 __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
206 fake_wodecvt_w codecvt_w;
208 typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
209 __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
210 fake_moneypunct_w moneypunct_tw;
211 fake_moneypunct_w moneypunct_fw;
213 typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
214 __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
215 fake_money_get_w money_get_w;
217 typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
218 __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
219 fake_money_put_w money_put_w;
221 typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
222 __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
223 fake_timepunct_w timepunct_w;
225 typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
226 __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
227 fake_time_get_w time_get_w;
229 typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
230 __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
231 fake_time_put_w time_put_w;
233 typedef char fake_messages_w[sizeof(messages<wchar_t>)]
234 __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
235 fake_messages_w messages_w;
238 // Globals for once-only runtime initialization of mutex objects. This
239 // allows static initialization of these objects on systems that need a
240 // function call to initialize a mutex. For example, see stl_threads.h.
241 #ifdef __GTHREAD_MUTEX_INIT
242 #elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
243 __gthread_once_t _GLIBCPP_once = __GTHREAD_ONCE_INIT;
244 __gthread_mutex_t _GLIBCPP_mutex;
245 __gthread_mutex_t *_GLIBCPP_mutex_address;
247 // Once-only initializer function for _GLIBCPP_mutex.
249 _GLIBCPP_mutex_init ()
250 { __GTHREAD_MUTEX_INIT_FUNCTION (&_GLIBCPP_mutex); }
252 // Once-only initializer function for _GLIBCPP_mutex_address.
254 _GLIBCPP_mutex_address_init ()
255 { __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address); }
257 } // namespace __gnu_cxx