SysThreadConcealed.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _SYSTHREADCONCEALED_H_
00014 #define _SYSTHREADCONCEALED_H_
00015 
00016 #include <SysThread.h>
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 
00023 /*
00024  * Once flag are a mix up between barriers and critical
00025  * sections. We could do without them except that for
00026  * ARMs EABI we only have four bytes to play with, hence
00027  * we need a new primitive type.
00028  *
00029  * For the time being these are kept as private since
00030  * they are only intended for Compiler Writers for
00031  * EABI support, in a future it may get to the SDK
00032  * or exported through a pthreads compatibility library.
00033  * 
00034  * See extended note in KALTSD.c
00035  */
00036 typedef uint32_t volatile SysOnceFlagType;
00037 enum {
00038     sysOnceFlagInitializer= 0,
00039     sysOnceFlagPending    = sysOnceFlagInitializer,
00040     sysOnceFlagDone       = 1,
00041     sysOnceFlagXYZZY      = 0x7FFFFFFF,
00042 };
00043 uint32_t SysOnceFlagTest(SysOnceFlagType *iOF);
00044 uint32_t SysOnceFlagSignal(SysOnceFlagType *iOF, uint32_t result);
00045 
00046 /*
00047  * Some conveniences for getting information about the
00048  * caller's process.  Should probably be moved to the SDK
00049  * at some point.
00050  */
00051 uint32_t SysProcessID(void);
00052 const char* SysProcessName(void);
00053 
00054 /*
00055  * These give a faster way to perform some of the low-
00056  * level operations, by avoiding the overhead of a
00057  * shared library call.
00058  */
00059 typedef struct sysThreadDirectFuncsTag
00060 {
00061     // Upon calling SysThreadGetDirectFuncs(), this contains the number
00062     // of funcs available in the structure; upon return it contains the
00063     // number that were filled in.
00064     int32_t     numFuncs;
00065 
00066     int32_t     (*atomicInc32)(int32_t volatile *ioOperandP);
00067     int32_t     (*atomicDec32)(int32_t volatile *ioOperandP);
00068     int32_t     (*atomicAdd32)(int32_t volatile *ioOperandP, int32_t iAddend);
00069     uint32_t    (*atomicAnd32)(uint32_t volatile *ioOperandP, uint32_t iValue);
00070     uint32_t    (*atomicOr32)(uint32_t volatile *ioOperandP, uint32_t iValue);
00071     uint32_t    (*atomicCompareAndSwap32)(uint32_t volatile *ioOperandP, uint32_t iOldValue, uint32_t iNewValue);
00072 
00073     void*       (*tsdGet)(SysTSDSlotID tsdslot);
00074     void        (*tsdSet)(SysTSDSlotID tsdslot, void *iValue);
00075 
00076     void        (*criticalSectionEnter)(SysCriticalSectionType *iCS);
00077     void        (*criticalSectionExit)(SysCriticalSectionType *iCS);
00078 
00079     void        (*conditionVariableWait)(SysConditionVariableType *iCV, SysCriticalSectionType *iOptionalCS);
00080     void        (*conditionVariableOpen)(SysConditionVariableType *iCV);
00081     void        (*conditionVariableClose)(SysConditionVariableType *iCV);
00082     void        (*conditionVariableBroadcast)(SysConditionVariableType *iCV);
00083 
00084 } sysThreadDirectFuncs;
00085 
00086 // This is the number of functions in the current structure.
00087 enum {
00088     sysThreadDirectFuncsCount = 14
00089 };
00090 
00091 status_t SysThreadGetDirectFuncs(sysThreadDirectFuncs* ioFuncs);
00092 
00093 #ifdef __cplusplus
00094 }   // extern "C"
00095 #endif
00096 
00097 #endif // _SYSTHREADCONCEALED_H_