This is copied from musl (MIT license). This is newer and more thorough than that of FreeBSD currently shipped only on Cygwin. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>