Define NAN ourselves if it doesn't exist and use GLib MIN() and MAX() instead of fminf() and fmaxf().