about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/Makefile2
-rw-r--r--sysdeps/unix/sysv/getdents.c4
-rw-r--r--sysdeps/unix/sysv/linux/Dist2
-rw-r--r--sysdeps/unix/sysv/linux/Makefile18
-rw-r--r--sysdeps/unix/sysv/linux/alpha/Dist2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/ioctls.h39
-rw-r--r--sysdeps/unix/sysv/linux/alpha/ioperm.c194
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h (renamed from sysdeps/unix/sysv/linux/alpha/kernel_termios.h)6
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sys/procfs.h2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/configure2
-rw-r--r--sysdeps/unix/sysv/linux/getdents.c26
-rw-r--r--sysdeps/unix/sysv/linux/i386/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/sys/kernel_termios.h (renamed from sysdeps/unix/sysv/linux/kernel_termios.h)6
-rw-r--r--sysdeps/unix/sysv/linux/sys/procfs.h2
-rw-r--r--sysdeps/unix/sysv/linux/tcgetattr.c6
-rw-r--r--sysdeps/unix/sysv/linux/tcsetattr.c6
18 files changed, 192 insertions, 130 deletions
diff --git a/sysdeps/unix/sysv/Makefile b/sysdeps/unix/sysv/Makefile
index 885d3b4eca..cfb1607b3f 100644
--- a/sysdeps/unix/sysv/Makefile
+++ b/sysdeps/unix/sysv/Makefile
@@ -16,7 +16,7 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-ifeq ($(subdir), termios)
+ifeq ($(subdir),termios)
 
 ifeq (,$(filter termio.h,$(sysdep_headers)))
 
diff --git a/sysdeps/unix/sysv/getdents.c b/sysdeps/unix/sysv/getdents.c
index 109f29a2b1..ef2dc23faf 100644
--- a/sysdeps/unix/sysv/getdents.c
+++ b/sysdeps/unix/sysv/getdents.c
@@ -21,9 +21,9 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-extern int __getdents __P ((int fd, char *buf, size_t nbytes));
+extern ssize_t __getdents __P ((int fd, char *buf, size_t nbytes));
 
-int
+ssize_t
 __getdirentries (fd, buf, nbytes, basep)
      int fd;
      char *buf;
diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist
index b96d1dfcf6..c5a2f179ee 100644
--- a/sysdeps/unix/sysv/linux/Dist
+++ b/sysdeps/unix/sysv/linux/Dist
@@ -1,6 +1,5 @@
 init-first.h
 kernel_sigaction.h
-kernel_termios.h
 llseek.c
 siglist.h
 sysctl.c
@@ -18,6 +17,7 @@ sys/debugreg.h
 sys/io.h
 sys/kd.h
 sys/kdaemon.h
+sys/kernel_termios.h
 sys/klog.h
 sys/module.h
 sys/mount.h
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 97fb5f14a5..ae2e294785 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -1,10 +1,10 @@
-ifeq ($(subdir), csu)
+ifeq ($(subdir),csu)
 CFLAGS-init-first.c = -fkeep-inline-functions
 
 sysdep_routines += errno-loc
 endif
 
-ifeq ($(subdir), misc)
+ifeq ($(subdir),misc)
 sysdep_routines += sysctl clone llseek
 
 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h sys/mtio.h \
@@ -28,29 +28,29 @@ $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscal
 generated += syscall-list.h syscall-list.d
 endif
 
-ifeq ($(subdir), time)
+ifeq ($(subdir),time)
 sysdep_headers += sys/timex.h
 endif
 
-ifeq ($(subdir), socket)
+ifeq ($(subdir),socket)
 sysdep_headers += sys/socketcall.h net/if.h net/if_ppp.h net/ppp-comp.h \
 		  net/ppp_defs.h net/if_arp.h net/route.h
 endif
 
-ifeq ($(subdir), sunrpc)
+ifeq ($(subdir),sunrpc)
 sysdep_headers += nfs/nfs.h
 endif
 
-ifeq ($(subdir), termios)
-sysdep_headers += termio.h
+ifeq ($(subdir),termios)
+sysdep_headers += termio.h sys/kernel_termios.h
 endif
 
