On Wed, 28 Apr 2021, Liu Hao wrote:

在 4/27/21 2:00 AM, Christian Franke 写道:

Which complexity do you mean - the extra cost of the system call or the extra 15 lines of code?


Just for the record - I wouldn't mind applying the patch or something like it. I agree with the arguments that it would be beneficial to get more precision here, even if one in general maybe can argue that we don't strictly need to provide such precision.

There are also some issues in this patch. You can't assign a `void*` to a pointer-to-function.

We have lots of cases of wrappers that do GetProcAddress() in mingw-w64-crt, and a lot of them use a plain (void*) cast. (Others do cast the return value of GetProcAddress() directly to the type of the function pointer.)

And you can't use `volatile` variables for synchronization; you have to use `_Atomic` which yet adds more complexity in code.

FWIW lots of similar existing cases in mingw-w64-crt just use a plain global pointer that is overwritten, without any atomicity. Just grep for GetProcAddress in mingw-w64-crt and look at all the existing cases. Many of them go via an __MINGW_IMP_SYMBOL pointer which first points at an init function, which then updates the __MINGW_IMP_SYMBOL pointer - but that's essentially the same as here even though this is a static pointer and used inline in a different function.

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to