Is there a (POSIX-)portable way in C for atomic variable operations similar to a portable threading with pthread?
Atomic operations are operations like \"increment a
Since you asked for OS X:
(and since cross platformity was raised in this thread.)
OS X has functions OSAtomicAdd32() and friends. They are declared in "/usr/include/libkern/OSAtomic.h". See The Threading Programming guide, section "Using Atomic Operations".
And for Windows, there is InterlockedIncrement() and friends (see MSDN).
Together with the gcc builtins __sync_fetch_and_add() and friends (has been linked above), you should have something for every main desktop platform.
Please note that I did not yet use them by myself, but maybe will do so in the next few days.