add several #ifdef for FreeBSD.