Fix build errors on FreeBSD