Re: OSAtomic built-in operations
Re: OSAtomic built-in operations
- Subject: Re: OSAtomic built-in operations
- From: Rick Mann <email@hidden>
- Date: Sun, 06 May 2012 21:29:13 -0700
On May 6, 2012, at 17:11 , Stefan Werner wrote:
> Have you tried union{} ?
>
> union {
> int32_t s;
> uint32_t u;
> } atomicvar;
> atomicvar.u = 0;
> OSAtomicCompareAndSwap32(0, 1, &atomicvar.s);
> OSAtomicOr32Orig(0, &atomicvar.u);
I've seen this technique in other places. Why is that better than just casting pointer types? Like this:
int32_t s;
uint32_t u;
u = *(uint32_t*) &s;
--
Rick
_______________________________________________
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