__builtin_thread_pointer
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Feb 12 18:57:50 GMT 2025
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
More information about the Cygwin
mailing list