I have a struct called Ambigous, and inside the struct I have an array of pointers to other Ambigous.
I want to use OSAtomic.h library, to do CompareandSwaps.
However I am having trouble getting the array to play nice.
OSAtomicCompareAndSwapPtrBarrier(void *__oldValue, void *__newValue,
void *volatile *__theValue)
is the compare and swap function.
and inside my struct I have
Ambigous * volatile* list;
and the call is
bool res=OSAtomicCompareAndSwapPtrBarrier(current_node, new_node, local->list[pos]);
When I try to cas by
bool res=OSAtomicCompareAndSwapPtrBarrier(current_node, new_node, (void * volatile *)local->list[pos]);
I get a bad EXE_BAD_ACCESS
So i guess what i am answering is how should i declare the array of volatile pointers?
Perhaps you want
Note that the CAS operation is basically
If you pass a
list[pos]
, the 3rd argument will be of typeAmbigous*
, and*val
will be of typestruct Ambigous
which cannot be compared to a pointer.