Applied tthierry's patch to fix compiling on FreeBSD.