Fix build on FreeBSD

Thanks to Olivier Duchateau for the patch.