Mon Jul 1 12:29:50 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
authorRoland McGrath <roland@gnu.org>
Mon, 1 Jul 1996 22:16:41 +0000 (22:16 +0000)
committerRoland McGrath <roland@gnu.org>
Mon, 1 Jul 1996 22:16:41 +0000 (22:16 +0000)
* nss/Makefile (databases): Change host to hosts.
* nss/host-lookup.c: Renamed to nss/hosts-lookup.c.

16 files changed:
configure.in
nss/Makefile
nss/hosts-lookup.c [moved from nss/host-lookup.c with 100% similarity]
nss/nss_files/files-hosts.c
nss/nss_files/files-parse.c
nss/nsswitch.c
resolv/res_hconf.c
string/string.h
sunrpc/xdr.c
sysdeps/alpha/dl-machine.h
sysdeps/unix/alpha/sysdep.S
sysdeps/unix/alpha/sysdep.h
sysdeps/unix/sysv/linux/alpha/init-first.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/i386/init-first.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/init-first.c
sysdeps/unix/sysv/linux/m68k/init-first.h [new file with mode: 0644]

index 1d0d45c..a8870c9 100644 (file)
@@ -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
 
index bdf1651..8e7a242 100644 (file)
@@ -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
similarity index 100%
rename from nss/host-lookup.c
rename to nss/hosts-lookup.c
index dad818c..15f00f3 100644 (file)
@@ -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;
index de45699..be35ae1 100644 (file)
@@ -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;
 
index 9b6c4eb..c748eb1 100644 (file)
@@ -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;
index b08dd3c..fbf74d4 100644 (file)
@@ -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)
        {
index 7dbcc41..da26a6f 100644 (file)
@@ -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;                                                                     \
index a5241a5..a5b5e68 100644 (file)
@@ -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
 }
 
index bc80b59..a276551 100644 (file)
@@ -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
index 3e7666f..6540b80 100644 (file)
@@ -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.  */
index 4b3f9aa..72d8404 100644 (file)
@@ -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 (file)
index 0000000..c27c589
--- /dev/null
@@ -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 (file)
index 0000000..f42d7f2
--- /dev/null
@@ -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");
index 6d974ea..a63200c 100644 (file)
@@ -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 (file)
index 0000000..7d8c320
--- /dev/null
@@ -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");