about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/elf/start.S4
-rw-r--r--sysdeps/posix/ttyname.c3
-rw-r--r--sysdeps/posix/ttyname_r.c3
-rw-r--r--sysdeps/unix/getlogin.c36
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/ioperm.c46
-rw-r--r--sysdeps/unix/sysv/linux/netinet/in.h14
-rw-r--r--sysdeps/unix/sysv/linux/sys/procfs.h1
8 files changed, 66 insertions, 43 deletions
diff --git a/sysdeps/alpha/elf/start.S b/sysdeps/alpha/elf/start.S
index c534d6987b..596cea6265 100644
--- a/sysdeps/alpha/elf/start.S
+++ b/sysdeps/alpha/elf/start.S
@@ -20,9 +20,11 @@ Cambridge, MA 02139, USA.  */
 #include <sysdep.h>
 
 	.text
-	.globl __start
+	.globl _start	/* what ELF wants */
+	.globl __start	/* for backwards (ECOFF) comatibility */
 	.align 3
 	.ent __start, 0
+_start:
 __start:
 	.frame fp, 0, zero
 	mov	zero, fp
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
index b0650b38b0..7c7ed2428a 100644
--- a/sysdeps/posix/ttyname.c
+++ b/sysdeps/posix/ttyname.c
@@ -44,6 +44,9 @@ DEFUN(ttyname, (fd), int fd)
   struct dirent *d;
   int save = errno;
 
+  if (!__isatty (fd))
+    return NULL;
+
   if (fstat (fd, &st) < 0)
     return NULL;
   mydev = st.st_dev;
diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c
index a05dbd5be3..e6172f1c97 100644
--- a/sysdeps/posix/ttyname_r.c
+++ b/sysdeps/posix/ttyname_r.c
@@ -54,6 +54,9 @@ __ttyname_r (fd, buf, buflen)
       return -1;
     }
 
+  if (!__isatty (fd))
+    return -1;
+
   if (fstat (fd, &st) < 0)
     return -1;
   mydev = st.st_dev;
diff --git a/sysdeps/unix/getlogin.c b/sysdeps/unix/getlogin.c
index 5a8ad96df2..e23ffa46f5 100644
--- a/sysdeps/unix/getlogin.c
+++ b/sysdeps/unix/getlogin.c
@@ -34,25 +34,21 @@ getlogin (void)
   char tty_pathname[2 + 2 * NAME_MAX];
   char *real_tty_path = tty_pathname;
   char *result = NULL;
-  static struct utmp_data utmp_data = { ut_fd: -1 };
+  struct utmp_data utmp_data = { ut_fd: -1 };
+  static char name[UT_NAMESIZE + 1];
   struct utmp *ut, line;
 
-  {
-    int err = 0;
-    int d = __open ("/dev/tty", 0);
-    if (d < 0)
-      return NULL;
-
-    if (__ttyname_r (d, real_tty_path, sizeof (tty_pathname)) < 0)
-      err = errno;
-    (void) close (d);
-
-    if (err != 0)
-      {
-	errno = err;
-	return NULL;
-      }
-  }
+  /* Get name of tty connected to fd 0.  Return NULL if not a tty or
+     if fd 0 isn't open.  Note that a lot of documentation says that
+     getlogin() is based on the controlling terminal---what they
+     really mean is "the terminal connected to standard input".  The
+     getlogin() implementation of DEC Unix, SunOS, Solaris, HP-UX all
+     return NULL if fd 0 has been closed, so this is the compatible
+     thing to do.  Note that ttyname(open("/dev/tty")) on those
+     systems returns /dev/tty, so that is not a possible solution for
+     getlogin().  */
+  if (__ttyname_r (0, real_tty_path, sizeof (tty_pathname)) < 0)
+    return NULL;
 
   real_tty_path += 5;		/* Remove "/dev/".  */
 
@@ -66,7 +62,11 @@ getlogin (void)
       result = NULL;
     }
   else