-ifeq ($(subdir), stdio-common)
+ifeq ($(subdir),stdio-common)
 # Just disable the auto generation in sysdeps/generic
 inhibit-siglist := yes
 endif
 
-ifeq ($(subdir), inet)
+ifeq ($(subdir),inet)
 sysdep_headers += netinet/in_systm.h sys/socketvar.h
 endif
 
diff --git a/sysdeps/unix/sysv/linux/alpha/Dist b/sysdeps/unix/sysv/linux/alpha/Dist
index cdb11e98d0..f3c4cb92d6 100644
--- a/sysdeps/unix/sysv/linux/alpha/Dist
+++ b/sysdeps/unix/sysv/linux/alpha/Dist
@@ -4,7 +4,7 @@ ioperm.c
 init-first.h
 clone.S
 sys/io.h
-kernel_sigaction.h
 kernel_termios.h
 sys/acct.h
+sys/kernel_sigaction.h
 sys/procfs.h
diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index 3908b5703c..fa2c078664 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -1,4 +1,4 @@
-ifeq ($(subdir), misc)
+ifeq ($(subdir),misc)
 sysdep_headers += alpha/ptrace.h alpha/regdef.h
 
 sysdep_routines += ieee_get_fp_control ieee_set_fp_control \
diff --git a/sysdeps/unix/sysv/linux/alpha/ioctls.h b/sysdeps/unix/sysv/linux/alpha/ioctls.h
new file mode 100644
index 0000000000..80b2e62e77
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/ioctls.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _IOCTLS_H
+#define _IOCTLS_H 1
+
+/* Use the definitions from the kernel header files.  */
+#include <asm/ioctls.h>
+#include <sys/kernel_termios.h>
+
+/* Oh well, this is necessary since the kernel data structure is
+   different from the user-level version.  */
+#undef  TCGETS
+#undef  TCSETS
+#undef  TCSETSW
+#undef  TCSETSF
+#define TCGETS	_IOR ('t', 19, struct __kernel_termios)
+#define TCSETS	_IOW ('t', 20, struct __kernel_termios)
+#define TCSETSW	_IOW ('t', 21, struct __kernel_termios)
+#define TCSETSF	_IOW ('t', 22, struct __kernel_termios)
+
+#include <linux/sockios.h>
+
+#endif /* ioctls.h  */
diff --git a/sysdeps/unix/sysv/linux/alpha/ioperm.c b/sysdeps/unix/sysv/linux/alpha/ioperm.c
index 924fc473b2..488265a069 100644
--- a/sysdeps/unix/sysv/linux/alpha/ioperm.c
+++ b/sysdeps/unix/sysv/linux/alpha/ioperm.c
@@ -1,36 +1,36 @@
-/* Copyright (C) 1992, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by David Mosberger.
+/* Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by David Mosberger.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 /* I/O access is restricted to ISA port space (ports 0..65535).
-Modern devices hopefully are sane enough not to put any performance
-critical registers in i/o space.
+   Modern devices hopefully are sane enough not to put any performance
+   critical registers in i/o space.
 
-On the first call to ioperm() or _sethae(), the entire (E)ISA port
-space is mapped into the virtual address space at address io.base.
-mprotect() calls are then used to enable/disable access to ports.  Per
-page, there are PAGE_SIZE>>IO_SHIFT I/O ports (e.g., 256 ports on a
-Low Cost Alpha based system using 8KB pages).
+   On the first call to ioperm() or _sethae(), the entire (E)ISA port
+   space is mapped into the virtual address space at address io.base.
+   mprotect() calls are then used to enable/disable access to ports.  Per
+   page, there are PAGE_SIZE>>IO_SHIFT I/O ports (e.g., 256 ports on a
+   Low Cost Alpha based system using 8KB pages).
 
-Keep in mind that this code should be able to run in a 32bit address
-space.  It is therefore unreasonable to expect mmap'ing the entire
-sparse address space would work (e.g., the Low Cost Alpha chip has an
-I/O address space that's 512MB large!).  */
+   Keep in mind that this code should be able to run in a 32bit address
+   space.  It is therefore unreasonable to expect mmap'ing the entire
+   sparse address space would work (e.g., the Low Cost Alpha chip has an
+   I/O address space that's 512MB large!).  */
 
 #include <errno.h>
 #include <fcntl.h>
@@ -66,27 +66,30 @@ I/O address space that's 512MB large!).  */
 #define CIA_SPARSE_MEM		(0xfffffc8000000000UL)
 #define CIA_DENSE_MEM		(0xfffffc8600000000UL)
 
+#define T2_IO_BASE		(0xfffffc03a0000000UL)
+#define T2_SPARSE_BASE		(0xfffffc0200000000UL)
+#define T2_DENSE_BASE		(0xfffffc03c0000000UL)
 
-enum {
-  IOSYS_JENSEN = 0, IOSYS_APECS = 1, IOSYS_CIA = 2
+typedef enum {
+  IOSYS_UNKNOWN, IOSYS_JENSEN, IOSYS_APECS, IOSYS_CIA, IOSYS_T2
 } iosys_t;
 
 struct ioswtch {
-  void		(*sethae)(unsigned long addr);
-  void		(*outb)(unsigned char b, unsigned long port);
-  void		(*outw)(unsigned short b, unsigned long port);
-  void		(*outl)(unsigned int b, unsigned long port);
-  unsigned int	(*inb)(unsigned long port);
-  unsigned int	(*inw)(unsigned long port);
-  unsigned int	(*inl)(unsigned long port);
+  void		(*sethae)(unsigned long int addr);
+  void		(*outb)(unsigned char b, unsigned long int port);
+  void		(*outw)(unsigned short b, unsigned long int port);
+  void		(*outl)(unsigned int b, unsigned long int port);
+  unsigned int	(*inb)(unsigned long int port);
+  unsigned int	(*inw)(unsigned long int port);
+  unsigned int	(*inl)(unsigned long int port);
 };
 
 static struct platform {
-  const char	*name;
-  int		io_sys;
-  int		hae_shift;
-  unsigned long	bus_memory_base;
-  unsigned long	sparse_bus_memory_base;
+  const char	   *name;
+  int		    io_sys;
+  iosys_t	    hae_shift;
+  unsigned long	int bus_memory_base;
+  unsigned long	int sparse_bus_memory_base;
 } platform[] = {
   {"Alcor",	IOSYS_CIA,	5, CIA_DENSE_MEM,	CIA_SPARSE_MEM},
   {"Avanti",	IOSYS_APECS,	5, APECS_DENSE_MEM,	APECS_SPARSE_MEM},
@@ -99,27 +102,29 @@ static struct platform {
   {"Mikasa",	IOSYS_APECS,	5, APECS_DENSE_MEM,	APECS_SPARSE_MEM},
   {"Mustang",	IOSYS_APECS,	5, APECS_DENSE_MEM,	APECS_SPARSE_MEM},
   {"Noname",	IOSYS_APECS,	5, APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"Sable",	IOSYS_T2,	5, T2_DENSE_MEM,	T2_SPARSE_MEM},
 };
 
 
 static struct {
   struct hae {
-    unsigned long	cache;
-    unsigned long *	reg;
+    unsigned long int	cache;
+    unsigned long int *	reg;
   } hae;
-  unsigned long		base;
+  unsigned long int	base;
   struct ioswtch *	swp;
-  int			sys;
+  unsigned long int	bus_memory_base;
+  unsigned long int	sparse_bus_memory_base;
+  unsigned long int	io_base;
+  iosys_t		sys;
   int			hae_shift;
-  unsigned long		bus_memory_base;
-  unsigned long		sparse_bus_memory_base;
 } io;
 
-extern void __sethae (unsigned long);	/* we can't use asm/io.h */
+extern void __sethae (unsigned long int);	/* we can't use asm/io.h */
 
 
-static inline unsigned long
-port_to_cpu_addr (unsigned long port, int iosys, int size)
+static inline unsigned long int
+port_to_cpu_addr (unsigned long int port, iosys_t iosys, int size)
 {
   if (iosys == IOSYS_JENSEN)
     return (port << 7) + ((size - 1) << 5) + io.base;
@@ -129,7 +134,7 @@ port_to_cpu_addr (unsigned long port, int iosys, int size)
 
 
 static inline void
-inline_sethae (unsigned long addr, int iosys)
+inline_sethae (unsigned long int addr, iosys_t iosys)
 {
   if (iosys == IOSYS_JENSEN)
     {
@@ -143,7 +148,7 @@ inline_sethae (unsigned long addr, int iosys)
     }
   else
     {
-      unsigned long msb;
+      unsigned long int msb;
 
       /* no need to set hae if msb is 0: */
       msb = addr & 0xf8000000;
@@ -157,10 +162,10 @@ inline_sethae (unsigned long addr, int iosys)
 
 
 static inline void
-inline_outb (unsigned char b, unsigned long port, int iosys)
+inline_outb (unsigned char b, unsigned long int port, iosys_t iosys)
 {
   unsigned int w;
-  unsigned long addr = port_to_cpu_addr (port, iosys, 1);
+  unsigned long int addr = port_to_cpu_addr (port, iosys, 1);
 
   inline_sethae (0, iosys);
   asm ("insbl %2,%1,%0" : "r=" (w) : "ri" (port & 0x3), "r" (b));
@@ -170,10 +175,10 @@ inline_outb (unsigned char b, unsigned long port, int iosys)
 
 
 static inline void
-inline_outw (unsigned short b, unsigned long port, int iosys)
+inline_outw (unsigned short int b, unsigned long int port, iosys_t iosys)
 {
   unsigned int w;
-  unsigned long addr = port_to_cpu_addr (port, iosys, 2);
+  unsigned long int addr = port_to_cpu_addr (port, iosys, 2);
 
   inline_sethae (0, iosys);
   asm ("inswl %2,%1,%0" : "r=" (w) : "ri" (port & 0x3), "r" (b));
@@ -183,9 +188,9 @@ inline_outw (unsigned short b, unsigned long port, int iosys)
 
 
 static inline void
-inline_outl (unsigned int b, unsigned long port, int iosys)
+inline_outl (unsigned int b, unsigned long int port, iosys_t iosys)
 {
-  unsigned long addr = port_to_cpu_addr (port, iosys, 4);
+  unsigned long int addr = port_to_cpu_addr (port, iosys, 4);
 
   if (port >= MAX_PORT)
     return;
@@ -197,9 +202,9 @@ inline_outl (unsigned int b, unsigned long port, int iosys)
 
 
 static inline unsigned int
-inline_inb (unsigned long port, int iosys)
+inline_inb (unsigned long int port, iosys_t iosys)
 {
-  unsigned long result, addr = port_to_cpu_addr (port, iosys, 1);
+  unsigned long int result, addr = port_to_cpu_addr (port, iosys, 1);
 
   inline_sethae (0, iosys);
   result = *(vuip) addr;
@@ -209,9 +214,9 @@ inline_inb (unsigned long port, int iosys)
 
 
 static inline unsigned int
-inline_inw (unsigned long port, int iosys)
+inline_inw (unsigned long int port, iosys_t iosys)
 {
-  unsigned long result, addr = port_to_cpu_addr (port, iosys, 2);
+  unsigned long int result, addr = port_to_cpu_addr (port, iosys, 2);
 
   inline_sethae (0, iosys);
   result = *(vuip) addr;
@@ -221,9 +226,9 @@ inline_inw (unsigned long port, int iosys)
 
 
 static inline unsigned int
-inline_inl (unsigned long port, int iosys)
+inline_inl (unsigned long int port, iosys_t iosys)
 {
-  unsigned long addr = port_to_cpu_addr (port, iosys, 4);
+  unsigned long int addr = port_to_cpu_addr (port, iosys, 4);
 
   inline_sethae (0, iosys);
   return *(vuip) addr;
@@ -232,14 +237,14 @@ inline_inl (unsigned long port, int iosys)
 
 #define DCL_SETHAE(name, iosys)			\
 static void						\
-name##_sethae (unsigned long addr)			\
+name##_sethae (unsigned long int addr)			\
 {							\
   inline_sethae (addr, IOSYS_##iosys);			\
 }
 
 #define DCL_OUT(name, func, type, iosys)		\
 static void						\
-name##_##func (unsigned type b, unsigned long addr)	\
+name##_##func (unsigned type b, unsigned long int addr)	\
 {							\
   inline_##func (b, addr, IOSYS_##iosys);		\
 }
@@ -247,7 +252,7 @@ name##_##func (unsigned type b, unsigned long addr)	\
 
 #define DCL_IN(name, func, iosys)			\
 static unsigned int					\
-name##_##func (unsigned long addr)			\
+name##_##func (unsigned long int addr)			\
 {							\
   return inline_##func (addr, IOSYS_##iosys);		\
 }
@@ -255,7 +260,7 @@ name##_##func (unsigned long addr)			\
 
 DCL_SETHAE(jensen, JENSEN)
 DCL_OUT(jensen, outb, char,  JENSEN)
-DCL_OUT(jensen, outw, short, JENSEN)
+DCL_OUT(jensen, outw, short int, JENSEN)
 DCL_OUT(jensen, outl, int,   JENSEN)
 DCL_IN(jensen, inb, JENSEN)
 DCL_IN(jensen, inw, JENSEN)
@@ -266,7 +271,7 @@ DCL_IN(jensen, inl, JENSEN)
 
 DCL_SETHAE(apecs, APECS)
 DCL_OUT(apecs, outb, char,  APECS)
-DCL_OUT(apecs, outw, short, APECS)
+DCL_OUT(apecs, outw, short int, APECS)
 DCL_OUT(apecs, outl, int,   APECS)
 DCL_IN(apecs, inb, APECS)
 DCL_IN(apecs, inw, APECS)
@@ -291,6 +296,10 @@ struct ioswtch ioswtch[] = {
  * with, we first try to read the value of symlink PATH_ALPHA_SYSTYPE,
  * if that fails, we lookup the "system type" field in /proc/cpuinfo.
  * If that fails as well, we give up.
+ *
+ * If the value received from PATH_ALPHA_SYSTYPE begins with a number,
+ * assume this is a previously unsupported system and the values encode,
+ * in order, "<io_base>,<hae_shift>,<dense_base>,<sparse_base>".
  */
 static int
 init_iosys (void)
@@ -298,10 +307,21 @@ init_iosys (void)
   char systype[256];
   int i, n;
 
-  n = readlink(PATH_ALPHA_SYSTYPE, systype, sizeof(systype) - 1);
+  n = readlink (PATH_ALPHA_SYSTYPE, systype, sizeof (systype) - 1);
   if (n > 0)
     {
       systype[n] = '\0';
+      if (isdigit (systype[0]))
+	{
+	  if (sscanf (systype, "%li,%i,%li,%li", &io.io_base, &io.hae_shift,
+		      &io.bus_memory_base, &io.sparse_bus_memory_base) == 4)
+	    {
+	      io.sys = IOSYS_UNKNOWN;
+	      io.swp = &ioswtch[1];
+	      return 0;
+	    }
+	  /* else we're likely going to fail with the system match below */
+	}
     }
   else
     {
@@ -318,14 +338,14 @@ init_iosys (void)
 	  else
 	    fgets (systype, 256, fp);
 	}
-      fclose(fp);
+      fclose (fp);
 
       if (n == EOF)
 	{
 	  /* this can happen if the format of /proc/cpuinfo changes...  */
-	  fprintf(stderr,
-		  "ioperm.init_iosys(): Unable to determine system type.\n"
-		  "\t(May need " PATH_ALPHA_SYSTYPE " symlink?)\n");
+	  fprintf (stderr,
+		   "ioperm.init_iosys(): Unable to determine system type.\n"
+		   "\t(May need " PATH_ALPHA_SYSTYPE " symlink?)\n");
 	  __set_errno (ENODEV);
 	  return -1;
 	}
@@ -355,9 +375,9 @@ init_iosys (void)
 
 
 int
-_ioperm (unsigned long from, unsigned long num, int turn_on)
+_ioperm (unsigned long int from, unsigned long int num, int turn_on)
 {
-  unsigned long addr, len;
+  unsigned long int addr, len;
   int prot;
 
   if (!io.swp && init_iosys () < 0)
@@ -374,7 +394,7 @@ _ioperm (unsigned long from, unsigned long num, int turn_on)
     {
       if (!io.base)
 	{
-	  unsigned long base;
+	  unsigned long int base;
 	  int fd;
 
 	  io.hae.reg   = 0;		/* not used in user-level */
@@ -387,6 +407,7 @@ _ioperm (unsigned long from, unsigned long num, int turn_on)
 
 	  switch (io.sys)
 	    {
+	    case IOSYS_UNKNOWN: base = io.io_base; break;
 	    case IOSYS_JENSEN:	base = JENSEN_IO_BASE; break;
 	    case IOSYS_APECS:	base = APECS_IO_BASE; break;
 	    case IOSYS_CIA:	base = CIA_IO_BASE; break;
@@ -398,7 +419,8 @@ _ioperm (unsigned long from, unsigned long num, int turn_on)
 	  addr &= PAGE_MASK;
 	  len = port_to_cpu_addr (MAX_PORT, io.sys, 1) - addr;
 	  io.base =
-	    (unsigned long) __mmap (0, len, PROT_NONE, MAP_SHARED, fd, base);
+	    (unsigned long int) __mmap (0, len, PROT_NONE, MAP_SHARED,
+					fd, base);
 	  close (fd);
 	  if ((long) io.base == -1)
 	    return -1;
@@ -437,7 +459,7 @@ _iopl (unsigned int level)
 
 
 void
-_sethae (unsigned long addr)
+_sethae (unsigned long int addr)
 {
   if (!io.swp && init_iosys () < 0)
     return;
@@ -447,7 +469,7 @@ _sethae (unsigned long addr)
 
 
 void
-_outb (unsigned char b, unsigned long port)
+_outb (unsigned char b, unsigned long int port)
 {
   if (port >= MAX_PORT)
     return;
@@ -457,7 +479,7 @@ _outb (unsigned char b, unsigned long port)
 
 
 void
-_outw (unsigned short b, unsigned long port)
+_outw (unsigned short b, unsigned long int port)
 {
   if (port >= MAX_PORT)
     return;
@@ -467,7 +489,7 @@ _outw (unsigned short b, unsigned long port)
 
 
 void
-_outl (unsigned int b, unsigned long port)
+_outl (unsigned int b, unsigned long int port)
 {
   if (port >= MAX_PORT)
     return;
@@ -477,27 +499,27 @@ _outl (unsigned int b, unsigned long port)
 
 
 unsigned int
-_inb (unsigned long port)
+_inb (unsigned long int port)
 {
   return io.swp->inb (port);
 }
 
 
 unsigned int
-_inw (unsigned long port)
+_inw (unsigned long int port)
 {
   return io.swp->inw (port);
 }
 
 
 unsigned int
-_inl (unsigned long port)
+_inl (unsigned long int port)
 {
   return io.swp->inl (port);
 }
 
 
-unsigned long
+unsigned long int
 _bus_base(void)
 {
   if (!io.swp && init_iosys () < 0)
@@ -505,7 +527,7 @@ _bus_base(void)
   return io.bus_memory_base;
 }
 
-unsigned long
+unsigned long int
 _bus_base_sparse(void)
 {
   if (!io.swp && init_iosys () < 0)
diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_termios.h b/sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h
index cb030e4de4..eebe976ce1 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h
@@ -1,14 +1,14 @@
 /* The following corresponds to the values from the Linux 2.1.20 kernel.  */
 
-#define KERNEL_NCCS 19
+#define __KERNEL_NCCS 19
 
-struct kernel_termios
+struct __kernel_termios
   {
     tcflag_t c_iflag;		/* input mode flags */
     tcflag_t c_oflag;		/* output mode flags */
     tcflag_t c_cflag;		/* control mode flags */
     tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_cc[KERNEL_NCCS];	/* control characters */
+    cc_t c_cc[__KERNEL_NCCS];	/* control characters */
     cc_t c_line;		/* line discipline */
     speed_t c_ispeed;		/* input speed */
     speed_t c_ospeed;		/* output speed */
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/procfs.h b/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
index 03af029254..7bd6e6958d 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
@@ -94,7 +94,7 @@ struct elf_prpsinfo
     unsigned long int pr_flag;		/* Flags.  */
     unsigned int pr_uid;
     unsigned int pr_gid;
-    unsigned int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
     /* Lots missing */
     char pr_fname[16];			/* Filename of executable.  */
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index cf5f439bc4..71407062fb 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -17,7 +17,6 @@ semctl		-	semctl		4	__semctl	semctl
 
 osf_sigprocmask	-	osf_sigprocmask	2	__osf_sigprocmask
 
-getdents	-	getdents	3	__getdirentries	getdirentries
 getpeername	-	getpeername	3	__getpeername	getpeername
 getpriority	-	getpriority	2	__getpriority	getpriority
 mmap		-	mmap		6	__mmap		mmap
diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index 20923215ae..a6137d9ba8 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -20,7 +20,7 @@ else
 #include "confdefs.h"
 #include <linux/version.h>
 int main() {
-#if LINUX_VERSION_CODE <  ( *65536+ 0 *256+ 10) /* .0.10 */
+#if LINUX_VERSION_CODE <  (2 *65536+ 0 *256+ 10) /* 2.0.10 */
 eat flaming death
 #endif
 ; return 0; }
diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c
index 0504393e67..40b31617ef 100644
--- a/sysdeps/unix/sysv/linux/getdents.c
+++ b/sysdeps/unix/sysv/linux/getdents.c
@@ -16,10 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <alloca.h>
 #include <dirent.h>
 #include <stddef.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/param.h>
 #include <sys/types.h>
 
 #include <linux/posix_types.h>
@@ -52,8 +54,7 @@ struct kernel_dirent
    in the buffer.  Taking this number allows us to specify a correct
    number of bytes to read.  If we should be wrong, we can reset the
    file descriptor.  */
-int __getdirentries __P ((int fd, char *buf, size_t nbytes, off_t *basep));
-int
+ssize_t
 __getdirentries (fd, buf, nbytes, basep)
      int fd;
      char *buf;
@@ -62,32 +63,33 @@ __getdirentries (fd, buf, nbytes, basep)
 {
   off_t base = __lseek (fd, (off_t) 0, SEEK_CUR);
   size_t red_nbytes;
-  struct kernel_dirent *kdp;
+  struct kernel_dirent *skdp, *kdp;
   struct dirent *dp;
   int retval;
 
   red_nbytes = nbytes - (nbytes / (offsetof (struct dirent, d_name) + 3));
 
   dp = (struct dirent *) buf;
-  kdp = (struct kernel_dirent *) (buf + (nbytes - red_nbytes));
+  skdp = kdp = __alloca (red_nbytes);
 
   retval = __getdents (fd, (char *) kdp, red_nbytes);
 
-  while ((char *) kdp < buf + (nbytes - red_nbytes) + retval)
+  while ((char *) kdp < (char *) skdp + retval)
     {
+      const size_t size_diff = MAX (offsetof (struct dirent, d_name)
+				    - offsetof (struct kernel_dirent, d_name),
+				    __alignof__ (struct dirent));
       dp->d_ino = kdp->d_ino;
       dp->d_off = kdp->d_off;
-      dp->d_reclen = (kdp->d_reclen
-		      + (offsetof (struct dirent, d_name)
-			 - offsetof (struct kernel_dirent, d_name)));
+      dp->d_reclen = kdp->d_reclen + size_diff;
       dp->d_type = DT_UNKNOWN;
-      memmove (dp->d_name, kdp->d_name,
-	       kdp->d_reclen - offsetof (struct kernel_dirent, d_name));
+      memcpy (dp->d_name, kdp->d_name,
+	      kdp->d_reclen - offsetof (struct kernel_dirent, d_name));
 
       dp = (struct dirent *) (((char *) dp) + dp->d_reclen);
       kdp = (struct kernel_dirent *) (((char *) kdp) + kdp->d_reclen);
 
-      if ((char *) dp >= (char *) kdp)
+      if ((char *) dp >= buf + nbytes)
 	{
 	  /* Our heuristic failed.  We read too many entries.  Reset
 	     the stream.  */
@@ -99,7 +101,7 @@ __getdirentries (fd, buf, nbytes, basep)
   if (basep)
     *basep = base;
 
-  return (char *) dp - (char *) buf;
+  return (char *) dp - buf;
 }
 
 weak_alias (__getdirentries, getdirentries)
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 77c9ad3e85..2ecedd4b15 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -1,4 +1,4 @@
-ifeq ($(subdir), misc)
+ifeq ($(subdir),misc)
 sysdep_routines += ioperm iopl vm86
 sysdep_headers += sys/perm.h sys/vm86.h
 endif
diff --git a/sysdeps/unix/sysv/linux/kernel_termios.h b/sysdeps/unix/sysv/linux/sys/kernel_termios.h
index 3b2653b2cd..95349760f0 100644
--- a/sysdeps/unix/sysv/linux/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/sys/kernel_termios.h
@@ -1,13 +1,13 @@
 /* The following corresponds to the values from the Linux 2.1.20 kernel.  */
 
-#define KERNEL_NCCS 19
+#define __KERNEL_NCCS 19
 
-struct kernel_termios
+struct __kernel_termios
   {
     tcflag_t c_iflag;		/* input mode flags */
     tcflag_t c_oflag;		/* output mode flags */
     tcflag_t c_cflag;		/* control mode flags */
     tcflag_t c_lflag;		/* local mode flags */
     cc_t c_line;		/* line discipline */
-    cc_t c_cc[KERNEL_NCCS];	/* control characters */
+    cc_t c_cc[__KERNEL_NCCS];	/* control characters */
   };
diff --git a/sysdeps/unix/sysv/linux/sys/procfs.h b/sysdeps/unix/sysv/linux/sys/procfs.h
index e8d32390fa..a1190a348f 100644
--- a/sysdeps/unix/sysv/linux/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/sys/procfs.h
@@ -94,7 +94,7 @@ struct elf_prpsinfo
     unsigned long int pr_flag;		/* Flags.  */
     unsigned short int pr_uid;
     unsigned short int pr_gid;
-    unsigned short int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
     /* Lots missing */
     char pr_fname[16];			/* Filename of executable.  */
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c
index 2e8cb1cf79..9578c4b772 100644
--- a/sysdeps/unix/sysv/linux/tcgetattr.c
+++ b/sysdeps/unix/sysv/linux/tcgetattr.c
@@ -23,7 +23,7 @@
 /* The difference here is that the termios structure used in the
    kernel is not the same as we use in the libc.  Therefore we must
    translate it here.  */
-#include <kernel_termios.h>
+#include <sys/kernel_termios.h>
 
 /* Put the state of FD into *TERMIOS_P.  */
 int
@@ -31,7 +31,7 @@ __tcgetattr (fd, termios_p)
       int fd;
       struct termios *termios_p;
 {
-  struct kernel_termios k_termios;
+  struct __kernel_termios k_termios;
   int retval;
   size_t cnt;
 
@@ -48,7 +48,7 @@ __tcgetattr (fd, termios_p)
 #ifdef _HAVE_C_OSPEED
   termios_p->c_ospeed = k_termios.c_ospeed;
 #endif
-  for (cnt = 0; cnt < KERNEL_NCCS; ++cnt)
+  for (cnt = 0; cnt < __KERNEL_NCCS; ++cnt)
     termios_p->c_cc[cnt] = k_termios.c_cc[cnt];
 
   return retval;
diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
index 3bb3e9f5ec..6c128110f6 100644
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -24,7 +24,7 @@
 /* The difference here is that the termios structure used in the
    kernel is not the same as we use in the libc.  Therefore we must
    translate it here.  */
-#include <kernel_termios.h>
+#include <sys/kernel_termios.h>
 
 
 /* Set the state of FD to *TERMIOS_P.  */
@@ -34,7 +34,7 @@ tcsetattr (fd, optional_actions, termios_p)
      int optional_actions;
      const struct termios *termios_p;
 {
-  struct kernel_termios k_termios;
+  struct __kernel_termios k_termios;
   unsigned long int cmd;
   size_t cnt;
 
@@ -65,7 +65,7 @@ tcsetattr (fd, optional_actions, termios_p)
 #ifdef _HAVE_C_OSPEED
   k_termios.c_ospeed = termios_p->c_ospeed;
 #endif
-  for (cnt = 0; cnt < KERNEL_NCCS; ++cnt)
+  for (cnt = 0; cnt < __KERNEL_NCCS; ++cnt)
     k_termios.c_cc[cnt] = termios_p->c_cc[cnt];
 
   return __ioctl (fd, cmd, &k_termios);