>> 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;
Indeed -- and my understanding is C only guarantees that the most
recently-assigned member of a union to be valid. So if the OP is
worried about correctness, it would seem the union approach doesn't
help.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]