Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
locale_classic.cpp
Go to the documentation of this file.
1
29#define _RWSTD_LIB_SRC
30#include <rw/_defs.h>
31
32#include <new> // for placment new
33
34#include <loc/_locale.h> // for locale
35#include "once.h" // for __rw_once()
36
37
39
40// static buffer for the classic "C" locale object
41static union {
42 void* _C_align;
43 char _C_buf [sizeof (_STD::locale)];
44} __rw_classic;
45
46
47// init-once flag for the classic "C" locale object
48static __rw_once_t
49__rw_classic_once_init = _RWSTD_ONCE_INIT;
50
51
52extern "C" {
53
54// one-time initializer for the classic "C" locale object
55static void
56__rw_init_classic ()
57{
58#ifdef _RWSTDDEBUG
59
60 static int init;
61
62 // paranoid check: verify that one-time initialization works
63 _RWSTD_ASSERT (0 == init);
64
65 ++init;
66
67#endif // _RWSTDDEBUG
68
69 // construct the classic "C" locale in the provided buffer
70 new (&__rw_classic) _STD::locale ("C");
71}
72
73} // extern "C"
74
75} // namespace __rw
76
77
79
80
81/* static */ const locale& locale::
82classic ()
83{
84 // initialize classic locale in the static buffer exactly once
85 _RW::__rw_once (&_RW::__rw_classic_once_init, _RW::__rw_init_classic);
86
87 // cast the address of the buffer to a locale pointer
88 const locale* const pclassic =
89 _RWSTD_REINTERPRET_CAST (locale*, &_RW::__rw_classic);
90
91 _RWSTD_ASSERT (0 != pclassic->_C_body);
92
93 return *pclassic;
94}
95
96
97} // namespace std
#define _RWSTD_REINTERPRET_CAST(T, x)
Definition _defs.h:535
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
std::mbstate_t init
Definition codecvt1.cpp:80
Definition json.h:5363
#define _RWSTD_ONCE_INIT
Definition once.h:123