Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\euser\epoc\win32\uc_cwhelp.cpp
15 // This file contains the CodeWarrior specific helper code common to eexe and edll
20 #include <e32std_private.h>
22 // Define LAZY_INIT to allow the runtime to construct itself only when necessary. This uses less
23 // TLS indicies, but is a more fragile approach.
30 // Dummy versions of CodeWarrior runtime functions.
32 // These are only called when we are linked against the DLL version of the runtime, or if these
33 // functions aren't present in the static runtime.
35 // The original functions are defined in:
36 // c:/apps/Metrowerks/OEM3.1/Symbian_Support/MSL/MSL_C/MSL_Win32/Src/ThreadLocalData.c
37 // c:/apps/Metrowerks/OEM3.1/Symbian_Support/MSL/MSL_C/MSL_Win32/Src/startup.win32.c
42 extern int _InitializeThreadDataIndex(void);
43 extern int *__get_MSL_init_count(void);
45 __declspec(weak) int *__get_MSL_init_count(void)
52 extern int _CRTStartup();
56 extern void _CleanUpMSL(void);
69 TBool CleanupCWRuntime()
72 int* init_count_ptr = __get_MSL_init_count();
73 if (!init_count_ptr) // if we couldn't link this function, don't attempt cleanup
75 if (!_InitializeThreadDataIndex()) // make sure runtime is initialised to known state
77 if (++(*init_count_ptr) != 1) // make it look like _CRTStartup was called
80 if (*__get_MSL_init_count() < 1) // _CRTStartup should have been called at least once
82 *__get_MSL_init_count() = 1; // reset to one so _CleanUpMSL runs
84 _CleanUpMSL(); // call into runtime to do cleanup