[PATCH 01/16] Fix build errors on FreeBSD