Bug 24532 – Add pragma to set function as a TLS callback function for Windows

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2024-05-02T22:46:56Z
Last change time
2024-12-13T19:35:03Z
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
Moved to GitHub: dmd#18237 →

Comments

Comment #0 by alphaglosined — 2024-05-02T22:46:56Z
The ``DllMain`` function on Windows is an optional /user/ function for being notified of when a binary load/unload or thread constructs and destructs. However, it is not really an entry point function akin to ``main``. It should be viewed as one of many call-back functions for TLS. https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#tls-callback-functions Having a pragma to set a function as one of these, would enable multiple library notifications without tying up and using the ``DllMain`` function. For druntime this is especially important if you want that to be a static library, preventing the need for ``SimpleDllMain`` to exist. Related: https://issues.dlang.org/show_bug.cgi?id=23756 which is about thread hooks similar to crt_constructor.
Comment #1 by robert.schadek — 2024-12-13T19:35:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18237 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB