fixes for netbsd

rebased version of https://github.com/antirez/redis/pull/591
plus one more fix.