Add FreeBSD support
Add FreeBSD to build
Fix build with 32-bit Clang
Add thread support for FreeBSD