opencv-3.4.1-fix-on-x86.patch 1.2 KB

12345678910111213141516171819202122232425262728
  1. From 7dc162cb4252ccf461f1c63650abde3c8807b79c Mon Sep 17 00:00:00 2001
  2. From: Alexander Alekhin <alexander.alekhin@intel.com>
  3. Date: Mon, 9 Apr 2018 18:25:51 +0300
  4. Subject: [PATCH] core: fix mm_pause() for non-SSE i386 builds
  5. replaced to safe binary compatible 'rep; nop' asm instruction
  6. ---
  7. modules/core/src/parallel_impl.cpp | 6 +++++-
  8. 1 file changed, 5 insertions(+), 1 deletion(-)
  9. diff --git a/modules/core/src/parallel_impl.cpp b/modules/core/src/parallel_impl.cpp
  10. index 78d9eb63694..bc64fce7a81 100644
  11. --- a/modules/core/src/parallel_impl.cpp
  12. +++ b/modules/core/src/parallel_impl.cpp
  13. @@ -49,7 +49,11 @@ DECLARE_CV_YIELD
  14. DECLARE_CV_PAUSE
  15. #endif
  16. #ifndef CV_PAUSE
  17. -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
  18. +# if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
  19. +# if !defined(__SSE__)
  20. + static inline void cv_non_sse_mm_pause() { __asm__ __volatile__ ("rep; nop"); }
  21. +# define _mm_pause cv_non_sse_mm_pause
  22. +# endif
  23. # define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
  24. # elif defined __GNUC__ && defined __aarch64__
  25. # define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)