Fix FreeBSD build

Mostly pertaining to nanosleep and the fact that FreeBSD doesn't have clock_nanosleep, 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 the compiler shits itself on mmap.c.