From: Gregory Morse Date: Mon, 16 Oct 2017 09:12:35 +0000 (+0200) Subject: Merge pull request #9856 from GregoryMorse:patch-1 X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~501 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d30a0c6f03269b57c4ca4225f4c031492a0cb8d6;p=platform%2Fupstream%2Fopencv.git Merge pull request #9856 from GregoryMorse:patch-1 * Update OpenCVCompilerOptimizations.cmake Neon not supported on MSVC ARM breaking build fix * Update OpenCVCompilerOptimizations.cmake Whitespace * Update intrin.hpp Many problems in MSVC ARM builds (at least on VS2017) being fixed in this PR now. C:\Users\Gregory\DOCUME~1\MYLIBR~1\OPENCV~3\opencv\sources\modules\core\include\opencv2/core/hal/intrin.hpp(444): error C3861: '_tzcnt_u32': identifier not found * Update hal_replacement.hpp Passing variadic expansion in a macro to another macro does not work properly in MSVC and a famous known workaround is hereby applied. Discussion of it: https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly Only needed the fix for ARM builds: TEGRA_ macros are used for cv_hal_ functions in the carotene library. C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): warning C4003: not enough actual parameters for macro 'TEGRA_ADD' C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): error C2143: syntax error: missing ')' before ',' C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): error C2059: syntax error: ')' * Update hal_replacement.hpp All hal_replacement's using carotene\hal\tegra_hal.hpp TEGRA_ functions as macros preprocessed by variadic macros should be changed, identical as was done in core. C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\imgproc\src\color.cpp(9604): warning C4003: not enough actual parameters for macro 'TEGRA_CVTBGRTOBGR' C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\imgproc\src\color.cpp(9604): error C2059: syntax error: '==' * Update OpenCVCompilerOptimizations.cmake * Update hal_replacement.hpp * Update hal_replacement.hpp --- diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake index fea13ce..2696ac2 100644 --- a/cmake/OpenCVCompilerOptimizations.cmake +++ b/cmake/OpenCVCompilerOptimizations.cmake @@ -256,12 +256,14 @@ elseif(ARM OR AARCH64) ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp") if(NOT AARCH64) ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16") - ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3") - ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon") - ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*") - ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16") + if(NOT MSVC) + ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3") + ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon") + ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*") + ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16") + ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*") + endif() ocv_update(CPU_FP16_IMPLIES "NEON") - ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*") else() ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16") ocv_update(CPU_NEON_FLAGS_ON "") diff --git a/modules/core/include/opencv2/core/hal/intrin.hpp b/modules/core/include/opencv2/core/hal/intrin.hpp index 26fd918..9dcfc56 100644 --- a/modules/core/include/opencv2/core/hal/intrin.hpp +++ b/modules/core/include/opencv2/core/hal/intrin.hpp @@ -440,7 +440,7 @@ template <> struct V_RegTrait128 { inline unsigned int trailingZeros32(unsigned int value) { #if defined(_MSC_VER) -#if (_MSC_VER < 1700) +#if (_MSC_VER < 1700) || defined(_M_ARM) unsigned long index = 0; _BitScanForward(&index, value); return (unsigned int)index; diff --git a/modules/core/src/hal_replacement.hpp b/modules/core/src/hal_replacement.hpp index 9a1177e..c0477e6 100644 --- a/modules/core/src/hal_replacement.hpp +++ b/modules/core/src/hal_replacement.hpp @@ -727,7 +727,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s //! @cond IGNORED #define CALL_HAL_RET(name, fun, retval, ...) \ { \ - int res = fun(__VA_ARGS__, &retval); \ + int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \ if (res == CV_HAL_ERROR_OK) \ return retval; \ else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \ @@ -738,7 +738,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s #define CALL_HAL(name, fun, ...) \ { \ - int res = fun(__VA_ARGS__); \ + int res = __CV_EXPAND(fun(__VA_ARGS__)); \ if (res == CV_HAL_ERROR_OK) \ return; \ else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \ diff --git a/modules/imgproc/src/hal_replacement.hpp b/modules/imgproc/src/hal_replacement.hpp index 1bbc2f3..5c7e772 100644 --- a/modules/imgproc/src/hal_replacement.hpp +++ b/modules/imgproc/src/hal_replacement.hpp @@ -627,7 +627,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src //! @cond IGNORED #define CALL_HAL_RET(name, fun, retval, ...) \ - int res = fun(__VA_ARGS__, &retval); \ + int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \ if (res == CV_HAL_ERROR_OK) \ return retval; \ else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \ @@ -636,7 +636,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src #define CALL_HAL(name, fun, ...) \ - int res = fun(__VA_ARGS__); \ + int res = __CV_EXPAND(fun(__VA_ARGS__)); \ if (res == CV_HAL_ERROR_OK) \ return; \ else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \