Only use madvise(2) if available.

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

* maint:
  Add memmem(3) from FreeBSD r188080 for use where needed
  Only use madvise(2) if available.