patch by Isaac Dunham. matched closely (maybe not exact) to glibc's idea of what _BSD_SOURCE should make visible.
we do not bother making h_errno thread-local since the only interfaces that use it are inherently non-thread-safe. but still use the potentially-thread-local ABI to access it just to avoid lock-in.