Merge pull request #20399 from pablorcum:3.4

Improves support for Unix non-Linux systems, including QNX

* Fixes #20395. Improves support for Unix non-Linux systems. Focus on QNX Neutrino.

Signed-off-by: promero <promero@mathworks.com>

* Update system.cpp
pull/20423/head^2
Pablo Romero 3 years ago committed by GitHub
parent 0acd06d13c
commit 6f417b57c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CMakeLists.txt
  2. 2
      modules/core/src/parallel.cpp
  3. 22
      modules/core/src/system.cpp

@ -648,6 +648,8 @@ if(UNIX)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread)
elseif(EMSCRIPTEN) elseif(EMSCRIPTEN)
# no need to link to system libs with emscripten # no need to link to system libs with emscripten
elseif(QNXNTO)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m)
else() else()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt) set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
endif() endif()

@ -53,7 +53,7 @@
#undef abs #undef abs
#endif #endif
#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ \ #if defined __unix__ || defined __APPLE__ || defined __GLIBC__ \
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ \ || defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ \
|| defined __OpenBSD__ || defined __OpenBSD__
#include <unistd.h> #include <unistd.h>

@ -114,10 +114,14 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
#include <cstdlib> // std::abort #include <cstdlib> // std::abort
#endif #endif
#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ #if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__
# include <unistd.h> # include <unistd.h>
# include <fcntl.h> # include <fcntl.h>
#if defined __QNXNTO__
# include <sys/elf.h>
#else
# include <elf.h> # include <elf.h>
#endif
#if defined __ANDROID__ || defined __linux__ #if defined __ANDROID__ || defined __linux__
# include <linux/auxvec.h> # include <linux/auxvec.h>
#endif #endif
@ -128,7 +132,7 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
#endif #endif
#if (defined __ppc64__ || defined __PPC64__) && defined __linux__ #if (defined __ppc64__ || defined __PPC64__) && defined __unix__
# include "sys/auxv.h" # include "sys/auxv.h"
# ifndef AT_HWCAP2 # ifndef AT_HWCAP2
# define AT_HWCAP2 26 # define AT_HWCAP2 26
@ -229,7 +233,7 @@ std::wstring GetTempFileNameWinRT(std::wstring prefix)
#include "omp.h" #include "omp.h"
#endif #endif
#if defined __linux__ || defined __APPLE__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ || defined __GLIBC__ || defined __HAIKU__ #if defined __unix__ || defined __APPLE__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ || defined __GLIBC__ || defined __HAIKU__
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
@ -591,7 +595,7 @@ struct HWFeatures
have[CV_CPU_MSA] = true; have[CV_CPU_MSA] = true;
#endif #endif
#if (defined __ppc64__ || defined __PPC64__) && defined __linux__ #if (defined __ppc64__ || defined __PPC64__) && defined __unix__
unsigned int hwcap = getauxval(AT_HWCAP); unsigned int hwcap = getauxval(AT_HWCAP);
if (hwcap & PPC_FEATURE_HAS_VSX) { if (hwcap & PPC_FEATURE_HAS_VSX) {
hwcap = getauxval(AT_HWCAP2); hwcap = getauxval(AT_HWCAP2);
@ -804,12 +808,12 @@ int64 getTickCount(void)
LARGE_INTEGER counter; LARGE_INTEGER counter;
QueryPerformanceCounter( &counter ); QueryPerformanceCounter( &counter );
return (int64)counter.QuadPart; return (int64)counter.QuadPart;
#elif defined __linux || defined __linux__ #elif defined __MACH__ && defined __APPLE__
return (int64)mach_absolute_time();
#elif defined __unix__
struct timespec tp; struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp); clock_gettime(CLOCK_MONOTONIC, &tp);
return (int64)tp.tv_sec*1000000000 + tp.tv_nsec; return (int64)tp.tv_sec*1000000000 + tp.tv_nsec;
#elif defined __MACH__ && defined __APPLE__
return (int64)mach_absolute_time();
#else #else
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
@ -823,8 +827,6 @@ double getTickFrequency(void)
LARGE_INTEGER freq; LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq); QueryPerformanceFrequency(&freq);
return (double)freq.QuadPart; return (double)freq.QuadPart;
#elif defined __linux || defined __linux__
return 1e9;
#elif defined __MACH__ && defined __APPLE__ #elif defined __MACH__ && defined __APPLE__
static double freq = 0; static double freq = 0;
if( freq == 0 ) if( freq == 0 )
@ -834,6 +836,8 @@ double getTickFrequency(void)
freq = sTimebaseInfo.denom*1e9/sTimebaseInfo.numer; freq = sTimebaseInfo.denom*1e9/sTimebaseInfo.numer;
} }
return freq; return freq;
#elif defined __unix__
return 1e9;
#else #else
return 1e6; return 1e6;
#endif #endif

Loading…
Cancel
Save