Fix FreeBSD build

Mostly pertaining to nanosleep and the fact that FreeBSD doesn't have that, as well as the fact that if you define all the crap in those checks without checking if it exists first it breaks all the BSD extentions and compiler shits itself on mmap.c.