Added freebsd support

Essentially made the darwin code also build on freebsd. Tested in a Freebsd-9.1 VM.