atomic_rmw.c (487B)
1 /* Atomic read-modify-write on a file-scope _Atomic global. The address 2 * escapes (global), so codegen emits the real exclusive-monitor sequence 3 * (ldaxr/stlxr loop) plus a barrier, and the final load is ldar — the 4 * acquire/release/exclusive atomics the disassembler must decode and the 5 * round-trip re-encode. Exit: 30 + 8 + 4 = 42. */ 6 _Atomic int g = 30; 7 int test_main(void) { 8 __atomic_fetch_add(&g, 8, __ATOMIC_SEQ_CST); 9 return __atomic_load_n(&g, __ATOMIC_SEQ_CST) + 4; 10 }