support for FreeBSD

largely copied the Linux epoll code and transferred it to kqueue