sl@0: /* sl@0: * Copyright (c) 2005-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 "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: * Name : threadcreate.h sl@0: * Part of : PThread library sl@0: * Data structure needed for thread creatation. sl@0: * Version: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef THREADCREATE_H sl@0: #define THREADCREATE_H sl@0: sl@0: #include <e32std.h> sl@0: #include <sched.h> sl@0: #include "sysif.h" sl@0: sl@0: #define MIN_RR_PRIORITY 0 sl@0: #define MAX_RR_PRIORITY 255 sl@0: sl@0: // On any addition or deletion to this pthread_attr structure, update sl@0: // _TOTALSIZEOF_PTHREAD_ATTR_T sl@0: typedef struct sl@0: { sl@0: /* Scheduler parameters; Only priority. */ sl@0: unsigned int policy; sl@0: unsigned int stackSize; sl@0: unsigned int detachState; sl@0: unsigned int scope; sl@0: struct sched_param sp; sl@0: int priority; sl@0: unsigned int reserved1; sl@0: unsigned int reserved2; sl@0: }_pthread_attr; sl@0: sl@0: typedef void *(*_START_ROUTINE) (void *); sl@0: typedef int (*_START_ROUTINE_SOS) (void *); sl@0: sl@0: #ifdef __X86GCC__ sl@0: // MinGW GCC compiler does not like typedef struct definitions with no tag sl@0: typedef struct _wrapperFunArgs_tag sl@0: #else sl@0: typedef struct sl@0: #endif // __X86GCC__ sl@0: { sl@0: _START_ROUTINE begin_routine; sl@0: void *args; sl@0: void *nodePtr; sl@0: /******************************************************************* sl@0: Overloading new and delete operators so that they will sl@0: allocate and deallocare memory from/to the private heap of backend sl@0: ********************************************************************/ sl@0: inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW sl@0: { sl@0: Mem::FillZ(aBase, aSize); return aBase; sl@0: } sl@0: sl@0: inline TAny* operator new(TUint aSize) __NO_THROW sl@0: { sl@0: return Backend()->Alloc(aSize); sl@0: } sl@0: sl@0: inline TAny* operator new(TUint aSize, TLeave) sl@0: { sl@0: TAny* ptr = Backend()->Alloc(aSize); sl@0: if (ptr == NULL) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: return ptr; sl@0: } sl@0: sl@0: inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW sl@0: { sl@0: return Backend()->Alloc(aSize + aExtraSize); sl@0: } sl@0: sl@0: inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize) sl@0: { sl@0: TAny* ptr = Backend()->Alloc(aSize + aExtraSize); sl@0: if (ptr == NULL) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: return ptr; sl@0: } sl@0: sl@0: inline void operator delete(TAny *aPtr) __NO_THROW sl@0: { sl@0: Backend()->Free( aPtr ); sl@0: } sl@0: }_wrapperFunArgs; sl@0: sl@0: sl@0: sl@0: #endif //THREADCREATE_H sl@0: sl@0: //End of File