X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0	tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_NEUTRAL
X-Spam-Check-By: sourceware.org
Message-ID: <504612A3.6070605@cs.utoronto.ca>
Date: Tue, 04 Sep 2012 10:39:31 -0400
From: Ryan Johnson <ryan.johnson@cs.utoronto.ca>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: limitations of TLS using GCC's __thread keyword and Cygwin
References: <CAKw7uVgy4qgeqVMk1dRPb=Lr-so5NP3e6XjER=ZGqd+B+MT3ZQ@mail.gmail.com>
In-Reply-To: <CAKw7uVgy4qgeqVMk1dRPb=Lr-so5NP3e6XjER=ZGqd+B+MT3ZQ@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On 04/09/2012 8:58 AM, Václav Zeman wrote:
> Hi.
>
> I am am porting a library that can use the __thread keyword in its
> internals to provide thread local storage. Now, with MSVC there is a
> limitation on pre-Vista Windows (see [1]) that DLLs using
> __declspec(thread) (MSVC equivalent of GCC's __thread) cannot be
> loaded using LoadLibrary() because pre-Vista Windows allocate the TLS
> declared that way only on process startup. Vista and later Windows do
> not seem to have the limitation. Since Cygwin officially still
> supports at least Windows XP, I want to provide a library that works
> there as well.
>
> Does Cygwin's GCC and its TLS emulation work around this problem? IOW,
> are Cygwin DLLs using TLS declared using __thread keyword safe to be
> loaded using LoadLibrary()/dlopen() or are they not safe to be loaded
> that way?
>
> [1] http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx
>
I suspect it's not a problem, but if I were you I'd write a simple test 
program to see. Unfortunately, TLS in general seems broken on my machine 
when I tried it, but that might be due to my home-brew gcc being 
configured wrong or something.

Ryan


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

