kumquat-buildroot/package/chocolate-doom/0003-opl-limit-use-of-ioperm-inb-outb-to-x86-architecture.patch

81 lines
2.5 KiB
Diff
Raw Normal View History

From 87c7399305b30045a856d737bbfd8f59b8f52392 Mon Sep 17 00:00:00 2001
From: Rodrigo Rebello <rprebello@gmail.com>
Date: Fri, 6 Nov 2015 12:14:01 -0200
Subject: [PATCH] opl: limit use of ioperm/inb/outb to x86 architecture
The use of I/O ports in the Linux driver to directly control OPL chips
is x86 specific and only really makes sense for x86-based PC's with
compatible hardware.
For some architectures (e.g. ARM), ioperm, inb and outb do exist and are
detected by the configure script (via AC_CHECK_FUNCS(ioperm)), but their
use is inappropriate in these cases and should be avoided.
In some other scenarios, like when using a GNU toolchain + uClibc for
PowerPC, the build even fails with the following error:
opl_linux.c:26:20: fatal error: sys/io.h: No such file or directory
That is so because ioperm() is exported by uClibc and gets detected by
configure, which enables the "Linux" driver via definition of
HAVE_IOPERM, but in practice 'sys/io.h' is missing for ppc (inb/outb is
not implemented, and the call to ioperm() would return EIO anyway).
So, besides testing for HAVE_IOPERM, also test if either __i386__ or
__x86_64__ are defined before enabling this OPL driver.
Upstream-status: accepted, not yet released.
https://github.com/chocolate-doom/chocolate-doom/pull/638
Signed-off-by: Rodrigo Rebello <rprebello@gmail.com>
---
opl/opl.c | 4 ++--
opl/opl_linux.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/opl/opl.c b/opl/opl.c
index 60f027d..0d25689 100644
--- a/opl/opl.c
+++ b/opl/opl.c
@@ -27,7 +27,7 @@
//#define OPL_DEBUG_TRACE
-#ifdef HAVE_IOPERM
+#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM)
extern opl_driver_t opl_linux_driver;
#endif
#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64)
@@ -40,7 +40,7 @@ extern opl_driver_t opl_sdl_driver;
static opl_driver_t *drivers[] =
{
-#ifdef HAVE_IOPERM
+#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM)
&opl_linux_driver,
#endif
#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64)
diff --git a/opl/opl_linux.c b/opl/opl_linux.c
index 5df5d46..19e4c3e 100644
--- a/opl/opl_linux.c
+++ b/opl/opl_linux.c
@@ -17,7 +17,7 @@
#include "config.h"
-#ifdef HAVE_IOPERM
+#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM)
#include <stdio.h>
#include <string.h>
@@ -99,5 +99,5 @@ opl_driver_t opl_linux_driver =
OPL_Timer_AdjustCallbacks,
};
-#endif /* #ifdef HAVE_IOPERM */
+#endif /* #if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM) */
--
2.1.4