1*404b540aSrobert // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
2*404b540aSrobert // Free Software Foundation, Inc.
3*404b540aSrobert //
4*404b540aSrobert // This file is part of the GNU ISO C++ Library. This library is free
5*404b540aSrobert // software; you can redistribute it and/or modify it under the
6*404b540aSrobert // terms of the GNU General Public License as published by the
7*404b540aSrobert // Free Software Foundation; either version 2, or (at your option)
8*404b540aSrobert // any later version.
9*404b540aSrobert
10*404b540aSrobert // This library is distributed in the hope that it will be useful,
11*404b540aSrobert // but WITHOUT ANY WARRANTY; without even the implied warranty of
12*404b540aSrobert // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*404b540aSrobert // GNU General Public License for more details.
14*404b540aSrobert
15*404b540aSrobert // You should have received a copy of the GNU General Public License along
16*404b540aSrobert // with this library; see the file COPYING. If not, write to the Free
17*404b540aSrobert // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18*404b540aSrobert // USA.
19*404b540aSrobert
20*404b540aSrobert // As a special exception, you may use this file as part of a free software
21*404b540aSrobert // library without restriction. Specifically, if other files instantiate
22*404b540aSrobert // templates or use macros or inline functions from this file, or you compile
23*404b540aSrobert // this file and link it with other files to produce an executable, this
24*404b540aSrobert // file does not by itself cause the resulting executable to be covered by
25*404b540aSrobert // the GNU General Public License. This exception does not however
26*404b540aSrobert // invalidate any other reasons why the executable file might be covered by
27*404b540aSrobert // the GNU General Public License.
28*404b540aSrobert
29*404b540aSrobert #include <clocale>
30*404b540aSrobert #include <cstring>
31*404b540aSrobert #include <cstdlib> // For getenv, free.
32*404b540aSrobert #include <cctype>
33*404b540aSrobert #include <cwctype> // For towupper, etc.
34*404b540aSrobert #include <locale>
35*404b540aSrobert #include <ext/concurrence.h>
36*404b540aSrobert
37*404b540aSrobert namespace
38*404b540aSrobert {
39*404b540aSrobert __gnu_cxx::__mutex&
get_locale_mutex()40*404b540aSrobert get_locale_mutex()
41*404b540aSrobert {
42*404b540aSrobert static __gnu_cxx::__mutex locale_mutex;
43*404b540aSrobert return locale_mutex;
44*404b540aSrobert }
45*404b540aSrobert
46*404b540aSrobert using namespace std;
47*404b540aSrobert
48*404b540aSrobert typedef char fake_locale_Impl[sizeof(locale::_Impl)]
49*404b540aSrobert __attribute__ ((aligned(__alignof__(locale::_Impl))));
50*404b540aSrobert fake_locale_Impl c_locale_impl;
51*404b540aSrobert
52*404b540aSrobert typedef char fake_locale[sizeof(locale)]
53*404b540aSrobert __attribute__ ((aligned(__alignof__(locale))));
54*404b540aSrobert fake_locale c_locale;
55*404b540aSrobert
56*404b540aSrobert typedef char fake_name_vec[sizeof(char*)]
57*404b540aSrobert __attribute__ ((aligned(__alignof__(char*))));
58*404b540aSrobert fake_name_vec name_vec[6 + _GLIBCXX_NUM_CATEGORIES];
59*404b540aSrobert
60*404b540aSrobert typedef char fake_names[sizeof(char[2])]
61*404b540aSrobert __attribute__ ((aligned(__alignof__(char[2]))));
62*404b540aSrobert fake_names name_c[6 + _GLIBCXX_NUM_CATEGORIES];
63*404b540aSrobert
64*404b540aSrobert typedef char fake_facet_vec[sizeof(locale::facet*)]
65*404b540aSrobert __attribute__ ((aligned(__alignof__(locale::facet*))));
66*404b540aSrobert fake_facet_vec facet_vec[_GLIBCXX_NUM_FACETS];
67*404b540aSrobert
68*404b540aSrobert typedef char fake_cache_vec[sizeof(locale::facet*)]
69*404b540aSrobert __attribute__ ((aligned(__alignof__(locale::facet*))));
70*404b540aSrobert fake_cache_vec cache_vec[_GLIBCXX_NUM_FACETS];
71*404b540aSrobert
72*404b540aSrobert typedef char fake_ctype_c[sizeof(std::ctype<char>)]
73*404b540aSrobert __attribute__ ((aligned(__alignof__(std::ctype<char>))));
74*404b540aSrobert fake_ctype_c ctype_c;
75*404b540aSrobert
76*404b540aSrobert typedef char fake_collate_c[sizeof(std::collate<char>)]
77*404b540aSrobert __attribute__ ((aligned(__alignof__(std::collate<char>))));
78*404b540aSrobert fake_collate_c collate_c;
79*404b540aSrobert
80*404b540aSrobert typedef char fake_numpunct_c[sizeof(numpunct<char>)]
81*404b540aSrobert __attribute__ ((aligned(__alignof__(numpunct<char>))));
82*404b540aSrobert fake_numpunct_c numpunct_c;
83*404b540aSrobert
84*404b540aSrobert typedef char fake_num_get_c[sizeof(num_get<char>)]
85*404b540aSrobert __attribute__ ((aligned(__alignof__(num_get<char>))));
86*404b540aSrobert fake_num_get_c num_get_c;
87*404b540aSrobert
88*404b540aSrobert typedef char fake_num_put_c[sizeof(num_put<char>)]
89*404b540aSrobert __attribute__ ((aligned(__alignof__(num_put<char>))));
90*404b540aSrobert fake_num_put_c num_put_c;
91*404b540aSrobert
92*404b540aSrobert typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
93*404b540aSrobert __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
94*404b540aSrobert fake_codecvt_c codecvt_c;
95*404b540aSrobert
96*404b540aSrobert typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
97*404b540aSrobert __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
98*404b540aSrobert fake_moneypunct_c moneypunct_ct;
99*404b540aSrobert fake_moneypunct_c moneypunct_cf;
100*404b540aSrobert
101*404b540aSrobert typedef char fake_money_get_c[sizeof(money_get<char>)]
102*404b540aSrobert __attribute__ ((aligned(__alignof__(money_get<char>))));
103*404b540aSrobert fake_money_get_c money_get_c;
104*404b540aSrobert
105*404b540aSrobert typedef char fake_money_put_c[sizeof(money_put<char>)]
106*404b540aSrobert __attribute__ ((aligned(__alignof__(money_put<char>))));
107*404b540aSrobert fake_money_put_c money_put_c;
108*404b540aSrobert
109*404b540aSrobert typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
110*404b540aSrobert __attribute__ ((aligned(__alignof__(__timepunct<char>))));
111*404b540aSrobert fake_timepunct_c timepunct_c;
112*404b540aSrobert
113*404b540aSrobert typedef char fake_time_get_c[sizeof(time_get<char>)]
114*404b540aSrobert __attribute__ ((aligned(__alignof__(time_get<char>))));
115*404b540aSrobert fake_time_get_c time_get_c;
116*404b540aSrobert
117*404b540aSrobert typedef char fake_time_put_c[sizeof(time_put<char>)]
118*404b540aSrobert __attribute__ ((aligned(__alignof__(time_put<char>))));
119*404b540aSrobert fake_time_put_c time_put_c;
120*404b540aSrobert
121*404b540aSrobert typedef char fake_messages_c[sizeof(messages<char>)]
122*404b540aSrobert __attribute__ ((aligned(__alignof__(messages<char>))));
123*404b540aSrobert fake_messages_c messages_c;
124*404b540aSrobert
125*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
126*404b540aSrobert typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
127*404b540aSrobert __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
128*404b540aSrobert fake_wtype_w ctype_w;
129*404b540aSrobert
130*404b540aSrobert typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
131*404b540aSrobert __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
132*404b540aSrobert fake_wollate_w collate_w;
133*404b540aSrobert
134*404b540aSrobert typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
135*404b540aSrobert __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
136*404b540aSrobert fake_numpunct_w numpunct_w;
137*404b540aSrobert
138*404b540aSrobert typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
139*404b540aSrobert __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
140*404b540aSrobert fake_num_get_w num_get_w;
141*404b540aSrobert
142*404b540aSrobert typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
143*404b540aSrobert __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
144*404b540aSrobert fake_num_put_w num_put_w;
145*404b540aSrobert
146*404b540aSrobert typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
147*404b540aSrobert __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
148*404b540aSrobert fake_wodecvt_w codecvt_w;
149*404b540aSrobert
150*404b540aSrobert typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
151*404b540aSrobert __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
152*404b540aSrobert fake_moneypunct_w moneypunct_wt;
153*404b540aSrobert fake_moneypunct_w moneypunct_wf;
154*404b540aSrobert
155*404b540aSrobert typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
156*404b540aSrobert __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
157*404b540aSrobert fake_money_get_w money_get_w;
158*404b540aSrobert
159*404b540aSrobert typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
160*404b540aSrobert __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
161*404b540aSrobert fake_money_put_w money_put_w;
162*404b540aSrobert
163*404b540aSrobert typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
164*404b540aSrobert __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
165*404b540aSrobert fake_timepunct_w timepunct_w;
166*404b540aSrobert
167*404b540aSrobert typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
168*404b540aSrobert __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
169*404b540aSrobert fake_time_get_w time_get_w;
170*404b540aSrobert
171*404b540aSrobert typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
172*404b540aSrobert __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
173*404b540aSrobert fake_time_put_w time_put_w;
174*404b540aSrobert
175*404b540aSrobert typedef char fake_messages_w[sizeof(messages<wchar_t>)]
176*404b540aSrobert __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
177*404b540aSrobert fake_messages_w messages_w;
178*404b540aSrobert #endif
179*404b540aSrobert
180*404b540aSrobert // Storage for "C" locale caches.
181*404b540aSrobert typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)]
182*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>))));
183*404b540aSrobert fake_num_cache_c numpunct_cache_c;
184*404b540aSrobert
185*404b540aSrobert typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char, true>)]
186*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char, true>))));
187*404b540aSrobert fake_money_cache_c moneypunct_cache_ct;
188*404b540aSrobert fake_money_cache_c moneypunct_cache_cf;
189*404b540aSrobert
190*404b540aSrobert typedef char fake_time_cache_c[sizeof(std::__timepunct_cache<char>)]
191*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__timepunct_cache<char>))));
192*404b540aSrobert fake_time_cache_c timepunct_cache_c;
193*404b540aSrobert
194*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
195*404b540aSrobert typedef char fake_num_cache_w[sizeof(std::__numpunct_cache<wchar_t>)]
196*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>))));
197*404b540aSrobert fake_num_cache_w numpunct_cache_w;
198*404b540aSrobert
199*404b540aSrobert typedef char fake_money_cache_w[sizeof(std::__moneypunct_cache<wchar_t,true>)]
200*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t,true>))));
201*404b540aSrobert fake_money_cache_w moneypunct_cache_wt;
202*404b540aSrobert fake_money_cache_w moneypunct_cache_wf;
203*404b540aSrobert
204*404b540aSrobert typedef char fake_time_cache_w[sizeof(std::__timepunct_cache<wchar_t>)]
205*404b540aSrobert __attribute__ ((aligned(__alignof__(std::__timepunct_cache<wchar_t>))));
206*404b540aSrobert fake_time_cache_w timepunct_cache_w;
207*404b540aSrobert #endif
208*404b540aSrobert } // anonymous namespace
209*404b540aSrobert
_GLIBCXX_BEGIN_NAMESPACE(std)210*404b540aSrobert _GLIBCXX_BEGIN_NAMESPACE(std)
211*404b540aSrobert
212*404b540aSrobert locale::locale() throw() : _M_impl(0)
213*404b540aSrobert {
214*404b540aSrobert _S_initialize();
215*404b540aSrobert __gnu_cxx::__scoped_lock sentry(get_locale_mutex());
216*404b540aSrobert _S_global->_M_add_reference();
217*404b540aSrobert _M_impl = _S_global;
218*404b540aSrobert }
219*404b540aSrobert
220*404b540aSrobert locale
global(const locale & __other)221*404b540aSrobert locale::global(const locale& __other)
222*404b540aSrobert {
223*404b540aSrobert _S_initialize();
224*404b540aSrobert _Impl* __old;
225*404b540aSrobert {
226*404b540aSrobert __gnu_cxx::__scoped_lock sentry(get_locale_mutex());
227*404b540aSrobert __old = _S_global;
228*404b540aSrobert __other._M_impl->_M_add_reference();
229*404b540aSrobert _S_global = __other._M_impl;
230*404b540aSrobert const string __other_name = __other.name();
231*404b540aSrobert if (__other_name != "*")
232*404b540aSrobert setlocale(LC_ALL, __other_name.c_str());
233*404b540aSrobert }
234*404b540aSrobert
235*404b540aSrobert // Reference count sanity check: one reference removed for the
236*404b540aSrobert // subsition of __other locale, one added by return-by-value. Net
237*404b540aSrobert // difference: zero. When the returned locale object's destrutor
238*404b540aSrobert // is called, then the reference count is decremented and possibly
239*404b540aSrobert // destroyed.
240*404b540aSrobert return locale(__old);
241*404b540aSrobert }
242*404b540aSrobert
243*404b540aSrobert const locale&
classic()244*404b540aSrobert locale::classic()
245*404b540aSrobert {
246*404b540aSrobert _S_initialize();
247*404b540aSrobert return reinterpret_cast<const locale&>(c_locale);
248*404b540aSrobert }
249*404b540aSrobert
250*404b540aSrobert void
_S_initialize_once()251*404b540aSrobert locale::_S_initialize_once()
252*404b540aSrobert {
253*404b540aSrobert // 2 references.
254*404b540aSrobert // One reference for _S_classic, one for _S_global
255*404b540aSrobert _S_classic = new (&c_locale_impl) _Impl(2);
256*404b540aSrobert _S_global = _S_classic;
257*404b540aSrobert new (&c_locale) locale(_S_classic);
258*404b540aSrobert }
259*404b540aSrobert
260*404b540aSrobert void
_S_initialize()261*404b540aSrobert locale::_S_initialize()
262*404b540aSrobert {
263*404b540aSrobert #ifdef __GTHREADS
264*404b540aSrobert if (__gthread_active_p())
265*404b540aSrobert __gthread_once(&_S_once, _S_initialize_once);
266*404b540aSrobert #endif
267*404b540aSrobert if (!_S_classic)
268*404b540aSrobert _S_initialize_once();
269*404b540aSrobert }
270*404b540aSrobert
271*404b540aSrobert // Definitions for static const data members of locale::_Impl
272*404b540aSrobert const locale::id* const
273*404b540aSrobert locale::_Impl::_S_id_ctype[] =
274*404b540aSrobert {
275*404b540aSrobert &std::ctype<char>::id,
276*404b540aSrobert &codecvt<char, char, mbstate_t>::id,
277*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
278*404b540aSrobert &std::ctype<wchar_t>::id,
279*404b540aSrobert &codecvt<wchar_t, char, mbstate_t>::id,
280*404b540aSrobert #endif
281*404b540aSrobert 0
282*404b540aSrobert };
283*404b540aSrobert
284*404b540aSrobert const locale::id* const
285*404b540aSrobert locale::_Impl::_S_id_numeric[] =
286*404b540aSrobert {
287*404b540aSrobert &num_get<char>::id,
288*404b540aSrobert &num_put<char>::id,
289*404b540aSrobert &numpunct<char>::id,
290*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
291*404b540aSrobert &num_get<wchar_t>::id,
292*404b540aSrobert &num_put<wchar_t>::id,
293*404b540aSrobert &numpunct<wchar_t>::id,
294*404b540aSrobert #endif
295*404b540aSrobert 0
296*404b540aSrobert };
297*404b540aSrobert
298*404b540aSrobert const locale::id* const
299*404b540aSrobert locale::_Impl::_S_id_collate[] =
300*404b540aSrobert {
301*404b540aSrobert &std::collate<char>::id,
302*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
303*404b540aSrobert &std::collate<wchar_t>::id,
304*404b540aSrobert #endif
305*404b540aSrobert 0
306*404b540aSrobert };
307*404b540aSrobert
308*404b540aSrobert const locale::id* const
309*404b540aSrobert locale::_Impl::_S_id_time[] =
310*404b540aSrobert {
311*404b540aSrobert &__timepunct<char>::id,
312*404b540aSrobert &time_get<char>::id,
313*404b540aSrobert &time_put<char>::id,
314*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
315*404b540aSrobert &__timepunct<wchar_t>::id,
316*404b540aSrobert &time_get<wchar_t>::id,
317*404b540aSrobert &time_put<wchar_t>::id,
318*404b540aSrobert #endif
319*404b540aSrobert 0
320*404b540aSrobert };
321*404b540aSrobert
322*404b540aSrobert const locale::id* const
323*404b540aSrobert locale::_Impl::_S_id_monetary[] =
324*404b540aSrobert {
325*404b540aSrobert &money_get<char>::id,
326*404b540aSrobert &money_put<char>::id,
327*404b540aSrobert &moneypunct<char, false>::id,
328*404b540aSrobert &moneypunct<char, true >::id,
329*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
330*404b540aSrobert &money_get<wchar_t>::id,
331*404b540aSrobert &money_put<wchar_t>::id,
332*404b540aSrobert &moneypunct<wchar_t, false>::id,
333*404b540aSrobert &moneypunct<wchar_t, true >::id,
334*404b540aSrobert #endif
335*404b540aSrobert 0
336*404b540aSrobert };
337*404b540aSrobert
338*404b540aSrobert const locale::id* const
339*404b540aSrobert locale::_Impl::_S_id_messages[] =
340*404b540aSrobert {
341*404b540aSrobert &std::messages<char>::id,
342*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
343*404b540aSrobert &std::messages<wchar_t>::id,
344*404b540aSrobert #endif
345*404b540aSrobert 0
346*404b540aSrobert };
347*404b540aSrobert
348*404b540aSrobert const locale::id* const* const
349*404b540aSrobert locale::_Impl::_S_facet_categories[] =
350*404b540aSrobert {
351*404b540aSrobert // Order must match the decl order in class locale.
352*404b540aSrobert locale::_Impl::_S_id_ctype,
353*404b540aSrobert locale::_Impl::_S_id_numeric,
354*404b540aSrobert locale::_Impl::_S_id_collate,
355*404b540aSrobert locale::_Impl::_S_id_time,
356*404b540aSrobert locale::_Impl::_S_id_monetary,
357*404b540aSrobert locale::_Impl::_S_id_messages,
358*404b540aSrobert 0
359*404b540aSrobert };
360*404b540aSrobert
361*404b540aSrobert // Construct "C" _Impl.
362*404b540aSrobert locale::_Impl::
_Impl(size_t __refs)363*404b540aSrobert _Impl(size_t __refs) throw()
364*404b540aSrobert : _M_refcount(__refs), _M_facets(0), _M_facets_size(_GLIBCXX_NUM_FACETS),
365*404b540aSrobert _M_caches(0), _M_names(0)
366*404b540aSrobert {
367*404b540aSrobert _M_facets = new (&facet_vec) const facet*[_M_facets_size];
368*404b540aSrobert _M_caches = new (&cache_vec) const facet*[_M_facets_size];
369*404b540aSrobert for (size_t __i = 0; __i < _M_facets_size; ++__i)
370*404b540aSrobert _M_facets[__i] = _M_caches[__i] = 0;
371*404b540aSrobert
372*404b540aSrobert // Name the categories.
373*404b540aSrobert _M_names = new (&name_vec) char*[_S_categories_size];
374*404b540aSrobert _M_names[0] = new (&name_c[0]) char[2];
375*404b540aSrobert std::memcpy(_M_names[0], locale::facet::_S_get_c_name(), 2);
376*404b540aSrobert for (size_t __j = 1; __j < _S_categories_size; ++__j)
377*404b540aSrobert _M_names[__j] = 0;
378*404b540aSrobert
379*404b540aSrobert // This is needed as presently the C++ version of "C" locales
380*404b540aSrobert // != data in the underlying locale model for __timepunct,
381*404b540aSrobert // numpunct, and moneypunct. Also, the "C" locales must be
382*404b540aSrobert // constructed in a way such that they are pre-allocated.
383*404b540aSrobert // NB: Set locale::facets(ref) count to one so that each individual
384*404b540aSrobert // facet is not destroyed when the locale (and thus locale::_Impl) is
385*404b540aSrobert // destroyed.
386*404b540aSrobert _M_init_facet(new (&ctype_c) std::ctype<char>(0, false, 1));
387*404b540aSrobert _M_init_facet(new (&codecvt_c) codecvt<char, char, mbstate_t>(1));
388*404b540aSrobert
389*404b540aSrobert typedef __numpunct_cache<char> num_cache_c;
390*404b540aSrobert num_cache_c* __npc = new (&numpunct_cache_c) num_cache_c(2);
391*404b540aSrobert _M_init_facet(new (&numpunct_c) numpunct<char>(__npc, 1));
392*404b540aSrobert
393*404b540aSrobert _M_init_facet(new (&num_get_c) num_get<char>(1));
394*404b540aSrobert _M_init_facet(new (&num_put_c) num_put<char>(1));
395*404b540aSrobert _M_init_facet(new (&collate_c) std::collate<char>(1));
396*404b540aSrobert
397*404b540aSrobert typedef __moneypunct_cache<char, false> money_cache_cf;
398*404b540aSrobert typedef __moneypunct_cache<char, true> money_cache_ct;
399*404b540aSrobert money_cache_cf* __mpcf = new (&moneypunct_cache_cf) money_cache_cf(2);
400*404b540aSrobert _M_init_facet(new (&moneypunct_cf) moneypunct<char, false>(__mpcf, 1));
401*404b540aSrobert money_cache_ct* __mpct = new (&moneypunct_cache_ct) money_cache_ct(2);
402*404b540aSrobert _M_init_facet(new (&moneypunct_ct) moneypunct<char, true>(__mpct, 1));
403*404b540aSrobert
404*404b540aSrobert _M_init_facet(new (&money_get_c) money_get<char>(1));
405*404b540aSrobert _M_init_facet(new (&money_put_c) money_put<char>(1));
406*404b540aSrobert
407*404b540aSrobert typedef __timepunct_cache<char> time_cache_c;
408*404b540aSrobert time_cache_c* __tpc = new (&timepunct_cache_c) time_cache_c(2);
409*404b540aSrobert _M_init_facet(new (&timepunct_c) __timepunct<char>(__tpc, 1));
410*404b540aSrobert
411*404b540aSrobert _M_init_facet(new (&time_get_c) time_get<char>(1));
412*404b540aSrobert _M_init_facet(new (&time_put_c) time_put<char>(1));
413*404b540aSrobert _M_init_facet(new (&messages_c) std::messages<char>(1));
414*404b540aSrobert
415*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
416*404b540aSrobert _M_init_facet(new (&ctype_w) std::ctype<wchar_t>(1));
417*404b540aSrobert _M_init_facet(new (&codecvt_w) codecvt<wchar_t, char, mbstate_t>(1));
418*404b540aSrobert
419*404b540aSrobert typedef __numpunct_cache<wchar_t> num_cache_w;
420*404b540aSrobert num_cache_w* __npw = new (&numpunct_cache_w) num_cache_w(2);
421*404b540aSrobert _M_init_facet(new (&numpunct_w) numpunct<wchar_t>(__npw, 1));
422*404b540aSrobert
423*404b540aSrobert _M_init_facet(new (&num_get_w) num_get<wchar_t>(1));
424*404b540aSrobert _M_init_facet(new (&num_put_w) num_put<wchar_t>(1));
425*404b540aSrobert _M_init_facet(new (&collate_w) std::collate<wchar_t>(1));
426*404b540aSrobert
427*404b540aSrobert typedef __moneypunct_cache<wchar_t, false> money_cache_wf;
428*404b540aSrobert typedef __moneypunct_cache<wchar_t, true> money_cache_wt;
429*404b540aSrobert money_cache_wf* __mpwf = new (&moneypunct_cache_wf) money_cache_wf(2);
430*404b540aSrobert _M_init_facet(new (&moneypunct_wf) moneypunct<wchar_t, false>(__mpwf, 1));
431*404b540aSrobert money_cache_wt* __mpwt = new (&moneypunct_cache_wt) money_cache_wt(2);
432*404b540aSrobert _M_init_facet(new (&moneypunct_wt) moneypunct<wchar_t, true>(__mpwt, 1));
433*404b540aSrobert
434*404b540aSrobert _M_init_facet(new (&money_get_w) money_get<wchar_t>(1));
435*404b540aSrobert _M_init_facet(new (&money_put_w) money_put<wchar_t>(1));
436*404b540aSrobert
437*404b540aSrobert typedef __timepunct_cache<wchar_t> time_cache_w;
438*404b540aSrobert time_cache_w* __tpw = new (&timepunct_cache_w) time_cache_w(2);
439*404b540aSrobert _M_init_facet(new (&timepunct_w) __timepunct<wchar_t>(__tpw, 1));
440*404b540aSrobert
441*404b540aSrobert _M_init_facet(new (&time_get_w) time_get<wchar_t>(1));
442*404b540aSrobert _M_init_facet(new (&time_put_w) time_put<wchar_t>(1));
443*404b540aSrobert _M_init_facet(new (&messages_w) std::messages<wchar_t>(1));
444*404b540aSrobert #endif
445*404b540aSrobert
446*404b540aSrobert // This locale is safe to pre-cache, after all the facets have
447*404b540aSrobert // been created and installed.
448*404b540aSrobert _M_caches[numpunct<char>::id._M_id()] = __npc;
449*404b540aSrobert _M_caches[moneypunct<char, false>::id._M_id()] = __mpcf;
450*404b540aSrobert _M_caches[moneypunct<char, true>::id._M_id()] = __mpct;
451*404b540aSrobert _M_caches[__timepunct<char>::id._M_id()] = __tpc;
452*404b540aSrobert #ifdef _GLIBCXX_USE_WCHAR_T
453*404b540aSrobert _M_caches[numpunct<wchar_t>::id._M_id()] = __npw;
454*404b540aSrobert _M_caches[moneypunct<wchar_t, false>::id._M_id()] = __mpwf;
455*404b540aSrobert _M_caches[moneypunct<wchar_t, true>::id._M_id()] = __mpwt;
456*404b540aSrobert _M_caches[__timepunct<wchar_t>::id._M_id()] = __tpw;
457*404b540aSrobert #endif
458*404b540aSrobert }
459*404b540aSrobert
460*404b540aSrobert _GLIBCXX_END_NAMESPACE
461