On Tue, 6 Oct 2026, Kirill Makurin wrote:

LIU Hao wrote:

在 2026-10-6 17:05, Kirill Makurin 写道:
While I don't oppose idea of mingw-64 providing C11 threading support, I think 
we should not provide them in the same way as other replacements/emulations - 
static functions in import libraries.

My main concern is ABI stability. Each binary (EXE or DLL) will have their own 
statically linked implementation. If we ever change ABI or even an internal 
structure pointed to by handle-like objects, we will ultimately introduce 
breakages in cases such objects were passed across different binaries. Also, we 
might need to keep track of some internal state.

If mingw-w64 were to implement C11 threading, I think it should be a separate 
library, so it can be used as a DLL.

If it depends on winpthreads anyway then it may be implemented in there. The 
separate DLL will be called
libwinpthread-1.dll.

Implementing C11 threads support around winpthreads is surely an option. OTOH, 
C11 threads look pretty minimalistic:

1. Threads (thrd_t)
2. Mutexes (mtx_t)
3. Once (once_flag)
4. Conditional variables (cnd_t)

I think it would be better to implement them directly around Windows APIs, is a separate library. We could reuse code from winpthreads though.

Yes, I agree. I think that toolchains linking in winpthreads as a default library is becoming less common, so for them, requiring winpthreads for C11 threads sounds suboptimal.

As for the other points made earlier - I'm not sure that we need to have them ABI compatible with MSVC's version - probably not. If we can it would be nice though.

Likewise, I think don't think that it's strictly necessary to have the code in a separate DLL at all. Users diskike extra runtime DLLs. Are we sure the implementation needs any shared state? And even if needed, I think it would be rare to have C11 threads.h types used across DLL boundaries.

(And given https://github.com/skeeto/w64devkit/blob/master/src/threads.c it seems like an implementation can be very slim - at least as long as one doesn't implement all the details of the API.)

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to