Fixes for FreeBSD

Hi,

The following patch is needed for f3 compilation on FreeBSD
It is cross checked and still compiles on ArchLinux

/Uffe