diff --git a/include/ceccloader.h b/include/ceccloader.h index 2f8f76018..6dd631fb9 100644 --- a/include/ceccloader.h +++ b/include/ceccloader.h @@ -34,7 +34,7 @@ #include "cecc.h" #include -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) #include #include typedef HINSTANCE libcecc_lib_instance_t; @@ -217,7 +217,7 @@ static int libcecc_resolve_all(void* lib, libcec_interface_t* iface) static libcecc_lib_instance_t libcecc_load_library(const char* strLib) { libcecc_lib_instance_t lib; -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) lib = LoadLibrary(strLib ? strLib : "cec.dll"); if (lib == NULL) printf("failed to load cec.dll\n"); @@ -235,7 +235,7 @@ static libcecc_lib_instance_t libcecc_load_library(const char* strLib) static void libcecc_close_library(libcecc_lib_instance_t lib) { -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) FreeLibrary(lib); #else dlclose(lib); @@ -244,7 +244,7 @@ static void libcecc_close_library(libcecc_lib_instance_t lib) static void* libcecc_resolve(void* lib, const char* name) { -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) return GetProcAddress(lib, name); #else return dlsym(lib, name); diff --git a/include/cecloader.h b/include/cecloader.h index be76468f4..c97a9e86a 100644 --- a/include/cecloader.h +++ b/include/cecloader.h @@ -31,7 +31,7 @@ * http://www.pulse-eight.net/ */ -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) #include #include diff --git a/include/cectypes.h b/include/cectypes.h index e585f2fec..709f26242 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -38,14 +38,14 @@ #include #include -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) #define CEC_CDECL __cdecl #else #define CEC_CDECL #endif #if !defined(DECLSPEC) -#if defined(_WIN32) || defined(_WIN64) +#if defined(_WIN32) || defined(_WIN64) || defined(_M_ARM64) #include #if defined DLL_EXPORT #define DECLSPEC __declspec(dllexport) diff --git a/src/cec-client/CMakeLists.txt b/src/cec-client/CMakeLists.txt index 5418ef7bc..35b19d990 100644 --- a/src/cec-client/CMakeLists.txt +++ b/src/cec-client/CMakeLists.txt @@ -65,7 +65,7 @@ if (NOT WIN32) endif() else() add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_) - if (${WIN64}) + if ((${WIN64}) OR (${_M_ARM64})) string(REPLACE "/arch:SSE2" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) else() add_definitions(-D_USE_32BIT_TIME_T) diff --git a/src/cecc-client/CMakeLists.txt b/src/cecc-client/CMakeLists.txt index 80f164bc1..ce4c50ef0 100644 --- a/src/cecc-client/CMakeLists.txt +++ b/src/cecc-client/CMakeLists.txt @@ -35,7 +35,7 @@ if (NOT WIN32) endif() else() add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_) - if (${WIN64}) + if ((${WIN64}) OR (${_M_ARM64})) string(REPLACE "/arch:SSE2" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) else() add_definitions(-D_USE_32BIT_TIME_T) diff --git a/src/libcec/CMakeLists.txt b/src/libcec/CMakeLists.txt index 19a070b7a..301d40e0f 100644 --- a/src/libcec/CMakeLists.txt +++ b/src/libcec/CMakeLists.txt @@ -160,7 +160,7 @@ if (WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcec.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/libcec.rc) add_definitions(-DDLL_EXPORT) add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_) - if (${WIN64}) + if ((${WIN64}) OR (${_M_ARM64})) string(REPLACE "/arch:SSE2" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) else() add_definitions(-D_USE_32BIT_TIME_T) diff --git a/src/libcec/LibCEC.cpp b/src/libcec/LibCEC.cpp index a814f3897..cc509e7ad 100644 --- a/src/libcec/LibCEC.cpp +++ b/src/libcec/LibCEC.cpp @@ -524,8 +524,10 @@ const char *CLibCEC::GetLibInfo(void) #ifndef LIB_INFO #ifdef _WIN32 #define FEATURES "'P8 USB' 'P8 USB detect'" -#ifdef _WIN64 +#if defined(_WIN64) #define HOST_TYPE "Windows (x64)" +#elseif defined(_M_ARM64) +#define HOST_TYPE "Windows (ARM64)" #else #define HOST_TYPE "Windows (x86)" #endif diff --git a/src/libcec/cmake/CheckPlatformSupport.cmake b/src/libcec/cmake/CheckPlatformSupport.cmake index a7f655962..f158035f8 100644 --- a/src/libcec/cmake/CheckPlatformSupport.cmake +++ b/src/libcec/cmake/CheckPlatformSupport.cmake @@ -60,6 +60,8 @@ if(WIN32) endif() elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM") set(LIB_INFO "${LIB_INFO} (arm)") + elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM64") + set(LIB_INFO "${LIB_INFO} (arm64)") else() message(FATAL_ERROR "Unknown architecture id: ${MSVC_C_ARCHITECTURE_ID}") endif() diff --git a/src/libcec/platform/adl/adl_structures.h b/src/libcec/platform/adl/adl_structures.h index 0bd6f8465..93e82491e 100644 --- a/src/libcec/platform/adl/adl_structures.h +++ b/src/libcec/platform/adl/adl_structures.h @@ -50,7 +50,7 @@ typedef struct AdapterInfo int iPresent; // @} -#if defined (_WIN32) || defined (_WIN64) +#if defined (_WIN32) || defined (_WIN64) || defined(_M_ARM64) /// \WIN_STRUCT_MEM /// Exist or not; 1 is exist and 0 is not present. @@ -64,7 +64,7 @@ typedef struct AdapterInfo /// It is generated from EnumDisplayDevices. int iOSDisplayIndex; // @} -#endif /* (_WIN32) || (_WIN64) */ +#endif /* (_WIN32) || (_WIN64) || (_M_ARM64) */ #if defined (LINUX) /// \LNX_STRUCT_MEM diff --git a/src/libcec/platform/windows/stdint.h b/src/libcec/platform/windows/stdint.h index 39b8aed9d..455831505 100644 --- a/src/libcec/platform/windows/stdint.h +++ b/src/libcec/platform/windows/stdint.h @@ -116,13 +116,13 @@ typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ +#if defined(_WIN64) || defined(_M_ARM64) // [ typedef signed __int64 intptr_t; typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ +#else // _WIN64 || _M_ARM64 ][ typedef _W64 signed int intptr_t; typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] +#endif // _WIN64 || _M_ARM64 ] // 7.18.1.5 Greatest-width integer types typedef int64_t intmax_t; @@ -176,15 +176,15 @@ typedef uint64_t uintmax_t; #define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ +#if defined(_WIN64) || defined(_M_ARM64) // [ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ +#else // _WIN64 || _M_ARM64 ][ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] +#endif // _WIN64 || _M_ARM64 ] // 7.18.2.5 Limits of greatest-width integer types #define INTMAX_MIN INT64_MIN @@ -193,23 +193,23 @@ typedef uint64_t uintmax_t; // 7.18.3 Limits of other integer types -#ifdef _WIN64 // [ +#if defined(_WIN64) || defined(_M_ARM64) // [ # define PTRDIFF_MIN _I64_MIN # define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ +#else // _WIN64 || _M_ARM64 ][ # define PTRDIFF_MIN _I32_MIN # define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] +#endif // _WIN64 || _M_ARM64 ] #define SIG_ATOMIC_MIN INT_MIN #define SIG_ATOMIC_MAX INT_MAX #ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ +# if defined(_WIN64) || defined(_M_ARM64) // [ # define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ +# else // _WIN64 || _M_ARM64 ][ # define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] +# endif // _WIN64 || _M_ARM64 ] #endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in diff --git a/src/platform b/src/platform index 1133cccd4..b6f38fcef 160000 --- a/src/platform +++ b/src/platform @@ -1 +1 @@ -Subproject commit 1133cccd412fd5dba541bf735f3facc5b72321c3 +Subproject commit b6f38fcef13c981b8c815c43d237a40c00594e10 diff --git a/support b/support index 416da1d0e..1681ddc3e 160000 --- a/support +++ b/support @@ -1 +1 @@ -Subproject commit 416da1d0e60ee2397f31d4eb8f85886a9ef3327a +Subproject commit 1681ddc3ec01ef1363e551a7e9cbf500261faf4a diff --git a/windows/build-all.cmd b/windows/build-all.cmd index e1a86c707..71b6db37e 100644 --- a/windows/build-all.cmd +++ b/windows/build-all.cmd @@ -12,6 +12,9 @@ SET RUNTIMEARCH=amd64 IF "%PROCESSOR_ARCHITECTURE%"=="x86" IF "%PROCESSOR_ARCHITEW6432%"=="" ( SET RUNTIMEARCH=x86 ) +IF "%PROCESSOR_ARCHITECTURE%"=="arm64" ( + SET RUNTIMEARCH=arm64 +) IF "%1" == "" ( SET BUILDARCH=%RUNTIMEARCH% ) ELSE ( @@ -44,6 +47,11 @@ IF "%4" == "" ( SET DOTNETAPPS=0 ) +rem Building .NET applications is not supported on ARM64 +if "%BUILDARCH%" == "arm64" ( + SET DOTNETAPPS=0 +) + SET BUILDPATH=%MYDIR%..\build SET EXITCODE=1 @@ -62,7 +70,7 @@ IF %errorlevel% neq 0 ( EXIT /b 1 ) -rem Set up the toolchain +rem Set up the toolchain CALL "%MYDIR%..\support\windows\config\toolchain.cmd" >nul IF "%TOOLCHAIN_NAME%" == "" ( ECHO.*** Visual Studio toolchain could not be configured for %BUILDARCH% *** @@ -70,35 +78,38 @@ IF "%TOOLCHAIN_NAME%" == "" ( ECHO.See docs\README.windows.md EXIT /b 2 ) + +rem Building LibCecSharp isn't supported on ARM64 +if not "%BUILDARCH%" == "arm64" ( + rem Compile LibCecSharp and LibCecSharpCore + ECHO. * cleaning LibCecSharp and LibCecSharpCore for %BUILDARCH% + "%DevEnvDir%devenv.com" libcec.sln /Clean "%BUILDTYPE%|%BUILDARCHPROJECT%" + ECHO. * compiling LibCecSharp and LibCecSharpCore for %BUILDARCH% + "%DevEnvDir%devenv.com" libcec.sln /Build "%BUILDTYPE%|%BUILDARCHPROJECT%" + + rem Create dir for referenced libs and check compilation results + RMDIR /s /q "%MYDIR%..\build\ref" >nul 2>&1 + MKDIR "%MYDIR%..\build\ref" >nul + MKDIR "%MYDIR%..\build\ref\netcore" >nul + + rem Check and copy LibCecSharp + IF EXIST "%MYDIR%..\build\%BUILDARCH%\LibCecSharp.dll" ( + COPY "%MYDIR%..\build\%BUILDARCH%\LibCecSharp.*" "%MYDIR%..\build\ref" >nul + ) ELSE ( + ECHO. *** failed to build LibCecSharp for %BUILDARCH% *** + PAUSE + EXIT /b 1 + ) -rem Compile LibCecSharp and LibCecSharpCore -ECHO. * cleaning LibCecSharp and LibCecSharpCore for %BUILDARCH% -"%DevEnvDir%devenv.com" libcec.sln /Clean "%BUILDTYPE%|%BUILDARCHPROJECT%" -ECHO. * compiling LibCecSharp and LibCecSharpCore for %BUILDARCH% -"%DevEnvDir%devenv.com" libcec.sln /Build "%BUILDTYPE%|%BUILDARCHPROJECT%" - -rem Create dir for referenced libs and check compilation results -RMDIR /s /q "%MYDIR%..\build\ref" >nul 2>&1 -MKDIR "%MYDIR%..\build\ref" >nul -MKDIR "%MYDIR%..\build\ref\netcore" >nul - -rem Check and copy LibCecSharp -IF EXIST "%MYDIR%..\build\%BUILDARCH%\LibCecSharp.dll" ( - COPY "%MYDIR%..\build\%BUILDARCH%\LibCecSharp.*" "%MYDIR%..\build\ref" >nul -) ELSE ( - ECHO. *** failed to build LibCecSharp for %BUILDARCH% *** - PAUSE - EXIT /b 1 -) - -rem Check and copy LibCecSharpCore -IF EXIST "%MYDIR%..\build\%BUILDARCH%\netcore\LibCecSharpCore.dll" ( - COPY "%MYDIR%..\build\%BUILDARCH%\netcore\LibCecSharpCore.*" "%MYDIR%..\build\ref\netcore\." >nul -) ELSE ( - ECHO. *** failed to build LibCecSharpCore for %BUILDARCH% *** - PAUSE - EXIT /b 1 -) + rem Check and copy LibCecSharpCore + IF EXIST "%MYDIR%..\build\%BUILDARCH%\netcore\LibCecSharpCore.dll" ( + COPY "%MYDIR%..\build\%BUILDARCH%\netcore\LibCecSharpCore.*" "%MYDIR%..\build\ref\netcore\." >nul + ) ELSE ( + ECHO. *** failed to build LibCecSharpCore for %BUILDARCH% *** + PAUSE + EXIT /b 1 + ) +) IF %DOTNETAPPS% == 1 ( rem Compile cec-tray and CecSharpTester apps diff --git a/windows/build-lib.cmd b/windows/build-lib.cmd index 4dc66e296..7ba68d401 100644 --- a/windows/build-lib.cmd +++ b/windows/build-lib.cmd @@ -65,7 +65,7 @@ EXIT /b 0 ECHO.%~dp0 requires 5 parameters ECHO. %~dp0 [architecture] [type] [vs version] [install path] [project type] ECHO. -ECHO. architecture: amd64 x86 +ECHO. architecture: amd64 x86 arm64 ECHO. build type: Release Debug ECHO. vs version: Visual Studio version (2019) ECHO. install path: installation path without quotes diff --git a/windows/visual-studio.cmd b/windows/visual-studio.cmd index a69265d48..4061da5a1 100644 --- a/windows/visual-studio.cmd +++ b/windows/visual-studio.cmd @@ -20,7 +20,7 @@ rem delete old build folder RMDIR /s /q "%MYDIR%..\build" >nul 2>&1 rem build/generate vs project files -FOR %%T IN (amd64 x86) DO ( +FOR %%T IN (amd64 x86 arm64) DO ( CALL "%MYDIR%build-lib.cmd" %%T %BUILDTYPE% %VSVERSION% "%INSTALLPATH%" vs IF %errorlevel% neq 0 EXIT /b %errorlevel% ) @@ -28,5 +28,6 @@ FOR %%T IN (amd64 x86) DO ( ECHO Visual Studio solutions can be found in: ECHO 32 bits: "%MYDIR%..\build\cmake\x86\libcec.sln" ECHO 64 bits: "%MYDIR%..\build\cmake\amd64\libcec.sln" +ECHO arm64: "%MYDIR%..\build\cmake\arm64\libcec.sln" ECHO. ECHO These projects only compile in %BUILDTYPE% mode and have been generated for Visual Studio %VSVERSION%.