Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 22:55:41 UTC, Imperatorn wrote: Check the assembly I already did, here's the "wrong" version when I only run `$ dmd -betterC -m64 test.d`: ``` Dump of file test.obj main: pushrbp mov rbp,rsp mov rax,qword ptr gs:[58h] mov

Re: Thread local variables in betterC

2021-05-09 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 9 May 2021 at 21:42:54 UTC, Blatnik wrote: On Sunday, 9 May 2021 at 20:56:01 UTC, Ali Çehreli wrote: This is a long shot, but are you on OSX? I think TLS is handled specially for 32-bit OSX and that may somehow work in this case. (?) Nope, I'm on (64bit) windows. Another really

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 20:56:01 UTC, Ali Çehreli wrote: This is a long shot, but are you on OSX? I think TLS is handled specially for 32-bit OSX and that may somehow work in this case. (?) Nope, I'm on (64bit) windows. Another really weird thing is that if I compile this code in VisualD

Re: Thread local variables in betterC

2021-05-09 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/21 11:49 AM, Blatnik wrote: Also, why did it work for 32-bits then? This is a long shot, but are you on OSX? I think TLS is handled specially for 32-bit OSX and that may somehow work in this case. (?) Ali

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 18:46:18 UTC, rikki cattermole wrote: No. It is tied to druntime. I.e. on Linux it calls __tls_get_addr to get the address. Oh. I wish I got a warning about that from the compiler then >.> Also, why did it work for 32-bits then?

Re: Thread local variables in betterC

2021-05-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/05/2021 6:41 AM, Blatnik wrote: Do thread local variables work in -betterC? Or maybe it's better to ask are they _supposed_ to work in -betterC? No. It is tied to druntime. I.e. on Linux it calls __tls_get_addr to get the address.

Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
Do thread local variables work in -betterC? Or maybe it's better to ask are they _supposed_ to work in -betterC? Here's a simple test program: ```D // test.d auto a; extern(C) void main() { printf("before... "); a = 42; printf("after"); } import core.stdc.

Re: Thread local variables in betterC

2021-05-09 Thread Blatnik via Digitalmars-d-learn
On Sunday, 9 May 2021 at 18:41:33 UTC, Blatnik wrote: Here's a simple test program: Whoops, `auto a` should be `int a`. Habits :P