Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Martin Storsjö
On Thu, 2 Aug 2018, Martin Storsjö wrote: On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 13:56, Martin Storsjö 写道: Yes, a responsible user would join all his threads before calling exit() or returning from main, there's no disagreement about that. But the problematic case I'm thinking about

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 13:56, Martin Storsjö 写道: Yes, a responsible user would join all his threads before calling exit() or returning from main, there's no disagreement about that. But the problematic case I'm thinking about is when you load and unload e.g. plugins, w

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Liu Hao
在 2018/8/2 13:56, Martin Storsjö 写道: > Yes, a responsible user would join all his threads before calling exit() > or returning from main, there's no disagreement about that. > > But the problematic case I'm thinking about is when you load and unload > e.g. plugins, which may contain TLS objects.

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/1 17:48, Martin Storsjö 写道: I don't see any nonzero lpReserved parameter when the process is terminating; I tried both just returning normally from main, calling exit(), ExitProcess() and abort() - none of them give anything else than the usual zer

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Liu Hao
在 2018/8/1 17:48, Martin Storsjö 写道: > To verify, I did a s/cxa/foo/ on this file, and compiled it with GCC, > and the resulting object file didn't have any references to cxa_. > I misunderstood it. > I don't see any nonzero lpReserved parameter when the process is > terminating; I tried both

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Martin Storsjö
On Wed, 1 Aug 2018, Liu Hao wrote: 在 2018/8/1 15:43, Martin Storsjö 写道: In order to properly call destructors of a DLL when that DLL is unloaded, we need to provide these as part of the static library libmingw32.a, which gets linked into the module itself. ( ... ... ) +static CRITICAL_SECTION l

Re: [Mingw-w64-public] [PATCH] Add some missing features to shlwapi header

2018-08-01 Thread JonY via Mingw-w64-public
On 08/01/2018 04:52 AM, Alexey Pavlov wrote: > Looks good. signature.asc Description: OpenPGP digital signature -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http

Re: [Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Liu Hao
在 2018/8/1 15:43, Martin Storsjö 写道: > In order to properly call destructors of a DLL when that DLL is > unloaded, we need to provide these as part of the static library > libmingw32.a, which gets linked into the module itself. > ( ... ... ) > +static CRITICAL_SECTION lock; > +static int inited = 0

[Mingw-w64-public] [PATCH 1/4] crt: Add an implementation of __cxa_atexit and __cxa_thread_atexit

2018-08-01 Thread Martin Storsjö
In order to properly call destructors of a DLL when that DLL is unloaded, we need to provide these as part of the static library libmingw32.a, which gets linked into the module itself. C++ libraries (both libstdc++ and libcxxabi) can also provide the function __cxa_thread_atexit, and defer the act

[Mingw-w64-public] [PATCH 3/4] crt: Expose a private variable that indicates whether the module is an exe or dll

2018-08-01 Thread Martin Storsjö
Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/crtdll.c | 2 ++ mingw-w64-crt/crt/crtexe.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index 50a9eb4..5f53602 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crt

[Mingw-w64-public] [PATCH 2/4] crt: Declare _register_thread_local_exe_atexit_callback in headers, provide fallback

2018-08-01 Thread Martin Storsjö
This function is available in the universal CRT. Add a best effort fallback version of it for other CRTs. Signed-off-by: Martin Storsjö --- mingw-w64-crt/Makefile.am| 1 + mingw-w64-crt/misc/register_tls_atexit.c | 29 + mingw-w64-headers/crt/process

[Mingw-w64-public] [PATCH 4/4] crt: Use _register_thread_local_exe_atexit_callback for TLS dtors

2018-08-01 Thread Martin Storsjö
The standard says that destructors of thread local objects should be invoked before any other destructors. Since the destructors are called by the CRT via what has been registered via atexit (ordered so that the function registered last will be executed first), we need to use this API from UCRT to

Re: [Mingw-w64-public] [PATCH] Improve standard conformance and fixes for ddk/scsi.h

2018-08-01 Thread Liu Hao
在 2018-08-01 13:09, Matheus Izvekov 写道: > ddk/scsi.h needed -fpermissive to compile > Moving those struct definitions out of the anonymous union fixes this > > struct CDB is not supposed to have any pointers as fields > > The first issue only emerges when the file is compiled as c++, identifie