* nss/Makefile (databases): Change host to hosts.
* nss/host-lookup.c: Renamed to nss/hosts-lookup.c.
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
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
#define ENTNAME hostent
#define DATAFILE _PATH_HOSTS
+#define ENTDATA hostent_data
struct hostent_data
{
unsigned char host_addr[16]; /* IPv4 or IPv6 address. */
/* 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;
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; \
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;
+ 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 };
while (1)
{
service_user *new_service;
- char *name;
+ const char *name;
while (isspace (line[0]))
++line;
};
-/*
- * 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)
return 0;
}
_res_hconf.trimdomain[_res_hconf.num_trimdomains++] =
- strndup (start, len);
+ strndup (start, len);
args = skip_ws (args);
switch (*args)
{
({ \
__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; \
*/
#include <stdio.h>
+#include <limits.h>
char *malloc();
#include <rpc/types.h>
(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
}
(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
}
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;
if (resolve)
{
- loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr,
+ loadbase = (*resolve)(&sym, (Elf64_Addr)reloc_addr,
r_info == R_ALPHA_JMP_SLOT);
}
else
#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. */
#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
--- /dev/null
+/* 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");
--- /dev/null
+/* 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");
#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
__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
-}
--- /dev/null
+/* 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");