On 04/13/2016 01:30 PM, Kai Tietz wrote: > Hi, > > I don't see that adding psdk header dependency to our crt header is > something sane. Why is this change in crt headers at all necessary? > > Kai > > 2016-04-13 13:05 GMT+02:00 Hugo Beauzée-Luyssen <[email protected]>: >> Provide a redirection from _beginthreadex -> CreateThread _endthread -> >> ExitThread, as the documentation recommends. >> --- >> mingw-w64-headers/crt/process.h | 6 +++ >> mingw-w64-libraries/winstorecompat/Makefile.am | 1 + >> .../winstorecompat/src/beginthread.c | 54 >> ++++++++++++++++++++++ >> 3 files changed, 61 insertions(+) >> create mode 100644 mingw-w64-libraries/winstorecompat/src/beginthread.c >> >> diff --git a/mingw-w64-headers/crt/process.h >> b/mingw-w64-headers/crt/process.h >> index 8034d41..bf01219 100644 >> --- a/mingw-w64-headers/crt/process.h >> +++ b/mingw-w64-headers/crt/process.h >> @@ -11,6 +11,8 @@ >> /* Includes a definition of _pid_t and pid_t */ >> #include <sys/types.h> >> >> +#include <winapifamily.h> >> + >> #ifndef _POSIX_ >> #ifdef __cplusplus >> extern "C" { >> @@ -28,10 +30,14 @@ extern "C" { >> #define _WAIT_GRANDCHILD 1 >> #endif >> >> +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) >> _CRTIMP uintptr_t __cdecl _beginthread(void (__cdecl *_StartAddress) >> (void *),unsigned _StackSize,void *_ArgList); >> _CRTIMP void __cdecl _endthread(void) __MINGW_ATTRIB_NORETURN; >> +#endif >> +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || >> defined(WINSTORECOMPAT) >> _CRTIMP uintptr_t __cdecl _beginthreadex(void *_Security,unsigned >> _StackSize,unsigned (__stdcall *_StartAddress) (void *),void >> *_ArgList,unsigned _InitFlag,unsigned *_ThrdAddr); >> _CRTIMP void __cdecl _endthreadex(unsigned _Retval) >> __MINGW_ATTRIB_NORETURN; >> +#endif >> >> #ifndef _CRT_TERMINATE_DEFINED >> #define _CRT_TERMINATE_DEFINED >> diff --git a/mingw-w64-libraries/winstorecompat/Makefile.am >> b/mingw-w64-libraries/winstorecompat/Makefile.am >> index dee6f20..332cae5 100644 >> --- a/mingw-w64-libraries/winstorecompat/Makefile.am >> +++ b/mingw-w64-libraries/winstorecompat/Makefile.am >> @@ -6,6 +6,7 @@ lib_LIBRARIES = libwinstorecompat.a >> >> libwinstorecompat_a_SOURCES = \ >> src/_wassert.c \ >> + src/beginthread.c \ >> src/GetModuleHandle.c \ >> src/CreateEventW.c \ >> src/CreateMutexW.c \ >> diff --git a/mingw-w64-libraries/winstorecompat/src/beginthread.c >> b/mingw-w64-libraries/winstorecompat/src/beginthread.c >> new file mode 100644 >> index 0000000..0d24ea0 >> --- /dev/null >> +++ b/mingw-w64-libraries/winstorecompat/src/beginthread.c >> @@ -0,0 +1,54 @@ >> +/* >> + Copyright (c) 2016 mingw-w64 project >> + >> + Contributing authors: Hugo Beauzée-Luyssen >> + >> + Permission is hereby granted, free of charge, to any person obtaining a >> + copy of this software and associated documentation files (the >> "Software"), >> + to deal in the Software without restriction, including without >> limitation >> + the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + and/or sell copies of the Software, and to permit persons to whom the >> + Software is furnished to do so, subject to the following conditions: >> + >> + The above copyright notice and this permission notice shall be included >> in >> + all copies or substantial portions of the Software. >> + >> + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> THE >> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >> + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >> + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >> + DEALINGS IN THE SOFTWARE. >> +*/ >> + >> +#define _WIN32_WINNT 0x501 >> + >> +#define _beginthreadex ___beginthreadex >> +#define _endthreadex ___endthreadex >> +#include <windef.h> >> +#include <winbase.h> >> +#include <processthreadsapi.h> >> +#undef _endthreadex >> +#undef _beginthreadex >> + >> +uintptr_t WINAPI _beginthreadex(void *_Security, unsigned _StackSize, >> + unsigned (__stdcall >> *_StartAddress) (void *), >> + void *_ArgList,unsigned >> _InitFlag,unsigned *_ThrdAddr) >> +{ >> + return (uintptr_t)CreateThread(_Security, _StackSize, >> (LPTHREAD_START_ROUTINE)_StartAddress, >> + _ArgList, _InitFlag, (LPDWORD)_ThrdAddr); >> +} >> + >> +void WINAPI _endthreadex(unsigned _Retval) >> +{ >> + ExitThread(_Retval); >> +} >> + >> +#ifndef _WIN64 >> +uintptr_t (WINAPI *__MINGW_IMP_SYMBOL(_beginthreadex))(void*, unsigned, >> unsigned (__stdcall *)(void *), void *,unsigned, unsigned*) >> asm("__imp___beginthreadex") = _beginthreadex; >> +void (WINAPI *__MINGW_IMP_SYMBOL(_endthreadex))(unsigned) >> asm("__imp___endthreadex") = _endthreadex; >> +#else >> +void (WINAPI *__MINGW_IMP_SYMBOL(_beginthreadex))(void*, unsigned, unsigned >> (__stdcall *)(void *), void *,unsigned, unsigned*) >> asm("__imp__beginthreadex") = _beginthreadex; >> +void (WINAPI *__MINGW_IMP_SYMBOL(_endthreadex))(unsigned) >> asm("__imp__endthreadex") = _endthreadex; >> +#endif >> -- >> 2.8.0.rc3 >> >> >> ------------------------------------------------------------------------------ >> Find and fix application performance issues faster with Applications Manager >> Applications Manager provides deep performance insights into multiple tiers >> of >> your business applications. It resolves application problems quickly and >> reduces your MTTR. Get your free trial! >> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z >> _______________________________________________ >> Mingw-w64-public mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > > ------------------------------------------------------------------------------ > Find and fix application performance issues faster with Applications Manager > Applications Manager provides deep performance insights into multiple tiers of > your business applications. It resolves application problems quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z > _______________________________________________ > Mingw-w64-public mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public >
It's not necessary per-se, however it felt wrong to expose a declaration since it won't link (depending on the runtime), and the function is definitely forbidden within WINAPI_PARTITION_APP I can send a new patch that aims only at winstorecompat if that works better for you! Regards, ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
