title: UNIX Portable Atomic Operations
body: <p>Is there a (POSIX-)portable way in C for atomic variable operations similar to a portable threading with pthread?</p>
  
  <p>Atomic operations are operations like "increment and get" that are executed atomically that means that no context switch can interfere with the operation. In Linux kernel space, we have to <a href="http://lxr.linux.no/linux/+code=atomic_t" rel="noreferrer">atomic_t</a> type, in Java we have the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/atomic/package-summary.html" rel="noreferrer">java.util.concurrent.atomic</a> package.</p>
  
  <p>On Linux, the atomic.h file provides atomic operations, but the include is platform dependent e.g. <code>#include &lt;asm-x86_64/atomic.h&gt;</code> and it is not available on Mac OS X in a similar way.</p>