1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

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.
This commit is contained in:
Roland McGrath
1996-07-01 22:16:41 +00:00
parent 7cbc698400
commit 3776d592f1
16 changed files with 127 additions and 124 deletions

View File

@ -84,11 +84,11 @@ gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
gnu_ld=yes gnu_as=yes ;; gnu_ld=yes gnu_as=yes ;;
esac esac
case "$host_os" in case "$host_os" in
linux*ecoff*)
;;
gnu* | linux* | sysv4* | solaris2*) gnu* | linux* | sysv4* | solaris2*)
# These systems always use the ELF format. # These systems (almost) always use the ELF format.
if test "$host_cpu" != alpha; then # Linux/Alpha is not fully ELF yet
elf=yes elf=yes
fi
;; ;;
esac esac

View File

@ -28,7 +28,7 @@ distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
routines = nsswitch $(addsuffix -lookup,$(databases)) routines = nsswitch $(addsuffix -lookup,$(databases))
# These are the databases that go through nss dispatch. # 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. # Specify rules for the nss_* modules. We have some services.
services := files dns services := files dns

View File

@ -32,6 +32,7 @@ Cambridge, MA 02139, USA. */
#define ENTNAME hostent #define ENTNAME hostent
#define DATAFILE _PATH_HOSTS #define DATAFILE _PATH_HOSTS
#define ENTDATA hostent_data
struct hostent_data struct hostent_data
{ {
unsigned char host_addr[16]; /* IPv4 or IPv6 address. */ unsigned char host_addr[16]; /* IPv4 or IPv6 address. */

View File

@ -33,17 +33,31 @@ Cambridge, MA 02139, USA. */
struct parser_data 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]; 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) \ #define LINE_PARSER(BODY) \
static inline int \ parser_stclass int \
parse_line (char *line, struct STRUCTURE *result, \ parse_line (char *line, struct STRUCTURE *result, \
struct parser_data *data, int datalen) \ struct parser_data *data, int datalen) \
{ \ { \
struct CONCAT(ENTNAME,_data) *const entdata __attribute__ ((unused)) \ ENTDATA_DECL (data); \
= &data->entdata; \
BODY; \ BODY; \
TRAILING_LIST_PARSER; \ TRAILING_LIST_PARSER; \
return 1; \ return 1; \
@ -107,9 +121,10 @@ parse_list (char *line, struct parser_data *data, int datalen)
char *eol, **list, **p; char *eol, **list, **p;
/* Find the end of the line buffer. */ /* 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. */ /* 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. */ /* We will start the storage here for the vector of pointers. */
list = (char **) eol; list = (char **) eol;

View File

@ -249,8 +249,8 @@ nss_lookup_function (service_user *ni, const char *fct_name)
+ strlen (fct_name) + 1); + strlen (fct_name) + 1);
char name[namlen]; char name[namlen];
struct link_map *map = ni->library->lib_handle; struct link_map *map = ni->library->lib_handle;
Elf32_Addr loadbase; ElfW(Addr) loadbase;
const Elf32_Sym *ref = NULL; const ElfW(Sym) *ref = NULL;
void get_sym (void) void get_sym (void)
{ {
struct link_map *scope[2] = { map, NULL }; struct link_map *scope[2] = { map, NULL };
@ -397,7 +397,7 @@ nss_parse_service_list (const char *line)
while (1) while (1)
{ {
service_user *new_service; service_user *new_service;
char *name; const char *name;
while (isspace (line[0])) while (isspace (line[0]))
++line; ++line;

View 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. */ /* Skip white space. */
static const char * static const char *
skip_ws (const char * str) skip_ws (const char * str)

View File

@ -108,7 +108,7 @@ extern char *strndup __P ((__const char *__string, size_t __n));
({ \ ({ \
__const char *__old = (s); \ __const char *__old = (s); \
char *__new; \ char *__new; \
size_t __len = strnlen (__old); \ size_t __len = strnlen (__old, (n)); \
__new = memcpy (__builtin_alloca (__len + 1), __old, __len); \ __new = memcpy (__builtin_alloca (__len + 1), __old, __len); \
__new[__len] = '\0'; \ __new[__len] = '\0'; \
__new; \ __new; \

View File

@ -42,6 +42,7 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
*/ */
#include <stdio.h> #include <stdio.h>
#include <limits.h>
char *malloc(); char *malloc();
#include <rpc/types.h> #include <rpc/types.h>
@ -99,7 +100,7 @@ xdr_int(xdrs, ip)
(void) (xdr_short(xdrs, (short *)ip)); (void) (xdr_short(xdrs, (short *)ip));
return (xdr_long(xdrs, (long *)ip)); return (xdr_long(xdrs, (long *)ip));
#else #else
if (sizeof (int) < sizeof (long)) { # if INT_MAX < LONG_MAX
long l; long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
@ -114,19 +115,13 @@ xdr_int(xdrs, ip)
*ip = (int) l; *ip = (int) l;
return TRUE; return TRUE;
} }
} else if (sizeof (int) == sizeof (long)) { # elif INT_MAX == LONG_MAX
return (xdr_long(xdrs, (long *)ip)); return xdr_long(xdrs, (long *)ip);
} else if (sizeof (int) == sizeof (short)) { # elif INT_MAX == SHRT_MAX
return (xdr_short(xdrs, (short *)ip)); return xdr_short(xdrs, (short *)ip);
} else { # else
abort (); /* roland@gnu */ # error unexpected integer sizes in_xdr_int()
#if 0
/* force unresolved reference (link-time error): */
extern unexpected_sizes_in_xdr_int ();
unexpected_sizes_in_xdr_int();
# endif # endif
}
#endif #endif
} }
@ -142,7 +137,7 @@ xdr_u_int(xdrs, up)
(void) (xdr_short(xdrs, (short *)up)); (void) (xdr_short(xdrs, (short *)up));
return (xdr_u_long(xdrs, (u_long *)up)); return (xdr_u_long(xdrs, (u_long *)up));
#else #else
if (sizeof (u_int) < sizeof (u_long)) { # if UINT_MAX < ULONG_MAX
u_long l; u_long l;
switch (xdrs->x_op) { switch (xdrs->x_op) {
@ -157,19 +152,13 @@ xdr_u_int(xdrs, up)
*up = (u_int) l; *up = (u_int) l;
return TRUE; return TRUE;
} }
} else if (sizeof (u_int) == sizeof (u_long)) { # elif UINT_MAX == ULONG_MAX
return (xdr_u_long(xdrs, (u_long *)up)); return xdr_u_long(xdrs, (u_long *)up);
} else if (sizeof (u_int) == sizeof (u_short)) { # elif UINT_MAX == USHRT_MAX
return (xdr_short(xdrs, (short *)up)); return xdr_short(xdrs, (short *)up);
} else { # else
abort (); /* drepper@gnu */ # error unexpected integer sizes in_xdr_u_int()
#if 0
/* force unresolved reference (link-time error): */
extern unexpected_sizes_in_xdr_u_int ();
unexpected_sizes_in_xdr_u_int();
# endif # endif
}
#endif #endif
} }

View File

@ -106,7 +106,7 @@ elf_alpha_fix_plt(struct link_map *l,
if (edisp >= -0x100000 && edisp < 0x100000) if (edisp >= -0x100000 && edisp < 0x100000)
{ {
/* If we are in range, use br to perfect branch prediction and /* 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. */ e.g., when a shared library call is resolved to the same library. */
int hi, lo; int hi, lo;

View File

@ -26,10 +26,10 @@ Cambridge, MA 02139, USA. */
#endif #endif
LEAF(__syscall_error, 0) LEAF(__syscall_error, 0)
ldgp gp, 0(t12)
.prologue 1 .prologue 1
/* Store return value in errno... */ /* Store return value in errno... */
ldgp gp, 0(t12)
stl v0, errno stl v0, errno
/* And just kick back a -1. */ /* And just kick back a -1. */

View File

@ -99,22 +99,12 @@ name/**/: \
#undef PSEUDO_END #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: \ 1996: \
br gp, 2f; \ br gp, 2f; \
2: ldgp gp, 0(gp); \ 2: ldgp gp, 0(gp); \
jmp zero, __syscall_error; \ jmp zero, __syscall_error; \
END(sym) END(sym)
#endif
#define r0 v0 #define r0 v0
#define r1 a4 #define r1 a4

View File

@ -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");

View File

@ -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");

View File

@ -19,23 +19,22 @@ Cambridge, MA 02139, USA. */
#include <unistd.h> #include <unistd.h>
#include <sysdep.h> #include <sysdep.h>
#include "fpu_control.h" #include <fpu_control.h>
#include "init-first.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. */
extern void __libc_init (int, char **, char **); extern void __libc_init (int, char **, char **);
extern void __libc_global_ctors (void); 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 static void
init (int *data) init (void *data)
{ {
extern int __personality (int); extern int __personality (int);
int argc = *data; int argc = *(long *)data;
char **argv = (void *) (data + 1); char **argv = (char **)data + 1;
char **envp = &argv[argc + 1]; char **envp = &argv[argc + 1];
/* The `personality' system call takes one argument that chooses the /* The `personality' system call takes one argument that chooses the
@ -50,33 +49,23 @@ init (int *data)
__environ = envp; __environ = envp;
__libc_init (argc, argv, envp); __libc_init (argc, argv, envp);
#ifdef PIC
__libc_global_ctors ();
#endif
} }
#ifdef PIC #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 SYSDEP_CALL_INIT(_init, 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")));*/
void 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 #endif
}

View File

@ -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");