1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/epoc/win32/uc_epoc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,225 @@
1.4 +// Copyright (c) 1998-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 the License "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 +// e32\euser\epoc\win32\uc_epoc.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +/*
1.22 +#include <e32std.h>
1.23 +#include <e32std_private.h>
1.24 +#include <e32wins.h>
1.25 +*/
1.26 +
1.27 +#ifdef __SYMC__
1.28 +
1.29 +//That stuff comes mostly from estub and uc_stub.cpp
1.30 +//We had to put it in there since we don't know how to do an MMP firstlib on Windows
1.31 +
1.32 +/*
1.33 +extern "C"
1.34 +GLDEF_C TInt _E32Startup()
1.35 +//
1.36 +// Unused in the stub
1.37 +//
1.38 + {
1.39 + return KErrNone;
1.40 + }
1.41 +
1.42 +
1.43 +
1.44 +//
1.45 +#include <windows.h>
1.46 +
1.47 +
1.48 +int CALLBACK _E32Bootstrap(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
1.49 + {
1.50 + BootEpoc(EFalse);
1.51 + return 0;
1.52 + };
1.53 +
1.54 +*/
1.55 +
1.56 +#endif
1.57 +
1.58 +
1.59 +
1.60 +
1.61 +
1.62 +
1.63 +
1.64 +/*
1.65 +#if defined __SYMC__
1.66 +
1.67 +//#include <e32cmn.h>
1.68 +#include <nwdl.h>
1.69 +
1.70 +
1.71 +//#include <e32hashtab.h>
1.72 +
1.73 +//SL: Empty on FCL ?
1.74 +//For now we use this for basic testing on our SYMC implementation
1.75 +
1.76 +
1.77 +TInt IdleCallBack(TAny* aParam)
1.78 + {
1.79 + static TInt count=0;
1.80 +
1.81 + count++;
1.82 +
1.83 + if (count>5)
1.84 + {
1.85 + //Stop it there
1.86 + CActiveScheduler::Stop();
1.87 + return EFalse;
1.88 + }
1.89 +
1.90 + //Keep playing
1.91 + return ETrue;
1.92 + }
1.93 +
1.94 +
1.95 +
1.96 +class CBaseTest: public CBase
1.97 + {
1.98 +
1.99 + };
1.100 +
1.101 +
1.102 +GLDEF_C void MainL()
1.103 + {
1.104 +
1.105 + //Testing CBase object
1.106 + CBase* other=new(ELeave) CBase();
1.107 + CleanupStack::PushL(other);
1.108 + CBase* base=new(ELeave) CBase();
1.109 + CleanupStack::PushL(base);
1.110 + CleanupStack::PopAndDestroy(2,other);
1.111 + //delete base;
1.112 +
1.113 + //Testing cleanup stack
1.114 + TRAPD(err,
1.115 + base=new(ELeave) CBase();
1.116 + CleanupStack::PushL(base);
1.117 + User::Leave(KErrCancel);
1.118 + );
1.119 +
1.120 + ASSERT(err==KErrCancel);
1.121 +
1.122 + //Testing alloc failure
1.123 + //See TProcess
1.124 + TRAP(err,
1.125 + TUint8* shouldFail=new(ELeave) TUint8[1024*1024*10];
1.126 + delete[] shouldFail;
1.127 + );
1.128 +
1.129 + //
1.130 + ASSERT(err==KErrNoMemory);
1.131 +
1.132 + //Testing alloc failure without leave
1.133 + TUint8* tooLarge=new TUint8[1024*1024*10];
1.134 + ASSERT(tooLarge==NULL);
1.135 + delete[] tooLarge;
1.136 +
1.137 + //Testing simple alloc of T class
1.138 + TUint8* tinyAlloc=new TUint8;
1.139 + ASSERT(tinyAlloc!=NULL);
1.140 + delete tinyAlloc;
1.141 +
1.142 + //TODO:
1.143 + //RHashSet<TUint32> hash;
1.144 +
1.145 + //Testing AOs
1.146 + //Install an active scheduler
1.147 + CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler;
1.148 + CActiveScheduler::Install(activeScheduler);
1.149 + CleanupStack::PushL(activeScheduler);
1.150 +
1.151 + CIdle* idle = CIdle::NewL(CActive::EPriorityIdle);
1.152 + CleanupStack::PushL(idle);
1.153 +
1.154 + idle->Start(TCallBack(IdleCallBack,NULL));
1.155 +
1.156 + CActiveScheduler::Start();
1.157 +
1.158 + CleanupStack::PopAndDestroy(idle);
1.159 + CActiveScheduler::Install(NULL);
1.160 + CleanupStack::PopAndDestroy(activeScheduler);
1.161 +
1.162 +
1.163 + //Testing unbalanced cleanup stack
1.164 + //base=new(ELeave) CBase();
1.165 + //CleanupStack::PushL(base);
1.166 + }
1.167 +
1.168 +
1.169 +GLDEF_C TInt E32Main()
1.170 + {
1.171 + //What do we do then
1.172 + //SetReturnedHandle
1.173 +
1.174 + __UHEAP_MARK;
1.175 +
1.176 + //CBase* base=new(ELeave) CBase();
1.177 + CBase* base=new CBase();
1.178 + delete base;
1.179 +
1.180 + CBaseTest* baseTest=new CBaseTest();
1.181 + delete baseTest;
1.182 +
1.183 + HBufC* buf=HBufC::New(10);
1.184 + delete buf;
1.185 +
1.186 + CArrayFix<TInt>* active=new CArrayFixFlat<TInt>(10);
1.187 + delete active;
1.188 +
1.189 + TUint8* test=new TUint8[1024*9];
1.190 + delete[] test;
1.191 +
1.192 + CTrapCleanup* cleanupStack = CTrapCleanup::New();
1.193 + if (!cleanupStack)
1.194 + {
1.195 + return KErrNoMemory;
1.196 + }
1.197 +
1.198 +
1.199 +
1.200 +
1.201 +
1.202 + TInt err=KErrNone;
1.203 + TRAP(err,MainL());
1.204 +
1.205 + delete cleanupStack;
1.206 +
1.207 + __UHEAP_MARKEND;
1.208 +
1.209 + return err;
1.210 + }
1.211 +
1.212 +
1.213 +
1.214 +#include <windows.h>
1.215 +
1.216 +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
1.217 + {
1.218 + //User::InitProcess();
1.219 + //E32Main();
1.220 + //User::Exit(0);
1.221 +
1.222 + BootEpoc(ETrue);
1.223 +
1.224 + return 0;
1.225 + }
1.226 +
1.227 +#endif
1.228 +*/