sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\earlyextension\earlyextension.cpp sl@0: // This is to test the registration of early extension and will do the following sl@0: // - Constructing the static data in VariantInit0 (the main extension object) sl@0: // - In Init3 entrypoint allocating space in Kernel Heap to store the time stamp obtained sl@0: // calling Kern::SystemTime(). sl@0: // - Supplying one exported function to allow reading the time stamp. sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include "earlyextension.h" sl@0: sl@0: static TestEarlyExtension* EarlyExtension; sl@0: sl@0: /** Registering as early extension */ sl@0: DECLARE_EXTENSION_WITH_PRIORITY(EARLY_EXTENSION_PRIORITY) sl@0: { sl@0: TestEarlyExtension* ee = new TestEarlyExtension; sl@0: if(!ee) sl@0: return KErrNoMemory; sl@0: EarlyExtension=ee; sl@0: EarlyExtension->iTime = new TTimeK; //Allocate memory for storing time stamp. sl@0: if(!EarlyExtension->iTime) sl@0: return KErrNoMemory; sl@0: *EarlyExtension->iTime = Kern::SystemTime(); //Store time stamp sl@0: // wait one tick to guarantee that system time will be different if called from the entry point of a following extension sl@0: NKern::Sleep(1); sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** This function allows to read the time stamp taken during the init3 entry point */ sl@0: EXPORT_C void TestEarlyExtension::GetTimeStamp(TTimeK& aTime) sl@0: { sl@0: if(!EarlyExtension->iTime) sl@0: { sl@0: aTime = 0; sl@0: return; sl@0: } sl@0: aTime = *EarlyExtension->iTime; sl@0: return; sl@0: } sl@0: sl@0: