DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51CIxPwg885539 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 51CIxPwg885539 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=ByPon88G X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81DE5385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1739386763; bh=FyjqNB5aJhFPGZoZwxb0U+08oTJdKXfTUjYfbhmtOrQ=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ByPon88GN5uyz9tbNOIfQU4MdnC5vmjTVDTwQYUQZv0OqviHvkLUZ+BmKZ7X2tMbh s3ICW4WhimmNDWnsVlUcHECy85ej7neq8cZ9R3NuunGYsBwadMtk3ovxGnXfeIxXfo /77NBADgwXstZXpD9yVSTA6BYeKY+VnzOLT7TPEM= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0E6E3858C53 Date: Wed, 12 Feb 2025 19:57:50 +0100 To: cygwin AT cygwin DOT com Subject: Re: __builtin_thread_pointer Message-ID: Mail-Followup-To: cygwin AT cygwin DOT com References: <9c6a1ccc-d2fb-4aaf-b8c2-29574fa640b4 AT cornell DOT edu> <6faedefc-eb17-4b02-89b9-44b73e82d43f AT SystematicSW DOT ab DOT ca> <0252F948-10C3-4B9E-943D-ACA35E190726 AT unified-streaming DOT com> <87935cbb-4a43-4ebd-b8cb-125ecfcbcdc3 AT SystematicSW DOT ab DOT ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Feb 11 23:52, Dimitry Andric via Cygwin wrote: > Yes, that is the RISCV or SH specific method. On x86_64, you access it via the fs register, i.e. gcc (on Linux at least :) compiles: > > void *p = __builtin_thread_pointer(); > > to something like: > > movq %fs:0, %rax > movq %rax, -8(%rbp) > > If somebody knows how to build the Cygwin gcc package from scratch, > they could inspect the config.log file, to see what that says about > TLS detection. https://cygwin.com/pipermail/cygwin/2025-February/257300.html As I wrote it's different on Windows and there's no good equivalent. On Windows, %fs points to the TEB on 32 bit x86, while it's %gs on x86_64. The TEB is not the same thing as the TCB in NPTL, which is what __builtin_thread_pointer() returns. I don't think we can implement this in a way which is even marginally similar... Corinna -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple