1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/stdcpp/src/libstd_cpp_init.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,217 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +# include "stlport_prefix.h"
1.23 +#include <e32base.h>
1.24 +#include <e32err.h>
1.25 +//#include <typeinfo.h>
1.26 +#include <memory>
1.27 +
1.28 +#include "libstdcppwsd.h"
1.29 +#ifdef __WINSCW__
1.30 +#include <pls.h>
1.31 +const TUid KLibstdcppUID = {0x10282872};
1.32 +#endif
1.33 +
1.34 +#ifdef __WINSCW__
1.35 +#ifdef __cplusplus
1.36 +extern "C" {
1.37 +#endif
1.38 +#ifdef __cplusplus
1.39 +} // extern "C"
1.40 +#endif
1.41 +#include <e32std.h>
1.42 +#endif //__WINSCW__
1.43 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.44 +#include "sysif.h"
1.45 +#endif
1.46 +
1.47 +
1.48 +
1.49 +
1.50 +_STLP_BEGIN_NAMESPACE
1.51 +
1.52 +void CallIosInit();
1.53 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.54 +extern void CallCloseStdLib();
1.55 +#endif
1.56 +
1.57 +_STLP_EXP_DECLSPEC void LibStdCppInit()
1.58 + {
1.59 + //Create Cleanup Stack
1.60 + CTrapCleanup* pCleanup = CTrapCleanup::New();
1.61 +
1.62 + if( pCleanup )
1.63 + {
1.64 + CallIosInit();
1.65 + delete pCleanup;
1.66 + }
1.67 + }
1.68 +
1.69 +#if 0
1.70 +_STLP_EXP_DECLSPEC type_info::~type_info () {}
1.71 +
1.72 +
1.73 +_STLP_EXP_DECLSPEC bad_cast::~bad_cast() throw() { }
1.74 +
1.75 +_STLP_EXP_DECLSPEC bad_typeid::~bad_typeid() throw() { }
1.76 +
1.77 +
1.78 +// return true if this is a type_info for a pointer type
1.79 +_STLP_EXP_DECLSPEC bool type_info::__is_pointer_p () const
1.80 +{
1.81 + return false;
1.82 +}
1.83 +
1.84 +_STLP_EXP_DECLSPEC bool type_info::__is_function_p () const
1.85 +{
1.86 + return false;
1.87 +}
1.88 +
1.89 +_STLP_EXP_DECLSPEC bool type_info::__do_catch (const type_info *thr_type, void **, unsigned) const
1.90 +{
1.91 + return *this == *thr_type;
1.92 +}
1.93 +
1.94 +#endif
1.95 +
1.96 +
1.97 +_STLP_EXP_DECLSPEC new_handler set_new_handler(new_handler pnew) __NO_THROW
1.98 +{
1.99 + new_handler& phandler = get_new_handler();
1.100 + new_handler phold = phandler;
1.101 + phandler = pnew;
1.102 + return phold;
1.103 +}
1.104 +
1.105 +_STLP_END_NAMESPACE
1.106 +
1.107 +using namespace std;
1.108 +
1.109 +int
1.110 +init_libcpp_wsdvar(_Libcpp_wsd* g_libcpp_wsd)
1.111 +{
1.112 + g_libcpp_wsd->is_Initialized = false;
1.113 + return KErrNone;
1.114 +}
1.115 +
1.116 +#ifdef __WINSCW__
1.117 +void* GetGlobalTlsData()
1.118 + {
1.119 + return Pls<_Libcpp_wsd>(KLibstdcppUID, &init_libcpp_wsdvar);
1.120 + }
1.121 +
1.122 +void SetGlobalTlsData(void* aData)
1.123 + {
1.124 + SetPls(aData, KLibstdcppUID);
1.125 + }
1.126 +#endif
1.127 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.128 +void* SetBackendHeap()
1.129 +{
1.130 +
1.131 + RHeap* oldHeap = User::SwitchHeap( Backend()->Heap() ); // From now, new allocates memory form backend heap
1.132 +
1.133 + return (void*)oldHeap;
1.134 +
1.135 +}
1.136 +
1.137 +void ReSetUserHeap(void* oldHeap)
1.138 +{
1.139 +
1.140 + User::SwitchHeap( (RHeap*)oldHeap);
1.141 +}
1.142 +
1.143 +
1.144 +#endif
1.145 +
1.146 +
1.147 +
1.148 +_STLP_EXP_DECLSPEC void CloseStdLibCpp()
1.149 + {
1.150 +#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.151 + std::CallCloseStdLib();
1.152 +#endif
1.153 + }
1.154 +
1.155 +
1.156 +
1.157 +
1.158 +_STLP_EXP_DECLSPEC void *operator new(unsigned int aSize)__NO_THROW
1.159 + {
1.160 + void* __y;
1.161 +
1.162 + __y = _STLP_NEW(aSize);
1.163 +
1.164 + if (__y == 0)
1.165 + {
1.166 + new_handler& phandler = get_new_handler();
1.167 + if(phandler == NULL)
1.168 + _STLP_THROW(bad_alloc());
1.169 + else
1.170 + phandler();
1.171 + }
1.172 + return __y;
1.173 + }
1.174 +
1.175 +_STLP_EXP_DECLSPEC void *operator new[](unsigned int aSize)__NO_THROW
1.176 + {
1.177 + return ::operator new(aSize);
1.178 + }
1.179 +
1.180 +_STLP_EXP_DECLSPEC void operator delete(void* aPtr) __NO_THROW
1.181 + {
1.182 +
1.183 + ::free(aPtr);
1.184 +
1.185 + }
1.186 +
1.187 +_STLP_EXP_DECLSPEC void operator delete[](void* aPtr) __NO_THROW
1.188 + {
1.189 + ::operator delete(aPtr);
1.190 + }
1.191 +
1.192 +_STLP_EXP_DECLSPEC void* operator new(unsigned int aSize, const std::nothrow_t& /*aNoThrow*/) __NO_THROW
1.193 + {
1.194 + void* __y = _STLP_NEW(aSize);
1.195 + if (__y == 0)
1.196 + {
1.197 + new_handler& phandler = get_new_handler();
1.198 + if(phandler != NULL)
1.199 + phandler();
1.200 + }
1.201 + return __y;
1.202 + }
1.203 +
1.204 +_STLP_EXP_DECLSPEC void* operator new[](unsigned int aSize, const std::nothrow_t& aNoThrow) __NO_THROW
1.205 + {
1.206 + return operator new (aSize, aNoThrow);
1.207 + }
1.208 +
1.209 +_STLP_EXP_DECLSPEC void operator delete(void* aPtr, const std::nothrow_t& /*aNoThrow*/) __NO_THROW
1.210 + {
1.211 + operator delete(aPtr);
1.212 + }
1.213 +
1.214 +_STLP_EXP_DECLSPEC void operator delete[](void* aPtr, const std::nothrow_t& /*aNoThrow*/) __NO_THROW
1.215 + {
1.216 + operator delete(aPtr);
1.217 + }
1.218 +
1.219 +
1.220 +// end of file