diff --git a/include/bx/config.h b/include/bx/config.h index f4650d4..fbf6e43 100644 --- a/include/bx/config.h +++ b/include/bx/config.h @@ -30,6 +30,7 @@ || BX_PLATFORM_QNX \ || BX_PLATFORM_RPI \ || BX_PLATFORM_WINDOWS \ + || BX_PLATFORM_WINRT \ ? 1 : 0) #endif // BX_CONFIG_CRT_FILE_READER_WRITER @@ -38,7 +39,7 @@ #endif // BX_CONFIG_SEMAPHORE_PTHREAD #ifndef BX_CONFIG_SUPPORTS_THREADING -# define BX_CONFIG_SUPPORTS_THREADING !(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_WINRT) +# define BX_CONFIG_SUPPORTS_THREADING !(BX_PLATFORM_EMSCRIPTEN) #endif // BX_CONFIG_SUPPORTS_THREADING #endif // BX_CONFIG_H_HEADER_GUARD diff --git a/include/bx/os.h b/include/bx/os.h index 5db19a2..c7f6ad8 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -10,6 +10,7 @@ #if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT # include +# include "debug.h" #elif BX_PLATFORM_ANDROID \ || BX_PLATFORM_EMSCRIPTEN \ || BX_PLATFORM_FREEBSD \ diff --git a/include/bx/platform.h b/include/bx/platform.h index cf5f7e6..88e4575 100644 --- a/include/bx/platform.h +++ b/include/bx/platform.h @@ -107,6 +107,7 @@ # define BX_PLATFORM_XBOX360 1 #elif defined(_WIN32) || defined(_WIN64) // http://msdn.microsoft.com/en-us/library/6sehtctf.aspx +# include # if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) # undef BX_PLATFORM_WINDOWS # if !defined(WINVER) && !defined(_WIN32_WINNT) diff --git a/include/bx/sem.h b/include/bx/sem.h index dcfe654..7822257 100644 --- a/include/bx/sem.h +++ b/include/bx/sem.h @@ -202,7 +202,11 @@ namespace bx public: Semaphore() { +#if BX_PLATFORM_WINRT + m_handle = CreateSemaphoreEx(NULL, 0, LONG_MAX, NULL, 0, SEMAPHORE_ALL_ACCESS); +#else m_handle = CreateSemaphore(NULL, 0, LONG_MAX, NULL); +#endif BX_CHECK(NULL != m_handle, "Failed to create Semaphore!"); } @@ -219,7 +223,11 @@ namespace bx bool wait(int32_t _msecs = -1) const { DWORD milliseconds = (0 > _msecs) ? INFINITE : _msecs; - return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds); +#if BX_PLATFORM_WINRT + return WAIT_OBJECT_0 == WaitForSingleObjectEx(m_handle, milliseconds, FALSE); +#else + return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds); +#endif } private: diff --git a/include/bx/thread.h b/include/bx/thread.h index 79afb46..42cadc9 100644 --- a/include/bx/thread.h +++ b/include/bx/thread.h @@ -8,7 +8,11 @@ #if BX_PLATFORM_POSIX # include -#endif // BX_PLATFORM_POSIX +#elif BX_PLATFORM_WINRT +using namespace Platform; +using namespace Windows::Foundation; +using namespace Windows::System::Threading; +#endif #include "sem.h" @@ -27,7 +31,7 @@ namespace bx public: Thread() -#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360 +#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT : m_handle(INVALID_HANDLE_VALUE) #elif BX_PLATFORM_POSIX : m_handle(0) @@ -65,6 +69,15 @@ namespace bx , 0 , NULL ); +#elif BX_PLATFORM_WINRT + m_handle = CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); + auto workItemHandler = ref new WorkItemHandler([=](IAsyncAction^) + { + m_exitCode = threadFunc(this); + SetEvent(m_handle); + }, CallbackContext::Any); + + ThreadPool::RunAsync(workItemHandler, WorkItemPriority::Normal, WorkItemOptions::TimeSliced); #elif BX_PLATFORM_POSIX int result; BX_UNUSED(result); @@ -99,6 +112,10 @@ namespace bx GetExitCodeThread(m_handle, (DWORD*)&m_exitCode); CloseHandle(m_handle); m_handle = INVALID_HANDLE_VALUE; +#elif BX_PLATFORM_WINRT + WaitForSingleObjectEx(m_handle, INFINITE, FALSE); + CloseHandle(m_handle); + m_handle = INVALID_HANDLE_VALUE; #elif BX_PLATFORM_POSIX union { @@ -129,7 +146,7 @@ namespace bx return m_fn(m_userData); } -#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360 +#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT static DWORD WINAPI threadFunc(LPVOID _arg) { Thread* thread = (Thread*)_arg; @@ -150,7 +167,7 @@ namespace bx } #endif // BX_PLATFORM_ -#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360 +#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT HANDLE m_handle; #elif BX_PLATFORM_POSIX pthread_t m_handle; @@ -194,7 +211,7 @@ namespace bx uint32_t m_id; }; -#else +#elif !(BX_PLATFORM_WINRT) class TlsData { diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index 045f412..ce6c0b6 100755 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -41,6 +41,7 @@ function toolchain(_buildDir, _libDir) { "vs2012-clang", "Clang 3.6" }, { "vs2013-clang", "Clang 3.6" }, { "winphone8", "Windows Phone 8.0" }, + { "winphone81", "Windows Phone 8.1" } }, } @@ -272,6 +273,12 @@ function toolchain(_buildDir, _libDir) premake.vstudio.toolset = "v110_wp80" location (_buildDir .. "projects/" .. _ACTION .. "-winphone8") end + + if "winphone81" == _OPTIONS["vs"] then + premake.vstudio.toolset = "v120_wp81" + platforms { "ARM" } + location (_buildDir .. "projects/" .. _ACTION .. "-winphone81") + end end flags { @@ -345,6 +352,10 @@ function toolchain(_buildDir, _libDir) "$(DXSDK_DIR)/lib/x64", } + configuration { "ARM", "vs*" } + targetdir (_buildDir .. "arm_" .. _ACTION .. "/bin") + objdir (_buildDir .. "arm_" .. _ACTION .. "/obj") + configuration { "vs*-clang" } buildoptions { "-Qunused-arguments", @@ -358,6 +369,9 @@ function toolchain(_buildDir, _libDir) targetdir (_buildDir .. "win64_" .. _ACTION .. "-clang/bin") objdir (_buildDir .. "win64_" .. _ACTION .. "-clang/obj") + configuration { "winphone8*" } + removeflags { "StaticRuntime", "NoExceptions" } + configuration { "mingw-*" } defines { "WIN32" } includedirs { bxDir .. "include/compat/mingw" } diff --git a/tools/bin/windows/genie.exe b/tools/bin/windows/genie.exe index 893d9c8..c8e8690 100644 Binary files a/tools/bin/windows/genie.exe and b/tools/bin/windows/genie.exe differ