From owner-freebsd-threads@FreeBSD.ORG Fri Feb 4 20:26:15 2011 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 2B710106566B; Fri, 4 Feb 2011 20:26:15 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-threads@FreeBSD.org Date: Fri, 4 Feb 2011 15:25:56 -0500 User-Agent: KMail/1.6.2 References: <201102041409.12314.jkim@FreeBSD.org> In-Reply-To: <201102041409.12314.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201102041525.59821.jkim@FreeBSD.org> Cc: davidxu@FreeBSD.org Subject: Re: [RFC] Implement pthread_getthreadid_np(3) and pthread_getunique_np(3) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2011 20:26:15 -0000 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 #include #include pid_t gettid(void) { if (pthread_main_np() == 0) return (pthread_getthreadid_np()); return (getpid()); } Jung-uk Kim