Exemplo n.º 1
0
static
void
infosig(int nada, siginfo_t *info, void *ctxp)
{
	ucontext_t *ctx = ctxp;
	char buf[256];

	snprintf(buf, sizeof(buf), "lwp %d pc=%p sp=%p\n",
		(int)lwp_gettid(),
		(void *)(intptr_t)ctx->uc_mcontext.mc_rip,
		(void *)(intptr_t)ctx->uc_mcontext.mc_rsp);
	write(2, buf, strlen(buf));
}
Exemplo n.º 2
0
/***********************************************************************
 *           get_unix_tid
 *
 * Retrieve the Unix tid to use on the server side for the current thread.
 */
static int get_unix_tid(void)
{
    int ret = -1;
#ifdef HAVE_PTHREAD_GETTHREADID_NP
    ret = pthread_getthreadid_np();
#elif defined(linux)
    ret = syscall( __NR_gettid );
#elif defined(__sun)
    ret = pthread_self();
#elif defined(__APPLE__)
    ret = mach_thread_self();
    mach_port_deallocate(mach_task_self(), ret);
#elif defined(__NetBSD__)
    ret = _lwp_self();
#elif defined(__FreeBSD__)
    long lwpid;
    thr_self( &lwpid );
    ret = lwpid;
#elif defined(__DragonFly__)
    ret = lwp_gettid();
#endif
    return ret;
}
Exemplo n.º 3
0
unsigned long iv_get_thread_id(void)
{
	unsigned long thread_id;

#if defined(__NR_gettid)
	thread_id = syscall(__NR_gettid);
#elif defined(HAVE_GETTID) && defined(HAVE_PROCESS_H)
	thread_id = gettid();
#elif defined(HAVE_LWP_GETTID)
	thread_id = lwp_gettid();
#elif defined(HAVE_THR_SELF) && defined(HAVE_SYS_THR_H)
	long thr;
	thr_self(&thr);
	thread_id = (unsigned long)thr;
#elif defined(HAVE_THR_SELF) && defined(HAVE_THREAD_H)
	thread_id = thr_self();
#else
#warning using pthread_self for iv_get_thread_id
	thread_id = pthr_self();
#endif

	return thread_id;
}