remove thread_private.h, no longer needed
include system headers for err.h compat macros
add strndup/strnlen compat functions from OpenBSD
remove bash-isms from test scripts
check link requirements for dl_iterate_phdr

Note that gcc chose to disable this rather than cause link issues with
older copies of Solaris 10:
https://gcc.gnu.org/ml/gcc-patches/2012-01/msg00816.html

If we want to support Solaris <10.10 (I'd rather support up-to-date
versions), getentropy_solaris would need to change.
prefer - over /dev/stdin for cmp test