X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Tue, 4 Sep 2012 14:58:04 +0200 Message-ID: Subject: limitations of TLS using GCC's __thread keyword and Cygwin From: =?UTF-8?Q?V=C3=A1clav_Zeman?= To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 -- VZ -- 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