Skip to content

Commit d30a0c6

Browse files
GregoryMorsealalek
authored andcommitted
Merge pull request opencv#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
1 parent fee2049 commit d30a0c6

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

cmake/OpenCVCompilerOptimizations.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,14 @@ elseif(ARM OR AARCH64)
256256
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
257257
if(NOT AARCH64)
258258
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16")
259-
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
260-
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
261-
ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
262-
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
259+
if(NOT MSVC)
260+
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
261+
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
262+
ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
263+
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
264+
ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
265+
endif()
263266
ocv_update(CPU_FP16_IMPLIES "NEON")
264-
ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
265267
else()
266268
ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16")
267269
ocv_update(CPU_NEON_FLAGS_ON "")

modules/core/include/opencv2/core/hal/intrin.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ template <> struct V_RegTrait128<double> {
440440

441441
inline unsigned int trailingZeros32(unsigned int value) {
442442
#if defined(_MSC_VER)
443-
#if (_MSC_VER < 1700)
443+
#if (_MSC_VER < 1700) || defined(_M_ARM)
444444
unsigned long index = 0;
445445
_BitScanForward(&index, value);
446446
return (unsigned int)index;

modules/core/src/hal_replacement.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
727727
//! @cond IGNORED
728728
#define CALL_HAL_RET(name, fun, retval, ...) \
729729
{ \
730-
int res = fun(__VA_ARGS__, &retval); \
730+
int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
731731
if (res == CV_HAL_ERROR_OK) \
732732
return retval; \
733733
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
738738

739739
#define CALL_HAL(name, fun, ...) \
740740
{ \
741-
int res = fun(__VA_ARGS__); \
741+
int res = __CV_EXPAND(fun(__VA_ARGS__)); \
742742
if (res == CV_HAL_ERROR_OK) \
743743
return; \
744744
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \

modules/imgproc/src/hal_replacement.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
627627

628628
//! @cond IGNORED
629629
#define CALL_HAL_RET(name, fun, retval, ...) \
630-
int res = fun(__VA_ARGS__, &retval); \
630+
int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
631631
if (res == CV_HAL_ERROR_OK) \
632632
return retval; \
633633
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
636636

637637

638638
#define CALL_HAL(name, fun, ...) \
639-
int res = fun(__VA_ARGS__); \
639+
int res = __CV_EXPAND(fun(__VA_ARGS__)); \
640640
if (res == CV_HAL_ERROR_OK) \
641641
return; \
642642
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \

0 commit comments

Comments
 (0)