LDC_global_crt_ctor for threads

kinke noone at nowhere.com
Fri Apr 3 19:25:00 UTC 2020


On Friday, 3 April 2020 at 19:16:04 UTC, Marcel wrote:
> On Friday, 3 April 2020 at 00:37:39 UTC, kinke wrote:
>> On Thursday, 2 April 2020 at 22:16:45 UTC, Marcel wrote:
>>> Oh, I didn't explain my situation properly: I'm writing a 
>>> memory allocation library and there's some thread local state 
>>> that I must take care of when the thread exits. Now, I can 
>>> always do as you said and ask the user to place calls to 
>>> certain functions at thread main, but I'd really prefer if 
>>> that was done automatically.
>>
>> You'll need some sort of runtime support for automation, so if 
>> you don't use druntime because of -betterC, you'll need to 
>> look (and ask) elsewhere. C doesn't have such a thing AFAIK; 
>> the C++ runtime may have something like __cxa_thread_atexit 
>> (e.g., used by clang for a thread_local global with dtor when 
>> targeting glibc).
>
> I see... A shame but it's understandable.
> Thank you anyway :)

You could add the module dtor for non-`version(D_BetterC)` though 
and add a non-betterC configuration to your library. Normal D 
stuff would link against that config and work out of the box; 
-betterC guys have to put up with the restrictions imposed by a 
missing druntime.


More information about the digitalmars-d-ldc mailing list