From 9a13ecb8f1462efaf741fed293e29ba38757ff70 Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Sat, 29 Jun 2013 20:49:53 +0200 Subject: [PATCH] Fix build on NetBSD-4. Signed-off-by: Thomas Klausner Reviewed-by: Matthieu Herrb Signed-off-by: Alan Coopersmith --- configure.ac | 10 ++++++++++ src/netbsd_pci.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 3441b63..537cfe3 100644 --- a/configure.ac +++ b/configure.ac @@ -108,7 +108,17 @@ AC_SYS_LARGEFILE AC_CHECK_HEADERS([err.h]) +if test "x$netbsd" = xyes; then +AC_CHECK_HEADERS([machine/sysarch.h]) +AC_CHECK_HEADERS([machine/mtrr.h], [have_mtrr_h="yes"], [have_mtrr_h="no"], +[#ifdef HAVE_MACHINE_SYSARCH_H +#include +#include +#endif +]) +else AC_CHECK_HEADER([asm/mtrr.h], [have_mtrr_h="yes"], [have_mtrr_h="no"]) +fi if test "x$have_mtrr_h" = xyes; then AC_DEFINE(HAVE_MTRR, 1, [Use MTRRs on mappings]) diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c index c9bd052..295e927 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -21,10 +21,25 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef HAVE_MTRR #include #include +#ifdef _X86_SYSARCH_L +/* NetBSD 5.x and newer */ #define netbsd_set_mtrr(mr, num) _X86_SYSARCH_L(set_mtrr)(mr, num) +#else +/* NetBSD 4.x and older */ +#ifdef __i386__ +#define netbsd_set_mtrr(mr, num) i386_set_mtrr((mr), (num)) +#endif +#ifdef __amd64__ +#define netbsd_set_mtrr(mr, num) x86_64_set_mtrr((mr), (num)) +#endif +#endif #endif #include -- 2.7.4