Implement strnlen locally if the system libc doesn't have it.

Needed for, and currently built only on, NetBSD 5.