OSAtomic built-in operations
OSAtomic built-in operations
- Subject: OSAtomic built-in operations
- From: Andreas Grosam <email@hidden>
- Date: Sun, 06 May 2012 11:05:45 +0200
Hi All!
I would like to use OSAtomicCompareAndSwap32 and OSAtomicOr32Orig using the same variable. Unfortunately, the first requires a signed int, the other an unsigned int.
How can I get this to work?
Example:
enum {
State_Canceling = 1U << 7;
};
int _state; // would like to have an uint32_t
int new_state = OSAtomicCompareAndSwap32(State_0, State_1, &_state);
…
if (OSAtomicOr32Orig(State_Canceling, &_state) != 0) {
// canceling
}
The solution would be a "OSAtomicCompareAndSwapU32", or is it save to pass a signed int where an unsigned int is required, considering strong Alias rules and whatever optimizations the compiler applies?
Thanks for tips!
Reagards
Andreas
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden