void exacct_seterr(int errval) { if (thr_main()) { exacct_errval = errval; return; } (void) thr_keycreate_once(&errkey, 0); (void) thr_setspecific(errkey, (void *)(intptr_t)errval); }
static vars_storage * _get_vars_storage(thread_key_t *keyp) { vars_storage *vars; if (thr_keycreate_once(keyp, free) != 0) return (NULL); vars = pthread_getspecific(*keyp); if (vars == NULL) { vars = calloc(1, sizeof (vars_storage)); if (thr_setspecific(*keyp, vars) != 0) { if (vars) (void) free(vars); vars = NULL; } } return (vars); }
static char * _get_stop(thread_key_t *keyp) { char *str; if (thr_keycreate_once(keyp, free) != 0) return (NULL); str = pthread_getspecific(*keyp); if (str == NULL) { str = calloc(CHARS, sizeof (char)); if (thr_setspecific(*keyp, str) != 0) { if (str) (void) free(str); str = NULL; } } return (str); }