Quantcast
Channel: In C using Clang atomics, how should I perform an atomic pre-increment? - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Peter Cordes for In C using Clang atomics, how should I perform an...

For _Atomic int x;, your example local = ++shared; already does work atomically, like GNU C__atomic_add_fetch (not ..._fetch_add). ISO C11 is no different for this than ISO C++.The downside is that you...

View Article



Answer by Shawn for In C using Clang atomics, how should I perform an atomic...

You can use the clang/gcc intrinsic function __atomic_add_fetch(), which first adds to a number then returns the new value (There's also __atomic_fetch_add() which acts like the C11...

View Article

Answer by ikegami for In C using Clang atomics, how should I perform an...

You can usev = atomic_fetch_add(&x, 1) + 1;

View Article

In C using Clang atomics, how should I perform an atomic pre-increment?

Expanding from this question (How to do an atomic increment and fetch in C?)In C, using Clang compiler, how can I do the atomic equivalent ofconst int v = ++xAs I understand it, v =...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images