# 
# Submitted:
#
# Robert Schwebel, 2004-01-31 (patch by RSC & Dan Kegel)
#
# Error: 
# 
# arm-unknown-linux-gnu-gcc ../sysdeps/unix/sysv/linux/arm/ioperm.c -c 
# -std=gnu99 -O -Wall -Winline -Wstrict-prototypes -Wwrite-strings -g0 
# -O99 -fomit-frame-pointer -D__USE_STRING_INLINES    -I../include -I. 
# -I/ptx/work/cvs-rsc/ptxdist/build/glibc-2.3.2-build/mis c -I.. -I../libio  
# -I/ptx/work/cvs-rsc/ptxdist/build/glibc-2.3.2-build -I../sysdeps/arm/elf 
# -I../linuxthreads/sysdeps/unix/sysv/linu x/arm 
# -I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread 
# -I../sysdeps/pthread -I../linuxthreads/sysdeps/uni x/sysv 
# -I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/arm 
# -I../sysdeps/unix/sysv/linux/arm -I../sysdeps/unix/sysv/linux 
# -I ../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman 
# -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/arm 
# -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/arm -I../sysdeps/wordsize-32 
# -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-6 4 -I../sysdeps/ieee754 -I../sysdeps/generic/elf 
# -I../sysdeps/generic  -nostdinc -isystem 
# /opt/ptxdist/arm-linux-3.3.2/lib/gcc-lib/arm-unknown-linux-gnu/3.3.2/include -isystem 
# /opt/ptxdist/arm-linux-3.3.2/arm-unknown-linux-gnu/include -D_LIBC_REENTRANT -include 
# ../include/libc-symbols.h -o /ptx/work/cvs-rsc/ptxdist/build/glibc-2.3.2-build/misc/ioperm.o 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c: In function `init_iosys': 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:103: error: `BUS_ISA' undeclared (first use in this function) 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:103: error: (Each undeclared identifier is reported only once 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:103: error: for each function it appears in.) 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:103: error: initializer element is not constant 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:103: error: (near initialization for `iobase_name[1]') 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:104: error: initializer element is not constant 
# ../sysdeps/unix/sysv/linux/arm/ioperm.c:104: error: (near initialization for `ioshift_name[1]') 
# make[3]: *** [/ptx/work/cvs-rsc/ptxdist/build/glibc-2.3.2-build/misc/ioperm.o] Error 1
#
#
# Description: 
#
# Kernel headers have changed to avoid confusion with BUS_ISA in input.h.
# 
# State:
# 
# Kernels > 2.4.24 and > 2.6 have a CTL_BUS_ISA definition. Older kernels should not be used anyway :-) 
#

diff -urN glibc-2.3.2/sysdeps/unix/sysv/linux/arm/ioperm.c glibc-2.3.2-ptx/sysdeps/unix/sysv/linux/arm/ioperm.c
--- glibc-2.3.2/sysdeps/unix/sysv/linux/arm/ioperm.c	2004-02-02 07:37:24.000000000 +0100
+++ glibc-2.3.2-ptx/sysdeps/unix/sysv/linux/arm/ioperm.c	2004-02-02 08:15:06.000000000 +0100
@@ -47,6 +47,12 @@
 #include <asm/page.h>
 #include <sys/sysctl.h>
 
+/* see http://www.ussg.iu.edu/hypermail/linux/kernel/0311.0/0529.html */
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23))
+#define CTL_BUS_ISA BUS_ISA    /* and hope it's not the one from linux/input.h */
+#endif
+
 #define PATH_ARM_SYSTYPE	"/etc/arm_systype"
 #define PATH_CPUINFO		"/proc/cpuinfo"
 
@@ -80,7 +86,7 @@
  * Initialize I/O system.  There are several ways to get the information
  * we need.  Each is tried in turn until one succeeds.
  *
- * 1. Sysctl (CTL_BUS, BUS_ISA, ISA_*).  This is the preferred method
+ * 1. Sysctl (CTL_BUS, CTL_BUS_ISA, ISA_*).  This is the preferred method
  *    but not all kernels support it.
  *
  * 2. Read the value (not the contents) of symlink PATH_ARM_SYSTYPE.
@@ -100,8 +106,8 @@
 {
   char systype[256];
   int i, n;
-  static int iobase_name[] = { CTL_BUS, BUS_ISA, BUS_ISA_PORT_BASE };
-  static int ioshift_name[] = { CTL_BUS, BUS_ISA, BUS_ISA_PORT_SHIFT };
+  static int iobase_name[] = { CTL_BUS, CTL_BUS_ISA, BUS_ISA_PORT_BASE };
+  static int ioshift_name[] = { CTL_BUS, CTL_BUS_ISA, BUS_ISA_PORT_SHIFT };
   size_t len = sizeof(io.base);
 
   if (! sysctl (iobase_name, 3, &io.io_base, &len, NULL, 0)