Detect the presence of the sys/io.h header and the ioperm function

instead of listing a long list of architectures.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/10/head
Slávek Banko 4 years ago
parent 324c040645
commit ef92c2b00d
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -25,6 +25,12 @@
// Defined to 1 if you have <linux/videodev2.h> header file. // Defined to 1 if you have <linux/videodev2.h> header file.
#cmakedefine HAVE_LINUX_VIDEODEV2_H 1 #cmakedefine HAVE_LINUX_VIDEODEV2_H 1
// Defined to 1 if you have <sys/io.h> header file.
#cmakedefine HAVE_SYS_IO_H 1
// Defined to 1 if <sys/io.h> defines ioperm function.
#cmakedefine HAVE_IOPERM 1
// Defined to 1 if you have <stdint.h> header file // Defined to 1 if you have <stdint.h> header file
#cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDINT_H 1

@ -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" ) tde_message_fatal( "video4linux support is requested, but videodev2.h or videodev.h was not found on your system" )
endif( ) endif( )
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( ) endif( )

@ -111,6 +111,9 @@ case "$target" in
if test x$have_v4l2 = xtrue; then if test x$have_v4l2 = xtrue; then
AC_DEFINE(HAVE_LINUX_VIDEODEV2_H, 1, [Define to 1 if you have the <linux/videodev2.h> header file.]) AC_DEFINE(HAVE_LINUX_VIDEODEV2_H, 1, [Define to 1 if you have the <linux/videodev2.h> header file.])
KDE_CHECK_HEADERS([sys/io.h],
[AC_DEFINE(HAVE_IOPERM, 1, [Defined to 1 if <sys/io.h> defines ioperm function.])]
)
fi fi
AM_CONDITIONAL(BSD, test x$OSDIR = xbsd) AM_CONDITIONAL(BSD, test x$OSDIR = xbsd)

@ -27,7 +27,7 @@
// Henrich <henrich@msu.edu> // Henrich <henrich@msu.edu>
//#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@ -38,11 +38,11 @@
#endif /* LOCKING */ #endif /* LOCKING */
#ifdef __linux__ #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 <fcntl.h> #include <fcntl.h>
#else #else
#include <sys/io.h> #include <sys/io.h>
#endif /* arm */ #endif /* !HAVE_IOPERM */
#elif defined(QNX) #elif defined(QNX)
#include <conio.h> #include <conio.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
@ -75,7 +75,7 @@ port_t::port_t(int iport) {
#endif /* LOCKING */ #endif /* LOCKING */
#ifdef LINUX #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) { if ((devport = open("/dev/port", O_RDWR)) < 0) {
perror("open /dev/port"); perror("open /dev/port");
return; return;
@ -85,7 +85,7 @@ port_t::port_t(int iport) {
perror("ioperm()"); perror("ioperm()");
return; return;
} }
#endif /* arm */ #endif /* !HAVE_IOPERM */
#elif defined(FREEBSD) #elif defined(FREEBSD)
if ((devio = fopen("/dev/io", "r+")) == NULL) { if ((devio = fopen("/dev/io", "r+")) == NULL) {
perror("fopen /dev/io"); perror("fopen /dev/io");
@ -119,7 +119,7 @@ port_t::~port_t(void) {
unlock(port); unlock(port);
#endif /* LOCKING */ #endif /* LOCKING */
#ifdef LINUX #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) if (devport >= 0)
close(devport); close(devport);
#else #else
@ -127,7 +127,7 @@ port_t::~port_t(void) {
if (ioperm(port, 3, 0) != 0) // drop port permissions -- still must if (ioperm(port, 3, 0) != 0) // drop port permissions -- still must
// be root // be root
perror("ioperm()"); perror("ioperm()");
#endif /* arm */ #endif /* !HAVE_IOPERM */
#elif defined(FREEBSD) #elif defined(FREEBSD)
if (devio != NULL) if (devio != NULL)
fclose(devio); fclose(devio);

@ -30,14 +30,14 @@
#ifndef PORT_H #ifndef PORT_H
#define PORT_H #define PORT_H
//#include "config.h" #include "config.h"
#include <unistd.h> #include <unistd.h>
#ifdef __linux__ #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 <sys/io.h> #include <sys/io.h>
#endif /* !arm */ #endif /* HAVE_IOPERM */
#elif defined(QNX) #elif defined(QNX)
#include <conio.h> #include <conio.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
@ -55,7 +55,7 @@
#error Please define a platform in the Makefile #error Please define a platform in the Makefile
#endif #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; static char ports_temp;
#ifdef inb #ifdef inb
@ -74,7 +74,7 @@ static char ports_temp;
ports_temp = data; \ ports_temp = data; \
write(devport, &ports_temp, 1); write(devport, &ports_temp, 1);
#endif /* arm, hppa */ #endif
class port_t { class port_t {
public: public:
@ -114,7 +114,7 @@ private:
#ifdef FREEBSD #ifdef FREEBSD
FILE *devio; FILE *devio;
#endif #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; int devport;
#endif #endif
}; };

Loading…
Cancel
Save