Ejemplo n.º 1
0
void
uu_set_error(uint_t code)
{
	if (_uu_main_thread) {
		_uu_main_error = code;
		return;
	}
#if defined(PTHREAD_ONCE_KEY_NP)
	if (pthread_key_create_once_np(&uu_error_key, NULL) != 0)
		uu_error_key_setup = -1;
	else
		uu_error_key_setup = 1;
#else	/* PTHREAD_ONCE_KEY_NP */
	if (uu_error_key_setup == 0) {
		(void) pthread_mutex_lock(&uu_key_lock);
		if (uu_error_key_setup == 0) {
			if (pthread_key_create(&uu_error_key, NULL) != 0)
				uu_error_key_setup = -1;
			else
				uu_error_key_setup = 1;
		}
		(void) pthread_mutex_unlock(&uu_key_lock);
	}
#endif	/* PTHREAD_ONCE_KEY_NP */
	if (uu_error_key_setup > 0)
		(void) pthread_setspecific(uu_error_key,
		    (void *)(uintptr_t)code);
}
Ejemplo n.º 2
0
/*
 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
 */
enum clnt_stat
clnt_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs,
	caddr_t argsp, xdrproc_t xresults,
	caddr_t resultsp, resultproc_t eachresult)
{
	if (thr_main()) {
		clnt_broadcast_result_main = eachresult;
	} else {
		(void) pthread_key_create_once_np(&clnt_broadcast_key, NULL);
		(void) pthread_setspecific(clnt_broadcast_key,
							(void *)eachresult);
	}
	return (rpc_broadcast(prog, vers, proc, xargs, argsp, xresults,
				resultsp, (resultproc_t)rpc_wrap_bcast, "udp"));
}
Ejemplo n.º 3
0
/*
 * Create thread key for thread specific data.
 */
static void create_jcr_key()
{
    int status;

#ifdef PTHREAD_ONCE_KEY_NP
    status = pthread_key_create_once_np(&jcr_key, NULL);
#else
    status = pthread_key_create(&jcr_key, NULL);
#endif
    if (status != 0) {
        berrno be;
        Jmsg1(NULL, M_ABORT, 0, _("pthread key create failed: ERR=%s\n"),
              be.bstrerror(status));
    }
}
Ejemplo n.º 4
0
void *
thr_get_storage(pthread_key_t *keyp, size_t size, void (*destructor)(void *))
{
	void *addr;

	if (pthread_key_create_once_np(keyp, destructor) != 0)
		return (NULL);
	addr = pthread_getspecific(*keyp);
	if (addr == NULL && size != 0) {
		addr = calloc(1, size);
		if (addr != NULL && pthread_setspecific(*keyp, addr) != 0) {
			free(addr);
			return (NULL);
		}
	}

	return (addr);
}
Ejemplo n.º 5
0
int
scf_setup_error(void)
{
	return (pthread_key_create_once_np(&scf_error_key, NULL) == 0);
}