Make this work on FreeBSD.

From my understanding this should make it work on NetBSD and Dragonfly
as well.

Part of #191.