Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Feb 2011 15:25:56 -0500
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        freebsd-threads@FreeBSD.org
Cc:        davidxu@FreeBSD.org
Subject:   Re: [RFC] Implement pthread_getthreadid_np(3) and pthread_getunique_np(3)
Message-ID:  <201102041525.59821.jkim@FreeBSD.org>
In-Reply-To: <201102041409.12314.jkim@FreeBSD.org>
References:  <201102041409.12314.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 04 February 2011 02:09 pm, Jung-uk Kim wrote:
> Our pthread_t is not an integral type and it causes a lot of
> trouble porting some software, which relies on Linux's gettid() or
> similar syscalls:
>
> http://www.kernel.org/doc/man-pages/online/pages/man2/gettid.2.html
>
> For example:
>
> http://docs.freebsd.org/cgi/mid.cgi?201102032111.13479.jkim
>
> To solve this problem, I implemented two functions:
>
> http://people.freebsd.org/~jkim/thr_tid.diff

BTW, you can easily emulate semantic of Linux's gettid() with it:

#include <pthread_np.h>
#include <sys/types.h>
#include <unistd.h>

pid_t
gettid(void)
{

	if (pthread_main_np() == 0)
		return (pthread_getthreadid_np());
	return (getpid());
}

Jung-uk Kim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102041525.59821.jkim>