]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/src/globals.cc
localefwd.h (class locale): Add static member _S_num_extra_categories...
[thirdparty/gcc.git] / libstdc++-v3 / src / globals.cc
CommitLineData
d3a193e3 1// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
bfd7f4ec
MM
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
91bfd02d
JDA
28#include "bits/c++config.h"
29#include "bits/gthr.h"
5de197f2 30#include <fstream>
bfd7f4ec
MM
31#include <istream>
32#include <ostream>
d3a193e3 33#include <locale>
5cdd50a5 34#include <ext/stdio_filebuf.h>
bfd7f4ec 35
5de197f2
BK
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.
bfd7f4ec 43
5de197f2
BK
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.
47namespace std
48{
1f46fc8e 49 // Standard "C" locale.
d3a193e3
BK
50 typedef char fake_locale[sizeof(locale)]
51 __attribute__ ((aligned(__alignof__(locale))));
52 fake_locale c_locale;
53
1f46fc8e
BK
54 typedef char fake_locale_Impl[sizeof(locale::_Impl)]
55 __attribute__ ((aligned(__alignof__(locale::_Impl))));
d3a193e3
BK
56 fake_locale_Impl c_locale_impl;
57
58 typedef char fake_facet_vec[sizeof(locale::facet*)]
59 __attribute__ ((aligned(__alignof__(locale::facet*))));
60 fake_facet_vec facet_vec[_GLIBCPP_NUM_FACETS];
1f46fc8e 61
aa53f832
PC
62 typedef char fake_facet_name[sizeof(char*)]
63 __attribute__ ((aligned(__alignof__(char*))));
64 fake_facet_name facet_name[6 + _GLIBCPP_NUM_CATEGORIES];
65
d3a193e3
BK
66 typedef char fake_ctype_c[sizeof(std::ctype<char>)]
67 __attribute__ ((aligned(__alignof__(std::ctype<char>))));
68 fake_ctype_c ctype_c;
69
70 typedef char fake_collate_c[sizeof(std::collate<char>)]
71 __attribute__ ((aligned(__alignof__(std::collate<char>))));
72 fake_collate_c collate_c;
73
74 typedef char fake_numpunct_c[sizeof(numpunct<char>)]
75 __attribute__ ((aligned(__alignof__(numpunct<char>))));
76 fake_numpunct_c numpunct_c;
77
78 typedef char fake_num_get_c[sizeof(num_get<char>)]
79 __attribute__ ((aligned(__alignof__(num_get<char>))));
80 fake_num_get_c num_get_c;
81
82 typedef char fake_num_put_c[sizeof(num_put<char>)]
83 __attribute__ ((aligned(__alignof__(num_put<char>))));
84 fake_num_put_c num_put_c;
85
86 typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
87 __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
88 fake_codecvt_c codecvt_c;
89
90 typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
91 __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
92 fake_moneypunct_c moneypunct_tc;
93 fake_moneypunct_c moneypunct_fc;
94
95 typedef char fake_money_get_c[sizeof(money_get<char>)]
96 __attribute__ ((aligned(__alignof__(money_get<char>))));
97 fake_money_get_c money_get_c;
98
99 typedef char fake_money_put_c[sizeof(money_put<char>)]
100 __attribute__ ((aligned(__alignof__(money_put<char>))));
101 fake_money_put_c money_put_c;
102
103 typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
104 __attribute__ ((aligned(__alignof__(__timepunct<char>))));
105 fake_timepunct_c timepunct_c;
106
107 typedef char fake_time_get_c[sizeof(time_get<char>)]
108 __attribute__ ((aligned(__alignof__(time_get<char>))));
109 fake_time_get_c time_get_c;
110
111 typedef char fake_time_put_c[sizeof(time_put<char>)]
112 __attribute__ ((aligned(__alignof__(time_put<char>))));
113 fake_time_put_c time_put_c;
114
115 typedef char fake_messages_c[sizeof(messages<char>)]
116 __attribute__ ((aligned(__alignof__(messages<char>))));
117 fake_messages_c messages_c;
118
119#ifdef _GLIBCPP_USE_WCHAR_T
120 typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
121 __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
122 fake_wtype_w ctype_w;
123
124 typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
125 __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
126 fake_wollate_w collate_w;
127
128 typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
129 __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
130 fake_numpunct_w numpunct_w;
131
132 typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
133 __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
134 fake_num_get_w num_get_w;
135
136 typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
137 __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
138 fake_num_put_w num_put_w;
139
140 typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
141 __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
142 fake_wodecvt_w codecvt_w;
143
144 typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
145 __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
146 fake_moneypunct_w moneypunct_tw;
147 fake_moneypunct_w moneypunct_fw;
148
149 typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
150 __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
151 fake_money_get_w money_get_w;
1f46fc8e 152
d3a193e3
BK
153 typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
154 __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
155 fake_money_put_w money_put_w;
156
157 typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
158 __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
159 fake_timepunct_w timepunct_w;
160
161 typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
162 __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
163 fake_time_get_w time_get_w;
164
165 typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
166 __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
167 fake_time_put_w time_put_w;
168
169 typedef char fake_messages_w[sizeof(messages<wchar_t>)]
170 __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
171 fake_messages_w messages_w;
172#endif
1f46fc8e
BK
173
174 // Standard stream objects.
5de197f2
BK
175 typedef char fake_istream[sizeof(istream)]
176 __attribute__ ((aligned(__alignof__(istream))));
177 typedef char fake_ostream[sizeof(ostream)]
178 __attribute__ ((aligned(__alignof__(ostream))));
bfd7f4ec
MM
179 fake_istream cin;
180 fake_ostream cout;
181 fake_ostream cerr;
182 fake_ostream clog;
183
5cdd50a5
BK
184 typedef char fake_filebuf[sizeof(__gnu_cxx::stdio_filebuf<char>)]
185 __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<char>))));
5de197f2
BK
186 fake_filebuf buf_cout;
187 fake_filebuf buf_cin;
188 fake_filebuf buf_cerr;
bfd7f4ec 189
5de197f2
BK
190#ifdef _GLIBCPP_USE_WCHAR_T
191 typedef char fake_wistream[sizeof(wistream)]
192 __attribute__ ((aligned(__alignof__(wistream))));
193 typedef char fake_wostream[sizeof(wostream)]
194 __attribute__ ((aligned(__alignof__(wostream))));
bfd7f4ec
MM
195 fake_wistream wcin;
196 fake_wostream wcout;
197 fake_wostream wcerr;
198 fake_wostream wclog;
5de197f2 199
5cdd50a5
BK
200 typedef char fake_wfilebuf[sizeof(__gnu_cxx::stdio_filebuf<wchar_t>)]
201 __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<wchar_t>))));
5de197f2
BK
202 fake_wfilebuf buf_wcout;
203 fake_wfilebuf buf_wcin;
204 fake_wfilebuf buf_wcerr;
bfd7f4ec 205#endif
91bfd02d 206
1f46fc8e
BK
207 // Globals for once-only runtime initialization of mutex objects. This
208 // allows static initialization of these objects on systems that need a
209 // function call to initialize a mutex. For example, see stl_threads.h.
91bfd02d 210#ifdef __GTHREAD_MUTEX_INIT
5b5e609d
BK
211 // Need to provide explicit instantiations of static data for
212 // systems with broken weak linkage support.
213 template __gthread_mutex_t _Swap_lock_struct<0>::_S_swap_lock;
91bfd02d 214#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
1f46fc8e
BK
215 __gthread_once_t _GLIBCPP_once = __GTHREAD_ONCE_INIT;
216 __gthread_mutex_t _GLIBCPP_mutex;
217 __gthread_mutex_t *_GLIBCPP_mutex_address;
218
219 // Once-only initializer function for _GLIBCPP_mutex.
220 void
221 _GLIBCPP_mutex_init ()
222 { __GTHREAD_MUTEX_INIT_FUNCTION (&_GLIBCPP_mutex); }
91bfd02d 223
1f46fc8e
BK
224 // Once-only initializer function for _GLIBCPP_mutex_address.
225 void
226 _GLIBCPP_mutex_address_init ()
227 { __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address); }
91bfd02d 228#endif
bfd7f4ec 229}