From 73cc6b5a6017a15b02ce3480e0e58d19520b31ba Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 4 Oct 2009 04:21:40 +0000 Subject: Make OpenBSD native OPL backend work on x86_64 as well as i386. Subversion-branch: /branches/opl-branch Subversion-revision: 1707 --- configure.in | 2 ++ opl/opl.c | 4 ++-- opl/opl_obsd.c | 38 +++++++++++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index d8bad56e..1d1b3f3e 100644 --- a/configure.in +++ b/configure.in @@ -73,8 +73,10 @@ AC_SDL_MAIN_WORKAROUND([ AC_CHECK_FUNCS(mmap sched_setaffinity ioperm) # OpenBSD I/O i386 library for I/O port access. + # (64 bit has the same thing with a different name!) AC_CHECK_LIB(i386, i386_iopl) + AC_CHECK_LIB(amd64, amd64_iopl) ]) AC_CHECK_TOOL(WINDRES, windres, ) diff --git a/opl/opl.c b/opl/opl.c index bf999d47..8e57647e 100644 --- a/opl/opl.c +++ b/opl/opl.c @@ -42,7 +42,7 @@ #ifdef HAVE_IOPERM extern opl_driver_t opl_linux_driver; #endif -#ifdef HAVE_LIBI386 +#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64) extern opl_driver_t opl_openbsd_driver; #endif #ifdef _WIN32 @@ -55,7 +55,7 @@ static opl_driver_t *drivers[] = #ifdef HAVE_IOPERM &opl_linux_driver, #endif -#ifdef HAVE_LIBI386 +#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64) &opl_openbsd_driver, #endif #ifdef _WIN32 diff --git a/opl/opl_obsd.c b/opl/opl_obsd.c index 05574333..b07a0421 100644 --- a/opl/opl_obsd.c +++ b/opl/opl_obsd.c @@ -25,16 +25,36 @@ #include "config.h" -#ifdef HAVE_LIBI386 +// OpenBSD has a i386_iopl on i386 and amd64_iopl on x86_64, +// even though they do the same thing. Take care of this +// here, and map set_iopl to point to the appropriate name. -#include -#include -#include -#include +#if defined(HAVE_LIBI386) #include #include #include +#define set_iopl i386_iopl + +#elif defined(HAVE_LIBAMD64) + +#include +#include +#include +#define set_iopl amd64_iopl + +#else +#define NO_OBSD_DRIVER +#endif + +// If the above succeeded, proceed with the rest. + +#ifndef NO_OBSD_DRIVER + +#include +#include +#include +#include #include "opl.h" #include "opl_internal.h" @@ -46,7 +66,7 @@ static int OPL_OpenBSD_Init(unsigned int port_base) { // Try to get permissions: - if (i386_iopl(3) < 0) + if (set_iopl(3) < 0) { fprintf(stderr, "Failed to get raise I/O privilege level: " "check that you are running as root.\n"); @@ -59,7 +79,7 @@ static int OPL_OpenBSD_Init(unsigned int port_base) if (!OPL_Timer_StartThread()) { - i386_iopl(0); + set_iopl(0); return 0; } @@ -74,7 +94,7 @@ static void OPL_OpenBSD_Shutdown(void) // Release I/O port permissions: - i386_iopl(0); + set_iopl(0); } static unsigned int OPL_OpenBSD_PortRead(opl_port_t port) @@ -101,5 +121,5 @@ opl_driver_t opl_openbsd_driver = OPL_Timer_SetPaused }; -#endif /* #ifdef HAVE_LIBI386 */ +#endif /* #ifndef NO_OBSD_DRIVER */ -- cgit v1.2.3