-    result = ut->ut_line;
+    {
+      strncpy (name, ut->ut_user, UT_NAMESIZE);
+      name[UT_NAMESIZE] = '\0';
+      result = name;
+    }
 
   __endutent_r (&utmp_data);
 
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 5f6b6b00ca..7d83718e5c 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -3,7 +3,7 @@ sysdep_routines += sysctl clone
 
 sysdep_headers += sys/mount.h sys/sysinfo.h sys/acct.h sys/sysctl.h \
 		  sys/module.h sys/io.h sys/klog.h sys/kdaemon.h \
-		  sys/user.h syscall-list.h sys/sysmacros.h
+		  sys/user.h syscall-list.h sys/sysmacros.h sys/procfs.h
 
 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
 $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/syscall.h
diff --git a/sysdeps/unix/sysv/linux/alpha/ioperm.c b/sysdeps/unix/sysv/linux/alpha/ioperm.c
index 56331cb596..d24eabe473 100644
--- a/sysdeps/unix/sysv/linux/alpha/ioperm.c
+++ b/sysdeps/unix/sysv/linux/alpha/ioperm.c
@@ -59,14 +59,16 @@ I/O address space that's 512MB large!).  */
  * so the following defines apply to LCA as well.
  */
 #define APECS_IO_BASE		(0xfffffc01c0000000UL)
+#define APECS_SPARSE_MEM	(0xfffffc0200000000UL)
 #define APECS_DENSE_MEM		(0xfffffc0300000000UL)
 
