Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 14, 2020 Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Getting rid of static cdtors is a good goal for druntime and standard library. Modules that need initialization should do so lazily upon first use. I picked a low-hanging fruit in https://github.com/dlang/phobos/pull/7529 - there is no need at all to initialize and test pointers to function in Posix. Could a Windows engineer help with the Windows part? It's a bit more involved - the pointers to functions should be initialized upon first use in a Singleton manner, and atexit(WSACleanup) needs to be inserted right after the call to WSAStartup. (BTW, has wine support been maintained? It would be useful for such cases - I could test the Windows code without an installation.) |
June 14, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sunday, 14 June 2020 at 18:53:52 UTC, Andrei Alexandrescu wrote:
> (BTW, has wine support been maintained? It would be useful for such cases - I could test the Windows code without an installation.)
(I'm not certain about the rest of your post so just answering this)
I use wine dmd regularly without any trouble. It actually works even better now than it was supposed to since optlink used to have some kind of weird bug on wine and the lld linker is free from such pain!
|
June 14, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sunday, 14 June 2020 at 18:53:52 UTC, Andrei Alexandrescu wrote:
> (BTW, has wine support been maintained? It would be useful for such cases - I could test the Windows code without an installation.)
Probably best to test it on Windows, otherwise you are just testing Wine's implementation and not actually your code.
|
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sunday, 14 June 2020 at 18:53:52 UTC, Andrei Alexandrescu wrote: > Getting rid of static cdtors is a good goal for druntime and standard library. Modules that need initialization should do so lazily upon first use. > > I picked a low-hanging fruit in https://github.com/dlang/phobos/pull/7529 - there is no need at all to initialize and test pointers to function in Posix. > > Could a Windows engineer help with the Windows part? It's a bit more involved - the pointers to functions should be initialized upon first use in a Singleton manner, and atexit(WSACleanup) needs to be inserted right after the call to WSAStartup. > > (BTW, has wine support been maintained? It would be useful for such cases - I could test the Windows code without an installation.) Microsoft offers free images for developers. They have a lifespan of 3 months IIRC, and come with Visual Studio / VSCode installed: https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/ |
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Avrina | On Sunday, 14 June 2020 at 19:26:39 UTC, Avrina wrote:
> On Sunday, 14 June 2020 at 18:53:52 UTC, Andrei Alexandrescu wrote:
>> (BTW, has wine support been maintained? It would be useful for such cases - I could test the Windows code without an installation.)
>
> Probably best to test it on Windows, otherwise you are just testing Wine's implementation and not actually your code.
Wine 5.0 works well for me at least. And I don't think testing on it is a problem, because the cloud autotester should catch the rare differences between Wine and Windows.
|
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mathias LANG | On Monday, 15 June 2020 at 02:37:20 UTC, Mathias LANG wrote:
> On Sunday, 14 June 2020 at 18:53:52 UTC, Andrei Alexandrescu wrote:
>> [...]
>
> Microsoft offers free images for developers. They have a lifespan of 3 months IIRC, and come with Visual Studio / VSCode installed: https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
That's neat!
|
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Are all those indirections still needed? https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo > The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later. |
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | auto our_freeaddrinfo(A...)(A a) @system { initialize; if (freeaddrinfoPointer) // May be null if WSAStartup() failed, just do nothing return; return freeaddrinfoPointer(a); } My, my, that's a subtle bug. Also winsock 2.2 is 0x0202, not 0x2020. |
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 6/15/20 6:20 AM, Kagamin wrote:
> Are all those indirections still needed?
> https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo
>
>> The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later.
Can you please mention this in the github thread? I'd be very glad to remove that stuff.
|
June 15, 2020 Re: Getting rid of global cdtors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 6/15/20 6:25 AM, Kagamin wrote:
> auto our_freeaddrinfo(A...)(A a) @system
> {
> initialize;
> if (freeaddrinfoPointer)
> // May be null if WSAStartup() failed, just do nothing
> return;
> return freeaddrinfoPointer(a);
> }
>
> My, my, that's a subtle bug.
What is the bug? Thanks.
|
Copyright © 1999-2021 by the D Language Foundation