os/kernelhwsrv/kernel/eka/euser/epoc/win32/uc_epoc.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32\euser\epoc\win32\uc_epoc.cpp
    15 // 
    16 //
    17 
    18 /*
    19 #include <e32std.h>
    20 #include <e32std_private.h>
    21 #include <e32wins.h>
    22 */
    23 
    24 #ifdef __SYMC__
    25 
    26 //That stuff comes mostly from estub and uc_stub.cpp
    27 //We had to put it in there since we don't know how to do an MMP firstlib on Windows
    28 
    29 /*
    30 extern "C"
    31 GLDEF_C TInt _E32Startup()
    32 //
    33 // Unused in the stub
    34 //
    35 	{
    36 	return KErrNone;
    37 	}
    38 
    39 
    40 
    41 //
    42 #include <windows.h>
    43 
    44 
    45 int CALLBACK _E32Bootstrap(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    46 	{
    47 	BootEpoc(EFalse);
    48 	return 0;
    49 	};
    50 
    51 */
    52 
    53 #endif
    54 
    55 
    56 
    57 
    58 
    59 
    60 
    61 /*
    62 #if defined __SYMC__
    63 
    64 //#include <e32cmn.h>
    65 #include <nwdl.h>
    66 
    67 
    68 //#include <e32hashtab.h>
    69 
    70 //SL: Empty on FCL ?
    71 //For now we use this for basic testing on our SYMC implementation
    72 
    73 
    74 TInt IdleCallBack(TAny* aParam)
    75    {
    76    static TInt count=0;
    77 
    78    count++;
    79 
    80    if (count>5)
    81       {
    82       //Stop it there
    83       CActiveScheduler::Stop();
    84       return EFalse;
    85       }
    86 
    87    //Keep playing
    88    return ETrue;		
    89    }
    90 
    91 
    92 
    93 class CBaseTest: public CBase
    94 	{
    95 
    96 	};
    97 
    98 
    99 GLDEF_C void MainL()
   100 	{
   101 
   102    //Testing CBase object
   103 	CBase* other=new(ELeave) CBase();
   104 	CleanupStack::PushL(other);
   105 	CBase* base=new(ELeave) CBase();
   106 	CleanupStack::PushL(base);
   107 	CleanupStack::PopAndDestroy(2,other);
   108 	//delete base;
   109 	
   110 	//Testing cleanup stack
   111 	TRAPD(err,
   112 	base=new(ELeave) CBase();
   113 	CleanupStack::PushL(base);
   114 	User::Leave(KErrCancel);
   115 	);
   116 
   117 	ASSERT(err==KErrCancel);
   118 
   119 	//Testing alloc failure
   120    //See TProcess
   121 	TRAP(err,
   122 	TUint8* shouldFail=new(ELeave) TUint8[1024*1024*10];
   123 	delete[] shouldFail;
   124 	);
   125 
   126    //
   127 	ASSERT(err==KErrNoMemory);
   128 
   129    //Testing alloc failure without leave
   130    TUint8* tooLarge=new TUint8[1024*1024*10];
   131    ASSERT(tooLarge==NULL);
   132    delete[] tooLarge;
   133 
   134    //Testing simple alloc of T class
   135    TUint8* tinyAlloc=new TUint8;
   136    ASSERT(tinyAlloc!=NULL);
   137    delete tinyAlloc;
   138 
   139    //TODO:
   140    //RHashSet<TUint32> hash;
   141 	
   142    //Testing AOs
   143    //Install an active scheduler
   144    CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler;
   145    CActiveScheduler::Install(activeScheduler);
   146    CleanupStack::PushL(activeScheduler);
   147 
   148    CIdle* idle = CIdle::NewL(CActive::EPriorityIdle);	
   149    CleanupStack::PushL(idle);
   150 
   151    idle->Start(TCallBack(IdleCallBack,NULL));
   152 
   153    CActiveScheduler::Start();
   154 
   155    CleanupStack::PopAndDestroy(idle);
   156    CActiveScheduler::Install(NULL);
   157    CleanupStack::PopAndDestroy(activeScheduler);
   158 
   159 
   160 	//Testing unbalanced cleanup stack
   161 	//base=new(ELeave) CBase();
   162 	//CleanupStack::PushL(base);
   163 	}
   164 
   165 
   166 GLDEF_C TInt E32Main()
   167 	{
   168 	//What do we do then
   169 	//SetReturnedHandle
   170 	
   171 	__UHEAP_MARK;
   172 
   173 	//CBase* base=new(ELeave) CBase();
   174 	CBase* base=new CBase();
   175 	delete base;
   176 
   177 	CBaseTest* baseTest=new CBaseTest();
   178 	delete baseTest;
   179 
   180 	HBufC* buf=HBufC::New(10);
   181 	delete buf;
   182 
   183 	CArrayFix<TInt>* active=new CArrayFixFlat<TInt>(10);
   184 	delete active;
   185 
   186 	TUint8* test=new TUint8[1024*9];
   187 	delete[] test;
   188 
   189 	CTrapCleanup* cleanupStack = CTrapCleanup::New();
   190 	if (!cleanupStack)
   191 		{
   192 		return KErrNoMemory;
   193 		}
   194 
   195 
   196 
   197 
   198 
   199 	TInt err=KErrNone;
   200 	TRAP(err,MainL());
   201 	
   202 	delete cleanupStack;
   203 
   204 	__UHEAP_MARKEND;
   205 
   206 	return err;
   207 	}
   208 
   209 
   210 
   211 #include <windows.h>
   212 
   213 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,	int nCmdShow)
   214 	{
   215 	//User::InitProcess();
   216 	//E32Main();
   217 	//User::Exit(0);
   218 
   219 	BootEpoc(ETrue);
   220 
   221 	return 0;
   222 	}
   223 
   224 #endif
   225 */