-#define ALCOR_IO_BASE		(0xfffffc8580000000UL)
-#define ALCOR_DENSE_MEM		(0xfffffc8600000000UL)
+#define CIA_IO_BASE		(0xfffffc8580000000UL)
+#define CIA_SPARSE_MEM		(0xfffffc8000000000UL)
+#define CIA_DENSE_MEM		(0xfffffc8600000000UL)
 
 
 enum {
-  IOSYS_JENSEN = 0, IOSYS_APECS = 1, IOSYS_ALCOR = 2
+  IOSYS_JENSEN = 0, IOSYS_APECS = 1, IOSYS_CIA = 2
 } iosys_t;
 
 struct ioswtch {
@@ -83,18 +85,19 @@ static struct platform {
   const char	*name;
   int		io_sys;
   unsigned long	bus_memory_base;
+  unsigned long	sparse_bus_memory_base;
 } platform[] = {
-  {"Alcor",	IOSYS_ALCOR,	ALCOR_DENSE_MEM},
-  {"Avanti",	IOSYS_APECS,	APECS_DENSE_MEM},
-  {"Cabriolet",	IOSYS_APECS,	APECS_DENSE_MEM},
-  {"EB164",	IOSYS_ALCOR,	ALCOR_DENSE_MEM},
-  {"EB64+",	IOSYS_APECS,	APECS_DENSE_MEM},
-  {"EB66",	IOSYS_APECS,	APECS_DENSE_MEM},	/* LCA same as APECS */
-  {"EB66P",	IOSYS_APECS,	APECS_DENSE_MEM},	/* LCA same as APECS */
-  {"Jensen",	IOSYS_JENSEN,	JENSEN_MEM},
-  {"Mikasa",	IOSYS_APECS,	APECS_DENSE_MEM},
-  {"Mustang",	IOSYS_APECS,	APECS_DENSE_MEM},
-  {"Noname",	IOSYS_APECS,	APECS_DENSE_MEM},	/* LCA same as APECS */
+  {"Alcor",	IOSYS_CIA,	CIA_DENSE_MEM,		CIA_SPARSE_MEM},
+  {"Avanti",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"Cabriolet",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"EB164",	IOSYS_CIA,	CIA_DENSE_MEM,		CIA_SPARSE_MEM},
+  {"EB64+",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"EB66",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"EB66P",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"Jensen",	IOSYS_JENSEN,	JENSEN_MEM,		JENSEN_MEM},
+  {"Mikasa",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"Mustang",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
+  {"Noname",	IOSYS_APECS,	APECS_DENSE_MEM,	APECS_SPARSE_MEM},
 };
 
 
@@ -109,6 +112,7 @@ static struct {
 } io;
 
 static unsigned long bus_memory_base = -1;
+static unsigned long sparse_bus_memory_base = -1;
 
 extern void __sethae (unsigned long);	/* we can't use asm/io.h */
 
@@ -256,7 +260,7 @@ DCL_IN(jensen, inb, JENSEN)
 DCL_IN(jensen, inw, JENSEN)
 DCL_IN(jensen, inl, JENSEN)
 
-/* The APECS functions are also used for ALCOR since they are
+/* The APECS functions are also used for CIA since they are
    identical.  */
 
 DCL_SETHAE(apecs, APECS)
@@ -332,6 +336,7 @@ init_iosys (void)
       if (strcmp (platform[i].name, systype) == 0)
 	{
 	  bus_memory_base = platform[i].bus_memory_base;
+	  sparse_bus_memory_base = platform[i].sparse_bus_memory_base;
 	  io.sys = platform[i].io_sys;
 	  if (io.sys == IOSYS_JENSEN)
 	    io.swp = &ioswtch[0];
@@ -382,7 +387,7 @@ _ioperm (unsigned long from, unsigned long num, int turn_on)
 	    {
 	    case IOSYS_JENSEN:	base = JENSEN_IO_BASE; break;
 	    case IOSYS_APECS:	base = APECS_IO_BASE; break;
-	    case IOSYS_ALCOR:	base = ALCOR_IO_BASE; break;
+	    case IOSYS_CIA:	base = CIA_IO_BASE; break;
 	    default:
 	      errno = ENODEV;
 	      return -1;
@@ -498,6 +503,14 @@ _bus_base(void)
   return bus_memory_base;
 }
 
+unsigned long
+_bus_base_sparse(void)
+{
+  if (!io.swp && init_iosys () < 0)
+    return -1;
+  return sparse_bus_memory_base;
+}
+
 weak_alias (_sethae, sethae);
 weak_alias (_ioperm, ioperm);
 weak_alias (_iopl, iopl);
@@ -508,3 +521,4 @@ weak_alias (_outb, outb);
 weak_alias (_outw, outw);
 weak_alias (_outl, outl);
 weak_alias (_bus_base, bus_base);
+weak_alias (_bus_base_sparse, bus_base_sparse);
diff --git a/sysdeps/unix/sysv/linux/netinet/in.h b/sysdeps/unix/sysv/linux/netinet/in.h
index 9ba2bdd5cb..9c128a16a3 100644
--- a/sysdeps/unix/sysv/linux/netinet/in.h
+++ b/sysdeps/unix/sysv/linux/netinet/in.h
@@ -81,6 +81,8 @@ struct ip_opts
     char ip_opts[40];		/* Actually variable in size.  */
   };
 
+__BEGIN_DECLS
+
 /* Functions to convert between host and network byte order.  */
 
 extern unsigned long int ntohl __P ((unsigned long int));
@@ -88,6 +90,11 @@ extern unsigned short int ntohs __P ((unsigned short int));
 extern unsigned long int htonl __P ((unsigned long int));
 extern unsigned short int htons __P ((unsigned short int));
 
+/* Bind socket FD to a privileged IP address SIN.  */
+extern int bindresvport __P ((int __fd, struct sockaddr_in * __sin));
+
+__END_DECLS
+
 #include <endian.h>
 
 #if __BYTE_ORDER == __BIG_ENDIAN
@@ -103,11 +110,4 @@ extern unsigned short int htons __P ((unsigned short int));
 #define	htons(x)	(x)
 #endif
 
-__BEGIN_DECLS
-
-/* Bind socket FD to a privileged IP address SIN.  */
-extern int bindresvport __P((int __fd, struct sockaddr_in * __sin));
-
-__END_DECLS
-
 #endif	/* netinet/in.h */
diff --git a/sysdeps/unix/sysv/linux/sys/procfs.h b/sysdeps/unix/sysv/linux/sys/procfs.h
new file mode 100644
index 0000000000..9c1079d7b9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sys/procfs.h
@@ -0,0 +1 @@
+#include <linux/elfcore.h>