|
|
@ -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);
|
|
|
|