A tiny diff below to make src/thread.cpp compile on FreeBSD.
Other issues on FreeBSD are:
1) no xlocale stuff, causes include/__locale to explode with
missing missing declarations for LC_*_MASK and _IS* functions.
unknown type locale_t
2) The following math functions are not implemented on FreeBSD, causing include/cmath breakage
coshl expl logl log10l powl sinhl tanhl acoshl asinhl atanhl cbrtl erfl erfcl expm1l lgammal log1pl log2f
3) The following errno's are not defined in FreeBSD's errno.h causing include/system:_error breakage
ENODATA ENOSR ENOSTR ETIME