RE: Is there an atomic compare-swap function/routine in the standard?

2020-02-14 Thread shwaresyst

Presently, no. There are operations, such as with semaphores, where this sort 
of functionality might be used but has been left unspecified as many CPUs don't 
support exchanges; for most older ones only loads and stores are atomic, and 
the volatile modifier and sigatomic_t types are geared to be used this way. 
Without direct hardware support, on those systems some aspects of c11s 
stdatomic interfaces get a performance and code size penalty to emulate 
robustly; possibly why it's an optional header entirely.
On Friday, February 14, 2020 Danny Niu  wrote:
As asked, is there an CMPXGCHG-like function in the standard? 

I tried looking for keywords such as cmp, comp, ch, but 
nothing turned up in the system interfaces list. 

The C language introduced atomic functions in C11 though. 




Is there an atomic compare-swap function/routine in the standard?

2020-02-14 Thread Danny Niu
As asked, is there an CMPXGCHG-like function in the standard? 

I tried looking for keywords such as cmp, comp, ch, but 
nothing turned up in the system interfaces list. 

The C language introduced atomic functions in C11 though.