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 --- opl/opl_obsd.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'opl/opl_obsd.c') 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