1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/libstdcppwsd.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,247 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Name : libstdcppwsd.cpp
1.18 +// Part of : standard c++ library.
1.19 +//
1.20 +//
1.21 +
1.22 +#include "stlport_prefix.h"
1.23 +#include "stl/_threads.h"
1.24 +#include <locale>
1.25 +#include <libstdcppwsd.h>
1.26 +#include "locale_impl.h"
1.27 +
1.28 +#ifdef __SYMBIAN32__WSD__ //stuff for WSD
1.29 +
1.30 +//constructor
1.31 +EXPORT_C _Libcpp_wsd::_Libcpp_wsd()
1.32 + : ios_base_Init_S_count(0),
1.33 + _IosInit(NULL),
1.34 + wsd_cin(NULL),
1.35 + wsd_cout(NULL),
1.36 + wsd_cerr(NULL),
1.37 + wsd_clog(NULL),
1.38 +#ifndef _STLP_NO_WCHAR_T
1.39 + wsd_wcin(NULL),
1.40 + wsd_wcout(NULL),
1.41 + wsd_wcerr(NULL),
1.42 + wsd_wclog(NULL),
1.43 +#endif
1.44 + is_Initialized(false),
1.45 + _Stl_classic_locale(NULL),
1.46 + _Stl_global_locale(NULL)
1.47 + { /* do nothing */ }
1.48 +
1.49 +//destructor
1.50 +EXPORT_C _Libcpp_wsd::~_Libcpp_wsd()
1.51 + {
1.52 + //Free the internal allocations
1.53 + if( _IosInit != NULL )
1.54 + {
1.55 + _IosInit->~Init();
1.56 + WSDFree(_IosInit);
1.57 + }
1.58 + if( wsd_cin != NULL )
1.59 + {
1.60 + wsd_cin->~basic_istream();
1.61 + WSDFree(wsd_cin);
1.62 + }
1.63 + if( wsd_cout != NULL )
1.64 + {
1.65 + wsd_cout->~basic_ostream();
1.66 + WSDFree(wsd_cout);
1.67 + }
1.68 + if( wsd_cerr != NULL )
1.69 + {
1.70 + wsd_cerr->~basic_ostream();
1.71 + WSDFree(wsd_cerr);
1.72 + }
1.73 + if( wsd_clog != NULL )
1.74 + {
1.75 + wsd_clog->~basic_ostream();
1.76 + WSDFree(wsd_clog);
1.77 + }
1.78 + if( wsd_wcin != NULL )
1.79 + {
1.80 + wsd_wcin->~basic_istream();
1.81 + WSDFree(wsd_wcin);
1.82 + }
1.83 + if( wsd_wcout != NULL )
1.84 + {
1.85 + wsd_wcout->~basic_ostream();
1.86 + WSDFree(wsd_wcout);
1.87 + }
1.88 + if( wsd_wcerr != NULL )
1.89 + {
1.90 + wsd_wcerr->~basic_ostream();
1.91 + WSDFree(wsd_wcerr);
1.92 + }
1.93 + if( wsd_wclog != NULL )
1.94 + {
1.95 + wsd_wclog->~basic_ostream();
1.96 + WSDFree(wsd_wclog);
1.97 + }
1.98 + if( _Stl_global_locale != NULL )
1.99 + {
1.100 + _Stl_global_locale->~locale();
1.101 + WSDFree(_Stl_global_locale);
1.102 + }
1.103 + if( _Stl_classic_locale != NULL )
1.104 + {
1.105 + _Stl_classic_locale->~locale();
1.106 + WSDFree(_Stl_classic_locale);
1.107 + }
1.108 +
1.109 + if( _Loc_init_S_count != NULL )
1.110 + WSDFree(_Loc_init_S_count);
1.111 + }
1.112 +
1.113 +EXPORT_C void CleanupWSD()
1.114 + {
1.115 + _Libcpp_wsd* wsdPtr = Pls<_Libcpp_wsd>(KLibstdcppUID, NULL);
1.116 + wsdPtr->~_Libcpp_wsd();
1.117 + }
1.118 +
1.119 +EXPORT_C _Libcpp_wsd& get_libcpp_wsd()
1.120 + {
1.121 + //get the TLS pointer
1.122 + _Libcpp_wsd* g_libcpp_wsd = Pls<_Libcpp_wsd>(KLibstdcppUID, NULL);
1.123 + if(g_libcpp_wsd->is_Initialized != true)
1.124 + {
1.125 + //this has to be here to avoid infinite recursion
1.126 + g_libcpp_wsd->is_Initialized = true;
1.127 +
1.128 +#ifdef _STLP_DEBUG
1.129 + get_Nameless() = new std::string("*");
1.130 +#endif
1.131 + //initialize allocator static data
1.132 + stdcpp_allocators_init();
1.133 +
1.134 + //initialize the page size
1.135 + filebuf_page_size_init();
1.136 +
1.137 + //initialize _S_count of _Loc_init
1.138 + // Calling placement new on internally alloc'ed memory.
1.139 + g_libcpp_wsd->_Loc_init_S_count = new (WSDAlloc(sizeof(std::_Refcount_Base))) std::_Refcount_Base(0);
1.140 +
1.141 + std::_Locale_impl::Init::Init();
1.142 + // Calling placement new on internally alloc'ed memory.
1.143 + g_libcpp_wsd->_IosInit = new (WSDAlloc(sizeof(std::ios_base::Init))) std::ios_base::Init();
1.144 + }
1.145 + return (*g_libcpp_wsd);
1.146 + }
1.147 +
1.148 +
1.149 +/******************** threads related *****************/
1.150 +//
1.151 +_STLP_DECLSPEC std::_STLP_STATIC_MUTEX& exp_get_threads_S_swap_lock()
1.152 + {
1.153 + return get_libcpp_wsd()._threads_S_swap_lock;
1.154 + }
1.155 +
1.156 +_STLP_DECLSPEC std::_STLP_STATIC_MUTEX& exp_get_threads_0_S_swap_lock()
1.157 + {
1.158 + return get_libcpp_wsd()._threads_0_S_swap_lock;
1.159 + }
1.160 +
1.161 +
1.162 +
1.163 +// locale::id
1.164 +//ACCESS FUNCTIONS
1.165 +_STLP_DECLSPEC std::locale::id&
1.166 +std::codecvt<char, char, mbstate_t>::GetFacetLocaleId()
1.167 + {
1.168 + return get_libcpp_wsd().codecvt_char_char_mbstate_id;
1.169 + }
1.170 +
1.171 +
1.172 +_STLP_DECLSPEC std::locale::id&
1.173 +std::codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId()
1.174 + {
1.175 + return get_libcpp_wsd().codecvt_wchar_char_mbstate_id;
1.176 + }
1.177 +
1.178 +_STLP_DECLSPEC std::locale::id&
1.179 +std::collate<char>::GetFacetLocaleId()
1.180 + {
1.181 + return get_libcpp_wsd().collate_char_id;
1.182 + }
1.183 +
1.184 +_STLP_DECLSPEC std::locale::id&
1.185 +std::ctype<char>::GetFacetLocaleId()
1.186 + {
1.187 + return get_libcpp_wsd().ctype_char_id;
1.188 + }
1.189 +
1.190 +_STLP_DECLSPEC std::locale::id&
1.191 +std::moneypunct<char, true>::GetFacetLocaleId()
1.192 + {
1.193 + return get_libcpp_wsd().moneypunct_char_true_id;
1.194 + }
1.195 +
1.196 +_STLP_DECLSPEC std::locale::id&
1.197 +std::moneypunct<char, false>::GetFacetLocaleId()
1.198 + {
1.199 + return get_libcpp_wsd().moneypunct_char_false_id;
1.200 + }
1.201 +
1.202 +_STLP_DECLSPEC std::locale::id&
1.203 +std::messages<char>::GetFacetLocaleId()
1.204 + {
1.205 + return get_libcpp_wsd().messages_char_id;
1.206 + }
1.207 +
1.208 +_STLP_DECLSPEC std::locale::id&
1.209 +std::numpunct<char>::GetFacetLocaleId()
1.210 + {
1.211 + return get_libcpp_wsd().numpunct_char_id;
1.212 + }
1.213 +
1.214 +_STLP_DECLSPEC std::locale::id&
1.215 +std::collate<wchar_t>::GetFacetLocaleId()
1.216 + {
1.217 + return get_libcpp_wsd().collate_wchar_id;
1.218 + }
1.219 +
1.220 +_STLP_DECLSPEC std::locale::id&
1.221 +std::ctype<wchar_t>::GetFacetLocaleId()
1.222 + {
1.223 + return get_libcpp_wsd().ctype_wchar_id;
1.224 + }
1.225 +
1.226 +_STLP_DECLSPEC std::locale::id&
1.227 +std::moneypunct<wchar_t, true>::GetFacetLocaleId()
1.228 + {
1.229 + return get_libcpp_wsd().moneypunct_wchar_true_id;
1.230 + }
1.231 +
1.232 +_STLP_DECLSPEC std::locale::id&
1.233 +std::moneypunct<wchar_t, false>::GetFacetLocaleId()
1.234 + {
1.235 + return get_libcpp_wsd().moneypunct_wchar_false_id;
1.236 + }
1.237 +
1.238 +_STLP_DECLSPEC std::locale::id&
1.239 +std::numpunct<wchar_t>::GetFacetLocaleId()
1.240 + {
1.241 + return get_libcpp_wsd().numpunct_wchar_id;
1.242 + }
1.243 +
1.244 +_STLP_DECLSPEC std::locale::id&
1.245 +std::messages<wchar_t>::GetFacetLocaleId()
1.246 + {
1.247 + return get_libcpp_wsd().messages_wchar_id;
1.248 + }
1.249 +
1.250 +#endif /* __SYMBIAN32__WSD__ */