I have in my project the following method:
long compare( long* avar, long comp, long exc )
{
return __sync_val_compare_and_swap( avar, comp, exc );
}
But if i want to compile my project using gcc of version (older vers开发者_如何转开发ion, 3.4.3 for instance) which doesn't support AtomicBuiltins What is the alternative path of the solution our problem? What kind of the alternative functions( the alternative of __sync_val_compare_and_swap ) or block of functions we can use instead of __sync_val_compare_and_swap?
The only alternative that I would see is that you'd have to implement this through assembler. I think the asm
extension of gcc predates the stone age, so any compiler that you might encouter will support this.
Implementing this particular function is not so difficult, and you'd find references easily. You'd have to provide different implementations for each architecture that you care for, though.
精彩评论