Question: **UPDATED:** Is there a thread-safe, lock-free and available on all Linux distros *increment* function available in C or C++ ?

Answer: 
GLib has functions to do this. You might check out [<http://library.gnome.org/devel/glib/stable/glib-Atomic-Operations.html>](http://library.gnome.org/devel/glib/stable/glib-Atomic-Operations.html)

Specifically, it sounds like you want g\_atomic\_int\_inc()
I think these are GNU extensions, and processor specific, but have a look at [GNU C Atomic Builtins](http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html).

I think there are also atomic "libraries" available that use inline assembly etc. to provide such features.