BUG: prevent nonzero memchr from running out of bounds
Merge pull request #4474 from juliantaylor/nonzero-bug

BUG: prevent nonzero memchr from running out of bounds
MAINT: add NPY_BEGIN_THREAD_NDITER and remove unnecessary needs_api checks

the thread variable is initialized to NULL and checked by the end macro
so the needs_api check is redundant.
ENH: release gil for nonzero
ENH: release gil for np.take and np.arange

implies adapting check_and_adjust_index to allow threadsafe error
reporting.
ENH: release gil for np.packbits and np.unpackbits