Fix compilation on FreeBSD.

This fixes an incorrect header for FreeBSD and a static variable which
conflicted with a variable defined in the standard libc on FreeBSD.
Fix a warning on FreeBSD.

This fixes a warning when compiling on FreeBSD for two undefined
functions.