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: Eric Albert <email@hidden>
- Date: Wed, 10 May 2006 10:03:38 -0700
On May 10, 2006, at 9:14 AM, Andy O'Meara wrote:
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* );
See <libkern/OSAtomic.h>, specifically the functions whose names
start with OSAtomicIncrement and OSAtomicDecrement.
Hope this helps,
Eric
_______________________________________________
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