From 14e43c8f42585a8fa07f3fcfea5d9e1255cda0d1 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 8 Jan 2016 14:03:04 +0100 Subject: [PATCH] winrt: Fix API usage certification According to MSDN Tls* is inline replaced by Fls* on Windows (Phone) 8.1 and beyond. However, this does not seem to be the case for Windows 10. An application links against Tls* and the certification step fails due to using non-allowed APIs. Hence we do the inline replacement manually. QThreadStorage and QThread tests continue to work, so it seems to be an oversight by Microsoft. Task-number: QTBUG-50292 Change-Id: Ice1b6e54fcee238c94af5c6fb1753d903db7476d Reviewed-by: Oliver Wolff --- src/corelib/thread/qthread_win.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 1a4b41fee4..32e8a52a28 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -69,6 +69,30 @@ #ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE +#ifdef Q_OS_WINRT +inline DWORD qWinRTTlsAlloc() { + return FlsAlloc(0); +} + +inline bool qWinRTTlsFree(DWORD dwTlsIndex) { + return FlsFree(dwTlsIndex); +} + +inline LPVOID qWinRTTlsGetValue(DWORD dwTlsIndex) { + return FlsGetValue(dwTlsIndex); +} + +inline bool qWinRTTlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { + return FlsSetValue(dwTlsIndex, lpTlsValue); +} + +#define TlsAlloc qWinRTTlsAlloc +#define TlsFree qWinRTTlsFree +#define TlsSetValue qWinRTTlsSetValue +#define TlsGetValue qWinRTTlsGetValue + +#endif // Q_OS_WINRT + void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread); DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID);