On 06.05.2012, at 21:29, Rick Mann wrote:
> 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;
Your code has two variables and make it the programmer's job to keep
>> 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 t
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
On 06.05.2012, at 02:05, Andreas Grosam wrote:
> 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?
Have you tried union{} ?
union {
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