os/ossrv/genericopenlibs/openenvcore/libpthread/inc/threadcreate.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * Name     : threadcreate.h
    16 * Part of  : PThread library
    17 * Data structure needed for thread creatation.
    18 * Version:
    19 *
    20 */
    21 
    22 
    23 
    24 #ifndef THREADCREATE_H
    25 #define THREADCREATE_H
    26 
    27 #include <e32std.h>
    28 #include <sched.h>
    29 #include "sysif.h"
    30 
    31 #define MIN_RR_PRIORITY 0
    32 #define MAX_RR_PRIORITY 255
    33 
    34 // On any addition or deletion to this pthread_attr structure, update 
    35 // _TOTALSIZEOF_PTHREAD_ATTR_T 
    36 typedef struct 
    37 {
    38   /* Scheduler parameters; Only priority.  */
    39   unsigned int policy;
    40   unsigned int stackSize;
    41   unsigned int detachState;
    42   unsigned int scope;
    43   struct sched_param sp;
    44   int priority;
    45   unsigned int reserved1;
    46   unsigned int reserved2;
    47 }_pthread_attr;
    48 
    49 typedef void *(*_START_ROUTINE) (void *);
    50 typedef int (*_START_ROUTINE_SOS) (void *);
    51 
    52 #ifdef __X86GCC__
    53 // MinGW GCC compiler does not like typedef struct definitions with no tag
    54 typedef struct _wrapperFunArgs_tag
    55 #else
    56 typedef struct 
    57 #endif // __X86GCC__
    58 {
    59     _START_ROUTINE begin_routine;
    60     void *args;
    61     void *nodePtr;
    62 	/*******************************************************************
    63 	Overloading new and delete operators so that they will
    64 	allocate and deallocare memory from/to the private heap of backend
    65 	********************************************************************/
    66 	inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW
    67 		{
    68 		Mem::FillZ(aBase, aSize); return aBase;
    69 		}
    70 		
    71 	inline TAny* operator new(TUint aSize) __NO_THROW
    72 		{
    73 		return Backend()->Alloc(aSize);
    74 		}
    75 		
    76 	inline TAny* operator new(TUint aSize, TLeave)
    77 		{
    78 		TAny* ptr = Backend()->Alloc(aSize);
    79 		if (ptr == NULL)
    80 			{
    81 			User::Leave(KErrNoMemory);
    82 			}
    83 		return ptr;
    84 		}
    85 		
    86 	inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW
    87 		{
    88 		return Backend()->Alloc(aSize + aExtraSize);
    89 		}
    90 		
    91 	inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize)
    92 		{
    93 		TAny* ptr = Backend()->Alloc(aSize + aExtraSize);
    94 		if (ptr == NULL)
    95 			{
    96 			User::Leave(KErrNoMemory);
    97 			}
    98 		return ptr;
    99 		}
   100 	
   101 	inline void operator delete(TAny *aPtr) __NO_THROW
   102 		{
   103 		Backend()->Free( aPtr );
   104 		}
   105 }_wrapperFunArgs;
   106 
   107 
   108 
   109 #endif //THREADCREATE_H
   110 
   111 //End of File