From 682e9da7afe2109e5d63a4f4ec0a327f74f4ca8a Mon Sep 17 00:00:00 2001 From: ahodgkinson Date: Thu, 16 Mar 2006 20:52:55 +0000 Subject: [PATCH] Misc. AIX atomic op changes. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@176 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- flaim/src/ftk.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/flaim/src/ftk.h b/flaim/src/ftk.h index fdf1365..ca95096 100644 --- a/flaim/src/ftk.h +++ b/flaim/src/ftk.h @@ -1856,13 +1856,23 @@ Note: Some of this code is derived from the Ximian source code contained #elif defined( FLM_AIX) + /********************************************************************** + Desc: + **********************************************************************/ + FINLINE int aix_atomic_add( + volatile int * piTarget, + int iDelta) + { + return( fetch_and_add( piTarget, iDelta) + iDelta); + } + /********************************************************************** Desc: **********************************************************************/ FINLINE FLMINT32 ftkAtomicIncrement( volatile FLMINT32 * pi32Target) { - return( fetch_and_add( pi32Target, 1)); + return( aix_atomic_add( (int *)pi32Target, 1)); } /********************************************************************** @@ -1871,7 +1881,7 @@ Note: Some of this code is derived from the Ximian source code contained FINLINE FLMINT32 ftkAtomicDecrement( volatile FLMINT32 * pi32Target) { - return( fetch_and_add( pi32Target, -1)); + return( aix_atomic_add( (int *)pi32Target, -1)); } /********************************************************************** @@ -1881,19 +1891,19 @@ Note: Some of this code is derived from the Ximian source code contained volatile FLMINT32 * pi32Target, FLMINT32 i32NewVal) { - FLMINT32 i32OldVal; + int iOldVal; for( ;;) { - i32OldVal = *pi32Target; + iOldVal = *pi32Target; - if( compare_and_swap( pi32Target, &i32OldVal, i32NewVal)) + if( compare_and_swap( (int *)pi32Target, &iOldVal, (int)i32NewVal)) { break; } } - return( i32OldVal); + return( iOldVal); } #elif defined( FLM_HPUX)