UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function available in C or C++ ?
GLib has functions to do this. You might check out http://library.gnome.org/devel/glib/stable/glib-Atomic-Operations.html
Specifically, it sounds like you want g_atomic_int_inc()