I would prefer use POSIX and return INT_MAX or LONG_MAX, is performance to avoid that call so important here??

Also the LONG_MAX value you copied is wrong, there is a 1 missing after the last 7 ;)