Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pytorch/cpuinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml25
-rw-r--r--CMakeLists.txt16
-rw-r--r--CMakePresets.json63
-rw-r--r--src/x86/name.c4
4 files changed, 100 insertions, 8 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 794e283..fb31c1a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -43,6 +43,31 @@ jobs:
run: scripts/local-build.sh
shell: bash # Specify bash so we can reuse the build script on Windows (runs on Git bash)
working-directory: ${{ github.workspace }}
+ cmake-uwp:
+ runs-on: windows-latest
+ timeout-minutes: 40
+ steps:
+ - uses: actions/checkout@v2
+ - name: 'x64-uwp(Debug)'
+ uses: lukka/run-cmake@v10
+ with:
+ configurePreset: 'x64-uwp'
+ buildPreset: 'x64-uwp-dbg'
+ - name: 'x64-uwp(Release)'
+ uses: lukka/run-cmake@v10
+ with:
+ configurePreset: 'x64-uwp'
+ buildPreset: 'x64-uwp-rel'
+ - name: 'arm64-uwp(Debug)'
+ uses: lukka/run-cmake@v10
+ with:
+ configurePreset: 'arm64-uwp'
+ buildPreset: 'arm64-uwp-dbg'
+ - name: 'arm64-uwp(Release)'
+ uses: lukka/run-cmake@v10
+ with:
+ configurePreset: 'arm64-uwp'
+ buildPreset: 'arm64-uwp-rel'
cmake-android:
strategy:
matrix:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d7e1786..1df2814 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,7 @@ IF(NOT CMAKE_SYSTEM_NAME)
"Target operating system is not specified. "
"cpuinfo will compile, but cpuinfo_initialize() will always fail.")
SET(CPUINFO_SUPPORTED_PLATFORM FALSE)
-ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS|Darwin|Linux|Android)$")
+ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Windows|WindowsStore|CYGWIN|MSYS|Darwin|Linux|Android)$")
IF(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14" AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
MESSAGE(WARNING
"Target operating system \"${CMAKE_SYSTEM_NAME}\" is not supported in cpuinfo. "
@@ -141,7 +141,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM)
src/x86/linux/cpuinfo.c)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
LIST(APPEND CPUINFO_SRCS src/x86/mach/init.c)
- ELSEIF(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$")
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "^(Windows|WindowsStore|CYGWIN|MSYS)$")
LIST(APPEND CPUINFO_SRCS src/x86/windows/init.c)
ENDIF()
ELSEIF(CPUINFO_TARGET_PROCESSOR MATCHES "^(armv[5-8].*|aarch64|arm64)$" OR IOS_ARCH MATCHES "^(armv7.*|arm64.*)$")
@@ -171,7 +171,7 @@ IF(CPUINFO_SUPPORTED_PLATFORM)
LIST(APPEND CPUINFO_SRCS
src/arm/android/properties.c)
ENDIF()
- ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CPUINFO_TARGET_PROCESSOR STREQUAL "ARM64")
+ ELSEIF((CMAKE_SYSTEM_NAME MATCHES "^Windows") AND CPUINFO_TARGET_PROCESSOR STREQUAL "ARM64")
LIST(APPEND CPUINFO_SRCS src/arm/windows/init-by-logical-sys-info.c)
LIST(APPEND CPUINFO_SRCS src/arm/windows/init.c)
ENDIF()
@@ -211,10 +211,14 @@ ADD_LIBRARY(cpuinfo_internals STATIC ${CPUINFO_SRCS})
CPUINFO_TARGET_ENABLE_C99(cpuinfo)
CPUINFO_TARGET_ENABLE_C99(cpuinfo_internals)
CPUINFO_TARGET_RUNTIME_LIBRARY(cpuinfo)
-IF(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$")
+IF(CMAKE_SYSTEM_NAME MATCHES "^(Windows|WindowsStore|CYGWIN|MSYS)$")
# Target Windows 7+ API
- TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE _WIN32_WINNT=0x0601)
- TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE _WIN32_WINNT=0x0601)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE _WIN32_WINNT=0x0601 _CRT_SECURE_NO_WARNINGS)
+ TARGET_COMPILE_DEFINITIONS(cpuinfo_internals PRIVATE _WIN32_WINNT=0x0601 _CRT_SECURE_NO_WARNINGS)
+ # Explicitly link Kernel32 for UWP build
+ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+ TARGET_LINK_LIBRARIES(cpuinfo PUBLIC Kernel32)
+ endif()
ENDIF()
SET_TARGET_PROPERTIES(cpuinfo PROPERTIES PUBLIC_HEADER include/cpuinfo.h)
TARGET_INCLUDE_DIRECTORIES(cpuinfo BEFORE PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 0000000..f80008f
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,63 @@
+{
+ "version": 3,
+ "cmakeMinimumRequired": {
+ "major": 3,
+ "minor": 21,
+ "patch": 0
+ },
+ "configurePresets": [
+ {
+ "name": "x64-uwp",
+ "displayName": "x64(uwp)",
+ "generator": "Visual Studio 17 2022",
+ "architecture": "x64",
+ "binaryDir": "${sourceDir}/build/x64-uwp",
+ "installDir": "${sourceDir}/install",
+ "cacheVariables": {
+ "CPUINFO_BUILD_UNIT_TESTS": false,
+ "CPUINFO_BUILD_MOCK_TESTS": false,
+ "CPUINFO_BUILD_BENCHMARKS": false,
+ "CMAKE_SYSTEM_NAME": "WindowsStore",
+ "CMAKE_SYSTEM_VERSION": "10.0",
+ "CMAKE_SYSTEM_PROCESSOR": "x86_64"
+ },
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ }
+ },
+ {
+ "name": "arm64-uwp",
+ "displayName": "arm64(uwp)",
+ "inherits": "x64-uwp",
+ "architecture": "ARM64",
+ "binaryDir": "${sourceDir}/build/arm64-uwp",
+ "cacheVariables": {
+ "CMAKE_SYSTEM_PROCESSOR": "ARM64"
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "x64-uwp-dbg",
+ "configurePreset": "x64-uwp",
+ "configuration": "Debug"
+ },
+ {
+ "name": "x64-uwp-rel",
+ "configurePreset": "x64-uwp",
+ "configuration": "Release"
+ },
+ {
+ "name": "arm64-uwp-dbg",
+ "configurePreset": "arm64-uwp",
+ "configuration": "Debug"
+ },
+ {
+ "name": "arm64-uwp-rel",
+ "configurePreset": "arm64-uwp",
+ "configuration": "Release"
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/x86/name.c b/src/x86/name.c
index 957a0d8..38c47a3 100644
--- a/src/x86/name.c
+++ b/src/x86/name.c
@@ -581,7 +581,7 @@ uint32_t cpuinfo_x86_normalize_brand_string(
/* Iterate through all tokens and erase redundant parts */
{
bool is_token = false;
- char* token_start;
+ char* token_start = NULL;
for (char* char_ptr = name; char_ptr != name_end; char_ptr++) {
if (*char_ptr == ' ') {
if (is_token) {
@@ -619,7 +619,7 @@ uint32_t cpuinfo_x86_normalize_brand_string(
/* Compact tokens: collapse multiple spacing into one */
{
char* output_ptr = normalized_name;
- char* token_start;
+ char* token_start = NULL;
bool is_token = false;
bool previous_token_ends_with_dash = true;
bool current_token_starts_with_dash = false;