add NetBSD to some of the #ifdefs (patch partly from 6.8 branch)