summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-07-01 22:16:41 +0000
committerRoland McGrath <roland@gnu.org>1996-07-01 22:16:41 +0000
commit3776d592f117c8c5b0d2c37d265cb8ee2ac21695 (patch)
tree9cae15e988bc6b4eb1e2737db59bceaab58e0be7
parent7cbc698400bfe2a64f12b0cb703fda0fdecb5a59 (diff)
downloadglibc-3776d592f117c8c5b0d2c37d265cb8ee2ac21695.tar.gz
glibc-3776d592f117c8c5b0d2c37d265cb8ee2ac21695.tar.xz
glibc-3776d592f117c8c5b0d2c37d265cb8ee2ac21695.zip
Mon Jul 1 12:29:50 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
	* nss/Makefile (databases): Change host to hosts.
	* nss/host-lookup.c: Renamed to nss/hosts-lookup.c.
-rw-r--r--configure.in8
-rw-r--r--nss/Makefile2
-rw-r--r--nss/hosts-lookup.c (renamed from nss/host-lookup.c)0
-rw-r--r--nss/nss_files/files-hosts.c3
-rw-r--r--nss/nss_files/files-parse.c27
-rw-r--r--nss/nsswitch.c6
-rw-r--r--resolv/res_hconf.c20
-rw-r--r--string/string.h2
-rw-r--r--sunrpc/xdr.c93
-rw-r--r--sysdeps/alpha/dl-machine.h4
-rw-r--r--sysdeps/unix/alpha/sysdep.S2
-rw-r--r--sysdeps/unix/alpha/sysdep.h12
-rw-r--r--sysdeps/unix/sysv/linux/alpha/init-first.h12
-rw-r--r--sysdeps/unix/sysv/linux/i386/init-first.h13
-rw-r--r--sysdeps/unix/sysv/linux/init-first.c43
-rw-r--r--sysdeps/unix/sysv/linux/m68k/init-first.h12
16 files changed, 131 insertions, 128 deletions
diff --git a/configure.in b/configure.in
index 1d0d45c2e0..a8870c9c75 100644
--- a/configure.in
+++ b/configure.in
@@ -84,11 +84,11 @@ gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
   gnu_ld=yes gnu_as=yes ;;
 esac
 case "$host_os" in
+linux*ecoff*)
+  ;;
 gnu* | linux* | sysv4* | solaris2*)
-  # These systems always use the ELF format.
-  if test "$host_cpu" != alpha; then	# Linux/Alpha is not fully ELF yet
-    elf=yes
-  fi
+  # These systems (almost) always use the ELF format.
+  elf=yes
   ;;
 esac
 
diff --git a/nss/Makefile b/nss/Makefile
index bdf1651bb1..8e7a242344 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -28,7 +28,7 @@ distribute		:= nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
 routines		= nsswitch $(addsuffix -lookup,$(databases))
 
 # These are the databases that go through nss dispatch.
-databases		= proto service host network grp pwd rpc ethers
+databases		= proto service hosts network grp pwd rpc ethers
 
 # Specify rules for the nss_* modules.  We have some services.
 services		:= files dns
diff --git a/nss/host-lookup.c b/nss/hosts-lookup.c
index f511393372..f511393372 100644
--- a/nss/host-lookup.c
+++ b/nss/hosts-lookup.c
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index dad818c941..15f00f31ce 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -32,6 +32,7 @@ Cambridge, MA 02139, USA.  */
 #define ENTNAME		hostent
 #define DATAFILE	_PATH_HOSTS
 
