From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpZGR-00075l-Oi for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:26:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpZGP-0005Oc-5I for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:26:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpZGO-0005MM-Tv for qemu-devel@nongnu.org; Thu, 20 Jun 2013 03:26:37 -0400 Date: Thu, 20 Jun 2013 15:26:33 +0800 From: Fam Zheng Message-ID: <20130620072633.GA24927@localhost.nay.redhat.com> References: <1371203313-26490-1-git-send-email-stefanha@redhat.com> <1371203313-26490-7-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1371203313-26490-7-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [RFC 06/13] qemu-thread: add TLS wrappers Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Paolo Bonzini Cc: Kevin Wolf , Anthony Liguori , Ping Fan Liu , qemu-devel@nongnu.org On Fri, 06/14 11:48, Stefan Hajnoczi wrote: > From: Paolo Bonzini > > Fast TLS is not available on some platforms, but it is always nice to > use it. This wrapper implementation falls back to pthread_get/setspecific > on POSIX systems that lack __thread, but uses the dynamic linker's TLS > support on Linux and Windows. > > The user shall call alloc_foo() in every thread that needs to access the > variable---exactly once and before any access. foo is the name of the > variable as passed to DECLARE_TLS and DEFINE_TLS. Then, get_foo() will > return the address of the variable. It is guaranteed to remain the same > across the lifetime of a thread, so you can cache it. Would tls_alloc_foo() and tls_get_foo() be easier to read and less possible for name conflict? Fam