Use posix_memalign over memalign if available

*BSD are missing memalign, but NetBSD, FreeBSD and DragonFly BSD have
posix_memalign, so use it instead.