@marcan and if all you need is to know how many threads to spawn to scale on cores:
sysconf(_SC_NPROCESSORS_CONF); /* processors configured */
sysconf(_SC_NPROCESSORS_ONLN); /* processors available */
is even more portable (though there are 2 different names depending on the OSes because why not).