Re:Simple, Fast, Practical Non-Blocking and Blocking Concurr...
by gosu on Monday May 26, 2014 @03:34PM
(#7801182)
By storing the struct in union with an integral type - or, if you need a value but not an address, casting to such a union. You might also think to just abuse pointer casting, but IIRC that breaks C strict aliasing assumptions and causes GCC's optimizations to do bad things to your program.
C11 has a new header stdatomic.h which only allows atomic for integer types.
How do you perform CAS on a struct in C( without using a mutex of course )?