Only use madvise(2) if available.

Fixes build on OpenSolaris
Add memmem(3) from FreeBSD r188080 for use where needed