2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
16 * Part of : standard c++ library (wsd definitions)
23 #ifndef LIBSTDCPPWSD_H_
24 #define LIBSTDCPPWSD_H_
26 #ifdef __SYMBIAN32__WSD__ //stuff for WSD
29 // ****************************** WSD RELATED ************************//
31 #include <pls.h> // For emulator WSD API
43 #include <stl/_locale.h>
44 #include <stl/_numpunct.h>
45 #include <stl/_alloc.h>
46 #include <stl/_fstream.h>
47 #include <stl/_codecvt.h>
48 #include <stl/_collate.h>
49 #include <stl/_ctype.h>
50 #include <stl/_pthread_alloc.h>
51 #include <stl/_monetary.h>
52 #include <stl/_threads.h>
55 // Global hash tables for category objects.
56 typedef std::hash_map<std::string, std::pair<void*, size_t>, std::hash<std::string>, std::equal_to<std::string> > Category_Map;
58 #define LOCALE_ID_MAX 39
60 * The following functions are used to make allocations internal to the
61 * C++ library.These are only required on the emulator as these are
62 * static variables in the actual STLPort implementation but in order to
63 * save them on the ewsd, they need to allocated on heap.
65 IMPORT_C void* WSDAlloc(unsigned int size);
66 IMPORT_C int WSDFree(void*);
68 // ******************************************************//
69 // *** all WSD definitions here
70 // ******************************************************//
75 size_t locale_id_S_max;
78 std::locale *_Stl_classic_locale;
79 std::locale *_Stl_global_locale;
83 std::_Refcount_Base *_Loc_init_S_count;
86 __stl_atomic_t _S_index;
87 std::_STLP_STATIC_MUTEX locale_Index_lock;
90 bool ios_base_S_was_synced;
91 long ios_base_Init_S_count; //ios_base::Init class
92 std::ios_base::Init *_IosInit;
95 int ios_base_xalloc_S_index;
96 std::_STLP_STATIC_MUTEX ios_base_xalloc_lock;
99 Category_Map *_S_ctype_hash;
100 Category_Map *_S_numeric_hash;
101 Category_Map *_S_time_hash;
102 Category_Map *_S_collate_hash;
103 Category_Map *_S_monetary_hash;
104 Category_Map *_S_messages_hash;
106 std::_STLP_STATIC_MUTEX locale_catalog_category_hash_lock;
109 std::istream *wsd_cin;
110 std::ostream *wsd_cout;
111 std::ostream *wsd_cerr;
112 std::ostream *wsd_clog;
113 #ifndef _STLP_NO_WCHAR_T
114 std::wistream *wsd_wcin;
115 std::wostream *wsd_wcout;
116 std::wostream *wsd_wcerr;
117 std::wostream *wsd_wclog;
121 std::string numpunct_char_m_truename;
122 std::string numpunct_char_m_falsename;
123 std::string numpunct_char_m_grouping;
124 # ifndef _STLP_NO_WCHAR_T
125 std::wstring numpunct_wchar_m_truename;
126 std::wstring numpunct_wchar_m_falsename;
127 std::string numpunct_wchar_m_grouping;
131 std::string monetary_S_empty_string;
132 # ifndef _STLP_NO_WCHAR_T
133 std::wstring monetary_S_empty_wstring;
134 # endif //_STLP_NO_WCHAR_T
137 size_t fstream_Filebuf_base_M_page_size;
140 std::__oom_handler_type wsd__oom_handler;
141 std::_STLP_STATIC_MUTEX wsd_allocator_S_lock;
142 size_t wsd__node_alloc_impl_S_heap_size;
143 char* wsd_S_start_free;
144 char* wsd_S_end_free;
145 void* wsd_S_free_list[16];
147 std::_STLP_STATIC_MUTEX wsd_pt_S_chunk_allocator_lock;
148 char *wsd_pt_S_start_free;
149 char *wsd_pt_S_end_free;
150 size_t wsd_pt_S_heap_size;
151 stlp_priv::_Pthread_alloc::__state_type *wsd_pt_S_free_per_thread_states;
152 pthread_key_t wsd_pt_S_key;
153 bool wsd_pt_S_key_initialized;
156 std::_STLP_STATIC_MUTEX _threads_S_swap_lock;
157 std::_STLP_STATIC_MUTEX _threads_0_S_swap_lock;
159 unsigned _mutex_last;
161 # ifndef _STLP_NO_MBSTATE_T
162 std::locale::id codecvt_char_char_mbstate_id;
163 # ifndef _STLP_NO_WCHAR_T
164 std::locale::id codecvt_wchar_char_mbstate_id;
166 # endif //_STLP_NO_MBSTATE_T
167 std::locale::id collate_char_id;
169 std::locale::id ctype_char_id;
171 std::locale::id moneypunct_char_true_id;
173 std::locale::id moneypunct_char_false_id;
175 std::locale::id messages_char_id;
177 std::locale::id numpunct_char_id;
179 # ifndef _STLP_NO_WCHAR_T
180 std::locale::id collate_wchar_id;
182 std::locale::id ctype_wchar_id;
184 std::locale::id moneypunct_wchar_true_id;
186 std::locale::id moneypunct_wchar_false_id;
188 std::locale::id numpunct_wchar_id;
190 std::locale::id messages_wchar_id;
192 std::locale::id num_get_wchar_istreambuf_iterator_id;
194 std::locale::id num_get_wchar_wchar_const_id;
196 std::locale::id num_put_wchar_ostreambuf_iterator_id;
198 std::locale::id num_put_wchar_wchar_id;
200 std::locale::id time_get_wchar_istreambuf_iterator_id;
202 std::locale::id time_get_wchar_wchar_const_id;
204 std::locale::id time_put_wchar_ostreambuf_iterator_id;
206 std::locale::id time_put_wchar_wchar_id;
208 std::locale::id money_get_wchar_istreambuf_iterator_id;
210 std::locale::id money_get_wchar_wchar_const_id;
212 std::locale::id money_put_wchar_ostreambuf_iterator_id;
214 std::locale::id money_put_wchar_wchar_id;
217 std::locale::id time_get_char_istreambuf_iterator_id;
219 std::locale::id time_get_char_char_const_id;
221 std::locale::id time_put_char_ostreambuf_iterator_id;
223 std::locale::id time_put_char_char_id;
225 std::locale::id num_get_char_istreambuf_iterator_id;
227 std::locale::id num_get_char_char_const_id;
229 std::locale::id num_put_char_ostreambuf_iterator_id;
231 std::locale::id num_put_char_char_id;
233 std::locale::id num_put_char_back_insert_iterator_id;
235 std::locale::id money_get_char_istreambuf_iterator_id;
237 std::locale::id money_get_char_char_const_id;
239 std::locale::id money_put_char_ostreambuf_iterator_id;
241 std::locale::id money_put_char_char_id;
243 std::map<std::string, std::locale::id> ctype_charT_ids; //for ctype<charT>
244 std::map<std::string, std::locale::id> numpunct_charT_ids; //for numpunct<charT>
245 std::map<std::string, std::locale::id> moneypunct_charT_ids; //for moneypunct<charT>
248 std::string *_Nameless;
250 // ****** end of static var definition
263 //declaraions for wsd initialization functions
264 void locale_impl_init();
265 void locale_index_lock_init();
266 void monetary_empty_string_init();
267 void global_iostream_init();
268 void stdcpp_allocators_init();
269 void filebuf_page_size_init();
272 inline std::string*& get_Nameless();
275 namespace _STLP_PRIV_NAME {
276 void locale_catalog_category_hash_lock_init();
277 void Category_Map_Init();
281 const TUid KLibstdcppUID = {0x20017610};
283 //cleanup all the WSD allocations
284 IMPORT_C void CleanupWSD();
286 //return the global class pointer
287 IMPORT_C _Libcpp_wsd& get_libcpp_wsd();
290 inline std::string*& get_Nameless()
292 return get_libcpp_wsd()._Nameless;
297 // ******************************************************//
299 //locale wsd functions
300 #include "wsd_locales.h"
302 //streams wsd functions
303 #include "wsd_streams.h"
305 // ******************************************************//
308 #endif /*LIBSTDCPPWSD_H_*/