Added implementations for "posix" atomic operations.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@397 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-05-09 17:57:40 +00:00
parent 82f07abe78
commit eeae0db616
2 changed files with 38 additions and 2 deletions

View File

@@ -69,6 +69,8 @@
static FLMUINT gv_uiLinuxRevision = 0;
#endif
static pthread_mutex_t gv_atomicMutex = PTHREAD_MUTEX_INITIALIZER;
/******************************************************************************
Desc:
*******************************************************************************/
@@ -1543,6 +1545,40 @@ void FLMAPI f_yieldCPU( void)
{
}
/**********************************************************************
Desc:
**********************************************************************/
FLMINT32 posix_atomic_add_32(
volatile FLMINT32 * piTarget,
FLMINT32 iDelta)
{
FLMINT32 i32RetVal;
pthread_mutex_lock( gv_atomicMutex);
(*piTarget) += iDelta;
i32RetVal = *piTarget;
pthread_mutex_unlock( gv_atomicMutex);
return( i32RetVal);
}
/**********************************************************************
Desc:
**********************************************************************/
FLMINT32 posix_atomic_xchg_32(
volatile FLMINT32 * piTarget,
FLMINT32 iNewValue)
{
FLMINT32 i32RetVal;
pthread_mutex_lock( gv_atomicMutex);
i32RetVal = *piTarget;
*piTarget = iNewValue;
pthread_mutex_unlock( gv_atomicMutex);
return( i32RetVal);
}
#endif // FLM_UNIX
#if defined( FLM_WATCOM_NLM)