Patch from g0rdon to compile on freebsd