From ef92c2b00d6b9085b392da3708d2e6a7aabdb65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Mon, 30 Mar 2020 21:38:25 +0200 Subject: Detect the presence of the sys/io.h header and the ioperm function instead of listing a long list of architectures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- config.h.cmake | 6 ++++++ kstars/ConfigureChecks.cmake | 5 +++++ kstars/configure.in.in | 3 +++ kstars/kstars/indi/webcam/port.cpp | 14 +++++++------- kstars/kstars/indi/webcam/port.h | 12 ++++++------ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/config.h.cmake b/config.h.cmake index e652bc51..8c61c4b8 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -25,6 +25,12 @@ // Defined to 1 if you have header file. #cmakedefine HAVE_LINUX_VIDEODEV2_H 1 +// Defined to 1 if you have header file. +#cmakedefine HAVE_SYS_IO_H 1 + +// Defined to 1 if defines ioperm function. +#cmakedefine HAVE_IOPERM 1 + // Defined to 1 if you have header file #cmakedefine HAVE_STDINT_H 1 diff --git a/kstars/ConfigureChecks.cmake b/kstars/ConfigureChecks.cmake index 41184537..4df776a8 100644 --- a/kstars/ConfigureChecks.cmake +++ b/kstars/ConfigureChecks.cmake @@ -48,6 +48,11 @@ if( WITH_V4L ) tde_message_fatal( "video4linux support is requested, but videodev2.h or videodev.h was not found on your system" ) endif( ) endif( ) + + check_include_file( "sys/io.h" HAVE_SYS_IO_H ) + if( HAVE_SYS_IO_H ) + check_symbol_exists( "ioperm" "sys/io.h" HAVE_IOPERM ) + endif( ) endif( ) diff --git a/kstars/configure.in.in b/kstars/configure.in.in index 6b364a76..9065ba5d 100644 --- a/kstars/configure.in.in +++ b/kstars/configure.in.in @@ -111,6 +111,9 @@ case "$target" in if test x$have_v4l2 = xtrue; then AC_DEFINE(HAVE_LINUX_VIDEODEV2_H, 1, [Define to 1 if you have the header file.]) + KDE_CHECK_HEADERS([sys/io.h], + [AC_DEFINE(HAVE_IOPERM, 1, [Defined to 1 if defines ioperm function.])] + ) fi AM_CONDITIONAL(BSD, test x$OSDIR = xbsd) diff --git a/kstars/kstars/indi/webcam/port.cpp b/kstars/kstars/indi/webcam/port.cpp index d5b68d40..74d7196f 100644 --- a/kstars/kstars/indi/webcam/port.cpp +++ b/kstars/kstars/indi/webcam/port.cpp @@ -27,7 +27,7 @@ // Henrich -//#include "config.h" +#include "config.h" #include #include @@ -38,11 +38,11 @@ #endif /* LOCKING */ #ifdef __linux__ - #if defined(arm) || defined(__aarch64__) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__) + #if !defined(HAVE_IOPERM) #include #else #include - #endif /* arm */ + #endif /* !HAVE_IOPERM */ #elif defined(QNX) #include #elif defined(__FreeBSD__) @@ -75,7 +75,7 @@ port_t::port_t(int iport) { #endif /* LOCKING */ #ifdef LINUX -#if defined(arm) || defined(__aarch64__) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__) +#if !defined(HAVE_IOPERM) if ((devport = open("/dev/port", O_RDWR)) < 0) { perror("open /dev/port"); return; @@ -85,7 +85,7 @@ port_t::port_t(int iport) { perror("ioperm()"); return; } -#endif /* arm */ +#endif /* !HAVE_IOPERM */ #elif defined(FREEBSD) if ((devio = fopen("/dev/io", "r+")) == NULL) { perror("fopen /dev/io"); @@ -119,7 +119,7 @@ port_t::~port_t(void) { unlock(port); #endif /* LOCKING */ #ifdef LINUX -#if defined(arm) || defined(__aarch64__) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__) +#if !defined(HAVE_IOPERM) if (devport >= 0) close(devport); #else @@ -127,7 +127,7 @@ port_t::~port_t(void) { if (ioperm(port, 3, 0) != 0) // drop port permissions -- still must // be root perror("ioperm()"); -#endif /* arm */ +#endif /* !HAVE_IOPERM */ #elif defined(FREEBSD) if (devio != NULL) fclose(devio); diff --git a/kstars/kstars/indi/webcam/port.h b/kstars/kstars/indi/webcam/port.h index 70dd9d4d..599b25bb 100644 --- a/kstars/kstars/indi/webcam/port.h +++ b/kstars/kstars/indi/webcam/port.h @@ -30,14 +30,14 @@ #ifndef PORT_H #define PORT_H -//#include "config.h" +#include "config.h" #include #ifdef __linux__ - #if !defined(arm) && !defined(__aarch64__) && !defined(__hppa__) && !defined(__sparc__) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__s390__) && !defined(__s390x__) && !defined(__mips__) && !defined(__mc68000__) + #if defined(HAVE_IOPERM) #include - #endif /* !arm */ + #endif /* HAVE_IOPERM */ #elif defined(QNX) #include #elif defined(__FreeBSD__) @@ -55,7 +55,7 @@ #error Please define a platform in the Makefile #endif -#if defined(arm) || defined(__aarch64__) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__) +#if defined(__linux__) && !defined(HAVE_IOPERM) static char ports_temp; #ifdef inb @@ -74,7 +74,7 @@ static char ports_temp; ports_temp = data; \ write(devport, &ports_temp, 1); -#endif /* arm, hppa */ +#endif class port_t { public: @@ -114,7 +114,7 @@ private: #ifdef FREEBSD FILE *devio; #endif -#if defined(__linux__) && (defined(arm) || defined(__aarch64__) || defined(__hppa__) || defined(__sparc__) || defined(__ppc__) || defined(__powerpc__) || defined(__s390__) || defined(__s390x__) || defined(__mips__) || defined(__mc68000__)) +#if defined(__linux__) && !defined(HAVE_IOPERM) int devport; #endif }; -- cgit v1.2.1