diff --git a/.gitignore b/.gitignore index 5b9ec0e..bac4d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,5 @@ libs/juce-* # A place for BP to store stuff ignore/* __pycache__ + +arm*bld diff --git a/src/cpufeatures.cpp b/src/cpufeatures.cpp index 6c05111..f21fd20 100644 --- a/src/cpufeatures.cpp +++ b/src/cpufeatures.cpp @@ -15,9 +15,13 @@ #if defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || \ (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(__i386__) || defined(__x86_64__) +#if defined(_M_ARM64EC) +#include +#else #define USING_X86 1 #include #endif +#endif #if MAC #include @@ -28,13 +32,14 @@ #include #endif +#if WINDOWS +#include +#endif + #ifdef _WIN32 #include #define cpuid(info, x) __cpuidex(info, x, 0) -#if !USING_X86 -#error "Windows only works on X86 right now" -#endif #else #if LINUX && USING_X86 #ifdef __GNUC__ @@ -80,6 +85,24 @@ std::string brand() } #elif WINDOWS +#if defined(_M_ARM64) || defined(_M_ARM64EC) + arch = "unknown windows arm"; + const char *csName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; + HKEY hKey; + DWORD gotType, gotSize = 64; + char inBuffer[64]; + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, csName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + if (!RegQueryValueExA(hKey, "ProcessorNameString", nullptr, &gotType, (PBYTE)inBuffer, + &gotSize)) + { + if (gotType == REG_SZ && strlen(inBuffer)) + { + arch = inBuffer; + } + } + } +#else std::string platform = "Windows"; int CPUInfo[4] = {-1}; @@ -100,6 +123,7 @@ std::string brand() memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo)); } arch = CPUBrandString; +#endif #elif LINUX std::string platform = "Linux"; @@ -132,7 +156,7 @@ std::string brand() bool isArm() { -#if defined(__arm__) || defined(__aarch64__) +#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) return true; #else return false; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 631e73c..92bd1a7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,6 +19,11 @@ add_executable(dumppaths) target_sources(dumppaths PRIVATE dumppaths.cpp) target_link_libraries(dumppaths sst-plugininfra) + +add_executable(cpufeatures) +target_sources(cpufeatures PRIVATE cpufeatures.cpp) +target_link_libraries(cpufeatures sst-plugininfra) + add_custom_target(sst-all-tests ALL) add_dependencies(sst-all-tests dumppaths) add_dependencies(sst-all-tests sst-tixml-tests) @@ -32,6 +37,7 @@ add_custom_command(TARGET sst-all-tests COMMAND ${CMAKE_COMMAND} -E copy "$" test-binary COMMAND ${CMAKE_COMMAND} -E copy "$" test-binary COMMAND ${CMAKE_COMMAND} -E copy "$" test-binary + COMMAND ${CMAKE_COMMAND} -E copy "$" test-binary COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/libs/tinyxml/test/utf8test.xml test-binary COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/libs/tinyxml/test/utf8testverify.xml test-binary ) diff --git a/tests/cpufeatures.cpp b/tests/cpufeatures.cpp new file mode 100644 index 0000000..09124e3 --- /dev/null +++ b/tests/cpufeatures.cpp @@ -0,0 +1,25 @@ +/* + * sst-plugininfra - an open source library of plugin infrastructure + * built by Surge Synth Team. + * + * Copyright 2018-2024, various authors, as described in the GitHub + * transaction log. + * + * sst-effects is released under the MIT License. It has subordinate + * libraries with licenses as described in libs/ + * + * All source in sst-plugininfra available at + * https://github.com/surge-synthesizer/sst-plugininfra + */ + +#include "sst/plugininfra/cpufeatures.h" +#include + +int main(int argc, char **argv) +{ + using namespace sst::plugininfra::cpufeatures; + std::cout << "CPU Features Platform\n"; + std::cout << "brand : " << brand() << "\n"; + std::cout << "isArm : " << isArm() << "\n"; + std::cout << "isX86 : " << isX86() << "\n"; +} \ No newline at end of file