Add UWP compiler flags

This commit is contained in:
Lasse Lauwerys 2026-02-07 12:12:14 +01:00
parent 8872ad2125
commit c5ad5738fd
2 changed files with 8 additions and 1 deletions

View File

@ -41,6 +41,7 @@
# define NOMINMAX
#endif
#include <locale>
#include <winapifamily.h>
#include <windows.h>
#include <string.h>
#include <fcntl.h>
@ -101,7 +102,7 @@ int32_t cpu_get_num_physical_cores() {
if (result == 0) {
return num_physical_cores;
}
#elif defined(_WIN32) && (_WIN32_WINNT >= 0x0601) && !defined(__MINGW64__) // windows 7 and later
#elif defined(_WIN32) && (_WIN32_WINNT >= 0x0601) && !defined(__MINGW64__) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(LLAMA_UWP) // windows 7 and later
// TODO: windows + arm64 + mingw64
unsigned int n_threads_win = std::thread::hardware_concurrency();
unsigned int default_threads = n_threads_win > 0 ? (n_threads_win <= 4 ? n_threads_win : n_threads_win / 2) : 4;

View File

@ -29,6 +29,7 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <winapifamily.h>
#include <windows.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
@ -660,6 +661,7 @@ struct llama_mlock::impl {
return false;
}
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(LLAMA_UWP)
SIZE_T min_ws_size, max_ws_size;
if (!GetProcessWorkingSetSize(GetCurrentProcess(), &min_ws_size, &max_ws_size)) {
LLAMA_LOG_WARN("warning: GetProcessWorkingSetSize failed: %s\n",
@ -674,6 +676,10 @@ struct llama_mlock::impl {
llama_format_win_err(GetLastError()).c_str());
return false;
}
#else
LLAMA_LOG_WARN("warning: MMAP is not supported for UWP\n");
return false;
#endif
}
}