+#define ENTDATA hostent_data
 struct hostent_data
   {
     unsigned char host_addr[16]; /* IPv4 or IPv6 address.  */
@@ -73,7 +74,7 @@ LINE_PARSER
     /* Illegal address: ignore line.  */
     return 0;
 
-  /* Store a pointer to the addressin the expected form.  */
+  /* Store a pointer to the address in the expected form.  */
   entdata->h_addr_ptrs[0] = entdata->host_addr;
   entdata->h_addr_ptrs[1] = NULL;
   result->h_addr_list = entdata->h_addr_ptrs;
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index de456995a2..be35ae1a8a 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -33,17 +33,31 @@ Cambridge, MA 02139, USA.  */
 
 struct parser_data
   {
-    struct CONCAT(ENTNAME,_data) entdata;
+#ifdef ENTDATA
+    struct ENTDATA entdata;
+#define ENTDATA_DECL(data) struct ENTDATA *const entdata = &data->entdata
+#else
+#define ENTDATA_DECL(data)
+#endif
     char linebuffer[0];
   };
 
+#ifdef ENTDATA
+/* The function can't be exported, because the entdata structure
+   is defined only in files-foo.c.  */
+#define parser_stclass static inline
+#else
+/* Export the line parser function so it can be used in nss_db.  */
+#define parser_stclass /* Global */
+#define parse_line CONCAT(_nss_files_parse_,ENTNAME)
+#endif
+
 #define LINE_PARSER(BODY)						      \
-static inline int							      \
+parser_stclass int							      \
 parse_line (char *line, struct STRUCTURE *result,			      \
 	    struct parser_data *data, int datalen)			      \
 {									      \
-  struct CONCAT(ENTNAME,_data) *const entdata __attribute__ ((unused))	      \
-    = &data->entdata;		      					      \
+  ENTDATA_DECL (data);							      \
   BODY;									      \
   TRAILING_LIST_PARSER;							      \
   return 1;								      \
@@ -107,9 +121,10 @@ parse_list (char *line, struct parser_data *data, int datalen)
   char *eol, **list, **p;
 
   /* Find the end of the line buffer.  */
-  eol = strchr (line, '\0') + 1;
+  eol = strchr (data->linebuffer, '\0') + 1;
   /* Adjust the pointer so it is aligned for storing pointers.  */
-  eol += (eol - (char *) 0) % __alignof__ (char *);
+  eol += __alignof__ (char *) - 1;
+  eol -= (eol - (char *) 0) % __alignof__ (char *);
   /* We will start the storage here for the vector of pointers.  */
   list = (char **) eol;
 
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 9b6c4eb12f..c748eb1bef 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -249,8 +249,8 @@ nss_lookup_function (service_user *ni, const char *fct_name)
 		       + strlen (fct_name) + 1);
       char name[namlen];
       struct link_map *map = ni->library->lib_handle;
-      Elf32_Addr loadbase;
-      const Elf32_Sym *ref = NULL;
+      ElfW(Addr) loadbase;
+      const ElfW(Sym) *ref = NULL;
       void get_sym (void)
 	{
 	  struct link_map *scope[2] = { map, NULL };
@@ -397,7 +397,7 @@ nss_parse_service_list (const char *line)
   while (1)
     {
       service_user *new_service;
-      char *name;
+      const char *name;
 
       while (isspace (line[0]))
 	++line;
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index b08dd3ced7..fbf74d4125 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -69,24 +69,6 @@ static struct cmd {
 };
 
 
-/*
- * Why isn't this in stdlib?
- */
-char *
-strndup (const char * s, size_t n)
-{
-  char * retval;
-
-  retval = malloc (n + 1);
-  if (!retval)
-    return retval;
-
-  memcpy (retval, s, n);
-  retval[n] = '\0';		/* ensure return value is terminated */
-  return retval;
-}
-
-
 /* Skip white space.  */
 static const char *
 skip_ws (const char * str)
@@ -194,7 +176,7 @@ arg_trimdomain_list (const char * fname, int line_num, const char * args,
 	  return 0;
 	}
       _res_hconf.trimdomain[_res_hconf.num_trimdomains++] =
-	strndup (start, len);
+	  strndup (start, len);
       args = skip_ws (args);
       switch (*args)
 	{
diff --git a/string/string.h b/string/string.h
index 7dbcc41c22..da26a6f496 100644
--- a/string/string.h
+++ b/string/string.h
@@ -108,7 +108,7 @@ extern char *strndup __P ((__const char *__string, size_t __n));
 ({									      \
   __const char *__old = (s);						      \
   char *__new;								      \
-  size_t __len = strnlen (__old);					      \
+  size_t __len = strnlen (__old, (n));					      \
   __new = memcpy (__builtin_alloca (__len + 1), __old, __len);		      \
   __new[__len] = '\0';							      \
   __new;								      \
diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c
index a5241a5120..a5b5e68d75 100644
--- a/sunrpc/xdr.c
+++ b/sunrpc/xdr.c
@@ -42,6 +42,7 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
  */
 
 #include <stdio.h>
+#include <limits.h>
 char *malloc();
 
 #include <rpc/types.h>
@@ -99,34 +100,28 @@ xdr_int(xdrs, ip)
 	(void) (xdr_short(xdrs, (short *)ip));
 	return (xdr_long(xdrs, (long *)ip));
 #else
-	if (sizeof (int) < sizeof (long)) {
-		long l;
-
-		switch (xdrs->x_op) {
-		      case XDR_ENCODE:
-			l = (long) *ip;
-			return XDR_PUTLONG(xdrs, &l);
-
-		      case XDR_DECODE:
-			if (!XDR_GETLONG(xdrs, &l)) {
-				return FALSE;
-			}
-			*ip = (int) l;
-			return TRUE;
-		}
-	} else if (sizeof (int) == sizeof (long)) {
-		return (xdr_long(xdrs, (long *)ip));
-	} else if (sizeof (int) == sizeof (short)) {
-		return (xdr_short(xdrs, (short *)ip));
-	} else {
-	  abort ();		/* roland@gnu */
-#if 0
-		/* force unresolved reference (link-time error): */
-		extern unexpected_sizes_in_xdr_int ();
+# if INT_MAX < LONG_MAX
+	long l;
 
-		unexpected_sizes_in_xdr_int();
-#endif
+	switch (xdrs->x_op) {
+	      case XDR_ENCODE:
+		l = (long) *ip;
+		return XDR_PUTLONG(xdrs, &l);
+
+	      case XDR_DECODE:
+		if (!XDR_GETLONG(xdrs, &l)) {
+			return FALSE;
+		}
+		*ip = (int) l;
+		return TRUE;
 	}
+# elif INT_MAX == LONG_MAX
+	return xdr_long(xdrs, (long *)ip);
+# elif INT_MAX == SHRT_MAX
+	return xdr_short(xdrs, (short *)ip);
+# else
+#	error unexpected integer sizes in_xdr_int()
+# endif
 #endif
 }
 
@@ -142,34 +137,28 @@ xdr_u_int(xdrs, up)
 	(void) (xdr_short(xdrs, (short *)up));
 	return (xdr_u_long(xdrs, (u_long *)up));
 #else
-	if (sizeof (u_int) < sizeof (u_long)) {
-		u_long l;
-
-		switch (xdrs->x_op) {
-		      case XDR_ENCODE:
-			l = (u_long) *up;
-			return XDR_PUTLONG(xdrs, &l);
-
-		      case XDR_DECODE:
-			if (!XDR_GETLONG(xdrs, &l)) {
-				return FALSE;
-			}
-			*up = (u_int) l;
-			return TRUE;
-		}
-	} else if (sizeof (u_int) == sizeof (u_long)) {
-		return (xdr_u_long(xdrs, (u_long *)up));
-	} else if (sizeof (u_int) == sizeof (u_short)) {
-		return (xdr_short(xdrs, (short *)up));
-	} else {
-	  abort ();		/* drepper@gnu */
-#if 0
-		/* force unresolved reference (link-time error): */
-		extern unexpected_sizes_in_xdr_u_int ();
+# if UINT_MAX < ULONG_MAX
+	u_long l;
 
-		unexpected_sizes_in_xdr_u_int();
-#endif
+	switch (xdrs->x_op) {
+	      case XDR_ENCODE:
+		l = (u_long) *up;
+		return XDR_PUTLONG(xdrs, &l);
+
+	      case XDR_DECODE:
+		if (!XDR_GETLONG(xdrs, &l)) {
+			return FALSE;
+		}
+		*up = (u_int) l;
+		return TRUE;
 	}
+# elif UINT_MAX == ULONG_MAX
+	return xdr_u_long(xdrs, (u_long *)up);
+# elif UINT_MAX == USHRT_MAX
+	return xdr_short(xdrs, (short *)up);
+# else
+#	error unexpected integer sizes in_xdr_u_int()
+# endif
 #endif
 }
 
diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h
index bc80b5985d..a276551b00 100644
--- a/sysdeps/alpha/dl-machine.h
+++ b/sysdeps/alpha/dl-machine.h
@@ -106,7 +106,7 @@ elf_alpha_fix_plt(struct link_map *l,
   if (edisp >= -0x100000 && edisp < 0x100000)
     {
       /* If we are in range, use br to perfect branch prediction and
-	 elide the dependancy on the address load.  This case happens,
+	 elide the dependency on the address load.  This case happens,
 	 e.g., when a shared library call is resolved to the same library.  */
 
       int hi, lo;
@@ -179,7 +179,7 @@ elf_machine_rela (struct link_map *map,
 
       if (resolve)
 	{
-	  loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr, 
+	  loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr,
 				r_info == R_ALPHA_JMP_SLOT);
 	}
       else
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S
index 3e7666ff61..6540b80af6 100644
--- a/sysdeps/unix/alpha/sysdep.S
+++ b/sysdeps/unix/alpha/sysdep.S
@@ -26,10 +26,10 @@ Cambridge, MA 02139, USA.  */
 #endif
 
 LEAF(__syscall_error, 0)
+	ldgp	gp, 0(t12)
 	.prologue 1
 
 	/* Store return value in errno... */
-	ldgp	gp, 0(t12)
 	stl	v0, errno
 
 	/* And just kick back a -1.  */
diff --git a/sysdeps/unix/alpha/sysdep.h b/sysdeps/unix/alpha/sysdep.h
index 4b3f9aa5d8..72d84047c2 100644
--- a/sysdeps/unix/alpha/sysdep.h
+++ b/sysdeps/unix/alpha/sysdep.h
@@ -99,22 +99,12 @@ name/**/:					\
 
 #undef PSEUDO_END
 
-#ifdef PIC
-/* When building a shared library, we can use a branch since the text
-   section of the library is much smaller than 4MB.  If we ever break
-   this assumption, the linker will tell us.  */
-# define PSEUDO_END(sym)			\
-1996:						\
-    br		zero, __syscall_error;		\
-    END(sym)
-#else
-# define PSEUDO_END(sym)			\
+#define PSEUDO_END(sym)				\
 1996:						\
     br		gp, 2f;				\
 2:  ldgp	gp, 0(gp);			\
     jmp		zero, __syscall_error;		\
     END(sym)
-#endif
 
 #define r0	v0
 #define r1	a4
diff --git a/sysdeps/unix/sysv/linux/alpha/init-first.h b/sysdeps/unix/sysv/linux/alpha/init-first.h
new file mode 100644
index 0000000000..c27c589a28
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/init-first.h
@@ -0,0 +1,12 @@
+/* This fragment is invoked in the stack context of program start.
+   Its job is to set up a pointer to argc as an argument, pass
+   control to `INIT', and, if necessary, clean up after the call
+   to leave the stack in the same condition it was found in.  */
+
+#define SYSDEP_CALL_INIT(NAME, INIT)	\
+    asm(".globl " #NAME "\n"		\
+	#NAME ":\n\t"			\
+	"ldgp $29, 0($27)\n\t"		\
+	".prologue 1\n\t"		\
+	"mov $30, $16\n\t"		\
+	"br $31, " #INIT "..ng");
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.h b/sysdeps/unix/sysv/linux/i386/init-first.h
new file mode 100644
index 0000000000..f42d7f2533
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/init-first.h
@@ -0,0 +1,13 @@
+/* This fragment is invoked in the stack context of program start.
+   Its job is to set up a pointer to argc as an argument, pass
+   control to `INIT', and, if necessary, clean up after the call
+   to leave the stack in the same condition it was found in.  */
+
+#define SYSDEP_CALL_INIT(NAME, INIT)	\
+    asm(".globl " #NAME "\n\t"		\
+	#NAME ":\n\t"			\
+	"lea 4(%esp), %eax\n\t"		\
+	"pushl %eax\n\t"		\
+	"call " #INIT "\n\t"		\
+	"popl %eax\n\t"			\
+	"ret");
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index 6d974ea1e6..a63200c1ae 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -19,23 +19,22 @@ Cambridge, MA 02139, USA.  */
 
 #include <unistd.h>
 #include <sysdep.h>
-#include "fpu_control.h"
-
-/* This code is mostly the same for all machines.  This version works at
-   least for i386 and m68k, and probably any CISCy machine with a normal
-   stack arrangement.  */
+#include <fpu_control.h>
+#include "init-first.h"
 
 extern void __libc_init (int, char **, char **);
 extern void __libc_global_ctors (void);
 
+/* The function is called from assembly stubs the compiler can't see.  */
+static void init (void *) __attribute__ ((unused));
 
 static void
-init (int *data)
+init (void *data)
 {
   extern int __personality (int);
 
-  int argc = *data;
-  char **argv = (void *) (data + 1);
+  int argc = *(long *)data;
+  char **argv = (char **)data + 1;
   char **envp = &argv[argc + 1];
 
   /* The `personality' system call takes one argument that chooses the
@@ -50,33 +49,23 @@ init (int *data)
 
   __environ = envp;
   __libc_init (argc, argv, envp);
+
+#ifdef PIC
+  __libc_global_ctors ();
+#endif
 }
 
 #ifdef PIC
-/* This function is called to initialize the shared C library.
-   It is called just before the user _start code from i386/elf/start.S,
-   with the stack set up as that code gets it.  */
 
-/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
-   pointer in the dynamic section based solely on that.  It is convention
-   for this function to be in the `.init' section, but the symbol name is
-   the only thing that really matters!!  */
-/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+SYSDEP_CALL_INIT(_init, init);
 
 void
-_init (int argc, ...)
+__libc_init_first (void)
 {
-  init (&argc);
-
-  __libc_global_ctors ();
 }
-#endif
 
+#else
+
+SYSDEP_CALL_INIT(__libc_init_first, init);
 
-void
-__libc_init_first (int argc __attribute__ ((unused)), ...)
-{
-#ifndef PIC
-  init (&argc);
 #endif
-}
diff --git a/sysdeps/unix/sysv/linux/m68k/init-first.h b/sysdeps/unix/sysv/linux/m68k/init-first.h
new file mode 100644
index 0000000000..7d8c320b0a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/init-first.h
@@ -0,0 +1,12 @@
+/* This fragment is invoked in the stack context of program start.
+   Its job is to set up a pointer to argc as an argument, pass
+   control to `INIT', and, if necessary, clean up after the call
+   to leave the stack in the same condition it was found in.  */
+
+#define SYSDEP_CALL_INIT(NAME, INIT)	\
+    asm(".globl " #NAME "\n\t"		\
+	#NAME ":\n\t"			\
+	"pea %sp@(4)\n\t"		\
+	"jbsr " #INIT "\n\t"		\
+	"addq #4,%sp\n\t"		\
+	"rts");