kerneltest/e32test/earlyextension/earlyextension.cpp
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 137 8aab599e3476
parent 0 a41df078684a
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// e32test\earlyextension\earlyextension.cpp
// This is to test the registration of early extension and will do the following
// - Constructing the static data in VariantInit0 (the main extension object)
// - In Init3 entrypoint allocating space in Kernel Heap to store the time stamp obtained
// calling Kern::SystemTime().
// - Supplying one exported function to allow reading the time stamp.
// 
//


#include <kernel/kernel.h>
#include "earlyextension.h"

static TestEarlyExtension* EarlyExtension;

/** Registering as early extension */
DECLARE_EXTENSION_WITH_PRIORITY(EARLY_EXTENSION_PRIORITY)
	{
	TestEarlyExtension* ee = new TestEarlyExtension;
	if(!ee)
		return KErrNoMemory;
	EarlyExtension=ee;
	EarlyExtension->iTime = new TTimeK; //Allocate memory for storing time stamp.
    if(!EarlyExtension->iTime)
		return KErrNoMemory;
	*EarlyExtension->iTime = Kern::SystemTime(); //Store time stamp
	// wait one tick to guarantee that system time will be different if called from the entry point of a following extension
	NKern::Sleep(1);
    return KErrNone;
	}

/** This function allows to read the time stamp taken during the init3 entry point */
EXPORT_C void TestEarlyExtension::GetTimeStamp(TTimeK& aTime)
    {
    if(!EarlyExtension->iTime)
        {
        aTime = 0;
        return;
        }    
	aTime = *EarlyExtension->iTime;
	return;
	}