Re: Interlocked +1/-1 on Mac OS X?
Re: Interlocked +1/-1 on Mac OS X?
- Subject: Re: Interlocked +1/-1 on Mac OS X?
- From: Hugh Sontag <email@hidden>
- Date: Wed, 10 May 2006 11:52:30 -0500
/*
* AddAtomic()
*
* Summary:
* 32-bit add operation, performed atomically with respect to all
* devices that participate in the coherency architecture of the
* platform.
*
* Discussion:
* The AddAtomic function adds the specified amount to the value at
* the specified address and returns the original value. This
* function guarantees atomicity only with main system memory. It is
* specifically unsuitable for use on noncacheable memory such as
* that in devices; this function cannot guarantee atomicity, for
* example, on memory mapped from a PCI device.
*
* Parameters:
*
* amount:
* The amount to add.
*
* address:
* The 4-byte aligned address of the value to update atomically.
*
* Result:
* The value before the addition
*
* Availability:
* Mac OS X: in version 10.0 and later in CoreServices.framework
* CarbonLib: in CarbonLib 1.0 and later
* Non-Carbon CFM: in InterfaceLib 8.5 and later
*/
extern SInt32
AddAtomic(
SInt32 amount,
SInt32 * address)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
Anyone know if there's a macro, CXX extension, gcc extension, POSIX call, or
any other Mac OS X call that does an interlocked increment/decrement (adds 1
or subtracts 1 to an integer). Yes, I know I can use a mutex, but life is
way easier (as well as overhead is a lot lower) when this kind of call is
available (especially since these days the CPU has dedicated instruction for
it). For example, Win32 has them:
long InterlockedIncrement( long* );
long InterlockedDecrement( long* );
Thanks,
Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden