From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtkBj-0000X2-Bx for qemu-devel@nongnu.org; Wed, 17 Aug 2011 13:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtkBd-0005Go-Td for qemu-devel@nongnu.org; Wed, 17 Aug 2011 13:45:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtkBd-0005GV-MS for qemu-devel@nongnu.org; Wed, 17 Aug 2011 13:45:53 -0400 Message-ID: <4E4BFE4D.2080706@redhat.com> Date: Wed, 17 Aug 2011 10:45:49 -0700 From: Paolo Bonzini MIME-Version: 1.0 References: <1313520667-26507-1-git-send-email-pbonzini@redhat.com> <4E4BF6D6.5040801@redhat.com> <4E4BFA29.7010703@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu-thread: add TLS wrappers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On 08/17/2011 10:37 AM, Blue Swirl wrote: > > I would agree (just did it for fun and to see how it looks like), but > > perhaps we can do something similar to what Windows does for OpenBSD too. > > > > Though I'm quite disappointed and I must say OpenBSD should enter the 21st > > century. > > I can't justify their design decisions, but isn't __thread a > non-standard extension by GCC anyway whereas POSIX threads are the > standard? Are other compilers supporting it? Visual C++ supports __declspec(thread). pthread TLS is orders of magnitudes slower than __thread. __thread in an executable is just as fast as a non-TLS variable access, 2 or 3 machine language instructions at most. Some pthread_getspecific implementation do a _linear walk_ of the keys. In that case it may work to have something like Windows plus a single pthread_getspecific key. On the other hand, Windows provides very good support for that thanks to its ordered subsections (.tls$something). It only needs a bit of preprocessor magic. Thinks such as linker scripts would be way out of scope. Paolo