1997-08-02 21:27  Ulrich Drepper  <drepper@cygnus.com>

	* inet/Makefile (headers): Rename netinet/inbits.h to bits/in.h.
	* inet/netinet/in.h: Include bits/in.h instead of netinet/inbits.h.
	* sysdeps/generic/netinet/inbits.h: Move to...
	* sysdeps/generic/bits/in.h: ... here.
	* sysdeps/unix/sysv/linux/bits/inbits.h: Move to ...
	* sysdeps/unix/sysv/linux/bits/in.h: ... here.

	* nis/Makefile (headers): Add bits/nislib.h.
	* nis/rpcsvc/nislib.h: Moved to ....
	* nis/bits/nislib.h: ... here.

	* nis/nss_compat/compat-grp.c: Don't include <rpcsvc/nislib.h>.
	* nis/nss_compat/compat-pwd.c: Likewise.
	* nis/nss_compat/compat-spwd.c: Likewise.
	* nis/nss_nisplus/nisplus-alias.c: Likewise.
	* nis/nss_nisplus/nisplus-ethers.c: Likewise.
	* nis/nss_nisplus/nisplus-grp.c: Likewise.
	* nis/nss_nisplus/nisplus-hosts.c: Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
	* nis/nss_nisplus/nisplus-ntework.c: Likewise.
	* nis/nss_nisplus/nisplus-proto.c: Likewise.
	* nis/nss_nisplus/nisplus-publickey.c: Likewise.
	* nis/nss_nisplus/nisplus-pwd.c: Likewise.
	* nis/nss_nisplus/nisplus-rpc.c: Likewise.
	* nis/nss_nisplus/nisplus-service.c: Likewise.
	* nis/nss_nisplus/nisplus-spwd.c: Likewise.

	* nis/rpcsvc/nis.x: Include bits/nislib.h, not rpcsvc/nislib.h.
	* nis/rpcsvc/nis.h: Likewise.

	* inet/getnameinfo.c (nrl_domainname): Change return type to const
	char *.
	(getnameinfo): Change type of local variable c to const char *.

	* inet/inet_ntoa.c: Rewrite to use __libc_once for initialization.
	* stdlib/fmtmsg.c: Likewise.

	* intl/bindtextdom.c: Update from latest gettext.
	* intl/dcgettext.c: Likewise.
	* intl/finddomain.c: Likewise.
	* intl/l10nflist.c: Likewise.
	* intl/localealias.c: Likewise.
	* intl/textdomain.c: Likewise.

	* login/getutid_r.c: Remove parameter to setutent call.
	* login/getutline_r.c: Likewise.

	* posix/wordexp.c: Complete rewrite.  Not fully implemented yet,
	though.  Patch by Tim Waugh <tim@cyberelk.demon.co.uk>.

	* stdio-common/printf_fp.c: Remove relative include paths.
	* stdio-common/printf_fphex.c: Likewise.

	* sysdeps/generic/crypt.h: Cleanup.  Don't define non standard
	elements unless __USE_GNU.

	* sysdeps/generic/vlimit.c: Pretty print.
	* sysdeps/generic/vtimes.c: Likewise.

	* sysdeps/i386/elf/bsd-_setjmp.S: New file.  Empty dummy file.
	* sysdeps/i386/elf/bsd-setjmp.S: New file.  Empty dummy file.
	* sysdeps/i386/elf/setjmp.S: New file.  Define __setjmp and also
	weak definitions of setjmp and _setjmp.

	* sysdeps/i386/fpu/bits/mathinline.h: More patches by John Bowman.

	* sysdeps/stub/if_index.h: Set errno in all functions and add
	stub warnings.

	* sysdeps/stub/libc-lock.h: Add __libc_once.

1997-08-02 01:57  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/unix/sysv/linux/ptrace.c: Don't set errno in error
	case since the __syscall_ptrace call already did this.
	Reported by Philip Gladstone <philip@talon.raptor.com>.

1997-07-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/unix/sysv/linux/sys/fsuid.h: Change include
	<gnu/types.h> to <sys/types.h>.

1997-08-01 23:18  Ulrich Drepper  <drepper@cygnus.com>

	* csu/defs.awk: Fix regexp for end and align.
	Patch by Klaus Espenlaub <kespenla@hydra.informatik.uni-ulm.de>.

	* locale/programs/localedef.c (print_escaped): New function.
	(show_info): Use print_escaped if strings can control unprintable
	characters.
	Patch by Jochen Hein <jochen.hein@delphi.central.de>.

1997-08-01 18:45  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

	* nis/nss_nisplus/nisplus-alias.c: Fix NULL pointer problems
	* nis/nss_nisplus/nisplus-grp.c: Likewise.

1997-07-31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-profile.c (_dl_start_profile): Use _dl_sysdep_error
	instead of fprintf.

1997-07-31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* manual/socket.texi (Host Address Functions): Fix arguments of
	@deftypefun.

1997-07-31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-runtime.c: Avoid warning about profile_fixup being
	unused.

	* sysdeps/m68k/dl-machine.h: Add support for shared library
	profiling.

1997-07-31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* md5-crypt/Makefile (extra-objs): Add onlymd5-crypt.o for
	dependencies.

1997-07-31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* Make-dist (subdirs): Distribute both aout and elf.

1997-07-31 23:04  Mark Kettenis  <kettenis@phys.uva.nl>

	* login/utmp-private.h: Remove reset argument from backend
	setutent.
	* login/getutent_r.c (__setutent): Allways call the setutent
	function in the daemon backend.
	(setutent_unknown): Function removed.
	(getutent_unknown, pututline_unknown): Call __setutent instead of
	setutent_unknown.
	* login/utmp_file.c (setutent_file): Removed reset argument.  All
	callers changed.
	* login/utmp_daemon.c (setutent_daemon): Removed reset
	argument.  All callers changed.  Try to open connection even if a
	previous connection failed, but first check if the sockets exist
	in the filesystem.

	* login/utmp_daemon.c (pututline_daemon): Try to open connection
	before reporting failure.

	* login/programs/database.c (open_database): Create compatibility
	file if it does not already exist.  Supply mode argument in open
	calls to guarantee that created files have the proper protection.

	* login/programs/utmpd.c (main): Remove files created by a
	previous `bind' before creating sockets.
	Suggested by a sun <asum@zoology.washington.edu>.

1997-07-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* math/libm-test.c: Remove unneeded function check_int_exec.

	* BUGS: Correct typos.

	* gmon/gmon.c: Add alias for monstartup, declare _strerror_internal.

1997-07-30  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* manual/socket.texi (Host Address Functions): Reformat inet_ntop
	entry to confirm with expected behaviour of some scripts.

	* libc.map: Add functions/variables in global namespace,
	remove wildcards.

1997-07-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* resolv/libresolv.map: Add variables and routines used by named,
	nslookup and other bind utils.
	* libc.map: Likewise.

1997-07-31 00:35  Philip Blundell  <Philip.Blundell@pobox.com>

	* sysdeps/unix/sysv/linux/if_index.c: Rewrite to avoid using /proc
	filesystem.
	* inet/test_ifindex.c: New file.
	* inet/Makefile (tests): Add test_ifindex.

1997-08-01 04:25  Ulrich Drepper  <drepper@cygnus.com>

	* nis/nss_nisplus/nisplus-parser.c: Fix another bug in the parser.
	Patch by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>.

	* manual/errno.texi: Fix typo.
	Reported by Erik Talvola <etalvo@sapient.com>.

	(write_hist): Remove dependency on 32 bit int.
This commit is contained in:
Ulrich Drepper 1997-08-02 21:00:51 +00:00
parent 3996f34b46
commit 8f2ece695d
76 changed files with 2922 additions and 675 deletions

8
BUGS
View File

@ -1,20 +1,20 @@
List of known bugs (certainly very incomplete) List of known bugs (certainly very incomplete)
---------------------------------------------- ----------------------------------------------
Time-stamp: <1997-05-21T21:25:40+0200 drepper> Time-stamp: <1997-08-01T05:37:51+0200 drepper>
This following list contains those bugs which I'm aware of. Please This following list contains those bugs which I'm aware of. Please
make sure that bugs you report are not listed here. If you can fix one make sure that bugs you report are not listed here. If you can fix one
of these bugs/limitations I'll certainly be glad to receive a patch. of these bugs/limitations I'll certainly be glad to receive a patch.
Another source of information about bugs is the problem data base of the Another source of information about bugs is the problem data base of the
GNU project. There is an easy to use WWW interface is available at GNU project. There is an easy to use WWW interface available at
http://www-gnats.gnu.ai.mit.edu:8080/cgi-bin/wwwgnats.pl http://www-gnats.gnu.ai.mit.edu:8080/cgi-bin/wwwgnats.pl
I would appreciate it very much if you could verify the problem was not I would appreciate it very much if you could verify the problem was not
reported before by looking though the database. To make the information reported before by looking through the database. To make the information
in this data as useful as possible please report bugs always using the in this database as useful as possible please report bugs always using the
`glibcbug' shell script which gets installed with GNU libc. `glibcbug' shell script which gets installed with GNU libc.

192
ChangeLog
View File

@ -1,3 +1,193 @@
1997-08-02 21:27 Ulrich Drepper <drepper@cygnus.com>
* inet/Makefile (headers): Rename netinet/inbits.h to bits/in.h.
* inet/netinet/in.h: Include bits/in.h instead of netinet/inbits.h.
* sysdeps/generic/netinet/inbits.h: Move to...
* sysdeps/generic/bits/in.h: ... here.
* sysdeps/unix/sysv/linux/bits/inbits.h: Move to ...
* sysdeps/unix/sysv/linux/bits/in.h: ... here.
* nis/Makefile (headers): Add bits/nislib.h.
* nis/rpcsvc/nislib.h: Moved to ....
* nis/bits/nislib.h: ... here.
* nis/nss_compat/compat-grp.c: Don't include <rpcsvc/nislib.h>.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* nis/nss_nisplus/nisplus-alias.c: Likewise.
* nis/nss_nisplus/nisplus-ethers.c: Likewise.
* nis/nss_nisplus/nisplus-grp.c: Likewise.
* nis/nss_nisplus/nisplus-hosts.c: Likewise.
* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
* nis/nss_nisplus/nisplus-ntework.c: Likewise.
* nis/nss_nisplus/nisplus-proto.c: Likewise.
* nis/nss_nisplus/nisplus-publickey.c: Likewise.
* nis/nss_nisplus/nisplus-pwd.c: Likewise.
* nis/nss_nisplus/nisplus-rpc.c: Likewise.
* nis/nss_nisplus/nisplus-service.c: Likewise.
* nis/nss_nisplus/nisplus-spwd.c: Likewise.
* nis/rpcsvc/nis.x: Include bits/nislib.h, not rpcsvc/nislib.h.
* nis/rpcsvc/nis.h: Likewise.
* inet/getnameinfo.c (nrl_domainname): Change return type to const
char *.
(getnameinfo): Change type of local variable c to const char *.
* inet/inet_ntoa.c: Rewrite to use __libc_once for initialization.
* stdlib/fmtmsg.c: Likewise.
* intl/bindtextdom.c: Update from latest gettext.
* intl/dcgettext.c: Likewise.
* intl/finddomain.c: Likewise.
* intl/l10nflist.c: Likewise.
* intl/localealias.c: Likewise.
* intl/textdomain.c: Likewise.
* login/getutid_r.c: Remove parameter to setutent call.
* login/getutline_r.c: Likewise.
* posix/wordexp.c: Complete rewrite. Not fully implemented yet,
though. Patch by Tim Waugh <tim@cyberelk.demon.co.uk>.
* stdio-common/printf_fp.c: Remove relative include paths.
* stdio-common/printf_fphex.c: Likewise.
* sysdeps/generic/crypt.h: Cleanup. Don't define non standard
elements unless __USE_GNU.
* sysdeps/generic/vlimit.c: Pretty print.
* sysdeps/generic/vtimes.c: Likewise.
* sysdeps/i386/elf/bsd-_setjmp.S: New file. Empty dummy file.
* sysdeps/i386/elf/bsd-setjmp.S: New file. Empty dummy file.
* sysdeps/i386/elf/setjmp.S: New file. Define __setjmp and also
weak definitions of setjmp and _setjmp.
* sysdeps/i386/fpu/bits/mathinline.h: More patches by John Bowman.
* sysdeps/stub/if_index.h: Set errno in all functions and add
stub warnings.
* sysdeps/stub/libc-lock.h: Add __libc_once.
1997-08-02 01:57 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/ptrace.c: Don't set errno in error
case since the __syscall_ptrace call already did this.
Reported by Philip Gladstone <philip@talon.raptor.com>.
1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/sys/fsuid.h: Change include
<gnu/types.h> to <sys/types.h>.
1997-08-01 23:18 Ulrich Drepper <drepper@cygnus.com>
* csu/defs.awk: Fix regexp for end and align.
Patch by Klaus Espenlaub <kespenla@hydra.informatik.uni-ulm.de>.
* locale/programs/localedef.c (print_escaped): New function.
(show_info): Use print_escaped if strings can control unprintable
characters.
Patch by Jochen Hein <jochen.hein@delphi.central.de>.
1997-08-01 18:45 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/nss_nisplus/nisplus-alias.c: Fix NULL pointer problems
* nis/nss_nisplus/nisplus-grp.c: Likewise.
1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* elf/dl-profile.c (_dl_start_profile): Use _dl_sysdep_error
instead of fprintf.
1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/socket.texi (Host Address Functions): Fix arguments of
@deftypefun.
1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* elf/dl-runtime.c: Avoid warning about profile_fixup being
unused.
* sysdeps/m68k/dl-machine.h: Add support for shared library
profiling.
1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* md5-crypt/Makefile (extra-objs): Add onlymd5-crypt.o for
dependencies.
1997-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Make-dist (subdirs): Distribute both aout and elf.
1997-07-31 23:04 Mark Kettenis <kettenis@phys.uva.nl>
* login/utmp-private.h: Remove reset argument from backend
setutent.
* login/getutent_r.c (__setutent): Allways call the setutent
function in the daemon backend.
(setutent_unknown): Function removed.
(getutent_unknown, pututline_unknown): Call __setutent instead of
setutent_unknown.
* login/utmp_file.c (setutent_file): Removed reset argument. All
callers changed.
* login/utmp_daemon.c (setutent_daemon): Removed reset
argument. All callers changed. Try to open connection even if a
previous connection failed, but first check if the sockets exist
in the filesystem.
* login/utmp_daemon.c (pututline_daemon): Try to open connection
before reporting failure.
* login/programs/database.c (open_database): Create compatibility
file if it does not already exist. Supply mode argument in open
calls to guarantee that created files have the proper protection.
* login/programs/utmpd.c (main): Remove files created by a
previous `bind' before creating sockets.
Suggested by a sun <asum@zoology.washington.edu>.
1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* math/libm-test.c: Remove unneeded function check_int_exec.
* BUGS: Correct typos.
* gmon/gmon.c: Add alias for monstartup, declare _strerror_internal.
1997-07-30 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* manual/socket.texi (Host Address Functions): Reformat inet_ntop
entry to confirm with expected behaviour of some scripts.
* libc.map: Add functions/variables in global namespace,
remove wildcards.
1997-07-29 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* resolv/libresolv.map: Add variables and routines used by named,
nslookup and other bind utils.
* libc.map: Likewise.
1997-07-31 00:35 Philip Blundell <Philip.Blundell@pobox.com>
* sysdeps/unix/sysv/linux/if_index.c: Rewrite to avoid using /proc
filesystem.
* inet/test_ifindex.c: New file.
* inet/Makefile (tests): Add test_ifindex.
1997-08-01 04:25 Ulrich Drepper <drepper@cygnus.com>
* nis/nss_nisplus/nisplus-parser.c: Fix another bug in the parser.
Patch by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>.
* manual/errno.texi: Fix typo.
Reported by Erik Talvola <etalvo@sapient.com>.
1997-07-28 23:35 Ulrich Drepper <drepper@cygnus.com> 1997-07-28 23:35 Ulrich Drepper <drepper@cygnus.com>
* csu/gmon-start.c (__gmon_start__): Call __monstartup not * csu/gmon-start.c (__gmon_start__): Call __monstartup not
@ -9,7 +199,7 @@
* gmon/bb_exit_func.c (__bb_exit_func): Use memcpy instead of bcopy. * gmon/bb_exit_func.c (__bb_exit_func): Use memcpy instead of bcopy.
* gmon/gmon.c (__monstartup): Likewise. * gmon/gmon.c (__monstartup): Likewise.
(write_hist): Remove dependency on 32 int. (write_hist): Remove dependency on 32 bit int.
(_mcleanup): Don't call perror, use fprintf. (_mcleanup): Don't call perror, use fprintf.
* elf/dl-load.c: Fix handling of current directory in search path. * elf/dl-load.c: Fix handling of current directory in search path.

View File

@ -47,6 +47,9 @@ subdirs := $(filter-out $(add-ons),$(subdirs))
# Make sure both stdio and libio get in, whichever is in use. # Make sure both stdio and libio get in, whichever is in use.
subdirs += stdio libio subdirs += stdio libio
# Make sure both aout and elf get in, whichever is in use.
subdirs += aout elf
sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs))) sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
ifdef sysdep-Subdir-files ifdef sysdep-Subdir-files
subdirs := $(sort $(subdirs) \ subdirs := $(sort $(subdirs) \

5
config.sub vendored
View File

@ -682,9 +682,12 @@ case $os in
-solaris) -solaris)
os=-solaris2 os=-solaris2
;; ;;
-unixware* | svr4*) -svr4*)
os=-sysv4 os=-sysv4
;; ;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*) -gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;; ;;

View File

@ -1,5 +1,5 @@
/.end/ { need_end = 1 } /\.end/ { need_end = 1 }
/.align/ { if($2 > max) max = $2; } /\.align/ { if($2 > max) max = $2; }
END { END {
if(need_end) if(need_end)

View File

@ -179,8 +179,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
cannot_create: cannot_create:
errnum = errno; errnum = errno;
__close (fd); __close (fd);
fprintf (stderr, "%s: cannot create file: %s\n", filename, _dl_sysdep_error (filename, ": cannot create file: ",
_strerror_internal (errnum, buf, sizeof buf)); _strerror_internal (errnum, buf, sizeof buf),
"\n", NULL);
return; return;
} }
@ -192,8 +193,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
{ {
__close (fd); __close (fd);
wrong_format: wrong_format:
fprintf (stderr, "%s: file is no correct profile data file for `%s'\n", _dl_sysdep_error (filename,
filename, _dl_profile); ": file is no correct profile data file for `",
_dl_profile, "'\n", NULL);
return; return;
} }
@ -204,8 +206,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
char buf[400]; char buf[400];
int errnum = errno; int errnum = errno;
__close (fd); __close (fd);
fprintf (stderr, "%s: cannot map file: %s\n", filename, _dl_sysdep_error (filename, ": cannot map file: ",
_strerror_internal (errnum, buf, sizeof buf)); _strerror_internal (errnum, buf, sizeof buf),
"\n", NULL);
return; return;
} }

View File

@ -163,6 +163,14 @@ fixup (
#ifndef PROF #ifndef PROF
static ElfW(Addr)
profile_fixup (
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
ELF_MACHINE_RUNTIME_FIXUP_ARGS,
#endif
struct link_map *l, ElfW(Word) reloc_offset, ElfW(Addr) retaddr)
__attribute__ ((unused));
static ElfW(Addr) static ElfW(Addr)
profile_fixup ( profile_fixup (
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS

View File

@ -46,6 +46,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
extern char *_strerror_internal __P ((int, char *buf, size_t));
extern int __profile_frequency __P ((void)); extern int __profile_frequency __P ((void));
struct __bb *__bb_head; /* Head of basic-block list or NULL. */ struct __bb *__bb_head; /* Head of basic-block list or NULL. */
@ -162,6 +164,7 @@ __monstartup (lowpc, highpc)
__moncontrol(1); __moncontrol(1);
} }
weak_alias(__monstartup, monstartup)
static void static void

View File

@ -23,7 +23,7 @@ subdir := inet
headers := netinet/ether.h netinet/in.h netinet/if_ether.h \ headers := netinet/ether.h netinet/in.h netinet/if_ether.h \
netinet/tcp.h netinet/ip.h $(wildcard arpa/*.h protocols/*.h) \ netinet/tcp.h netinet/ip.h $(wildcard arpa/*.h protocols/*.h) \
aliases.h netinet/ip6.h netinet/icmp6.h netinet/inbits.h aliases.h netinet/ip6.h netinet/icmp6.h bits/in.h
distribute := netgroup.h distribute := netgroup.h
@ -46,7 +46,7 @@ routines := htonl htons \
getaliasent_r getaliasent getaliasname getaliasname_r \ getaliasent_r getaliasent getaliasname getaliasname_r \
in6_addr getnameinfo if_index in6_addr getnameinfo if_index
tests := htontest tests := htontest test_ifindex
# No warnings about losing BSD code. # No warnings about losing BSD code.
CFLAGS-rcmd.c = -w CFLAGS-rcmd.c = -w

View File

@ -77,7 +77,7 @@ struct hostent *_addr2hostname_hosts (const char *, int, int);
#endif /* min */ #endif /* min */
static char * static const char *
nrl_domainname (void) nrl_domainname (void)
{ {
static const char *domain = NULL; static const char *domain = NULL;
@ -267,7 +267,7 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
{ {
if (flags & NI_NOFQDN) if (flags & NI_NOFQDN)
{ {
char *c; const char *c;
if ((c = nrl_domainname ()) && (c = strstr(h->h_name, c)) if ((c = nrl_domainname ()) && (c = strstr(h->h_name, c))
&& (c != h->h_name) && (*(--c) == '.')) && (c != h->h_name) && (*(--c) == '.'))
{ {

View File

@ -26,49 +26,35 @@
/* The interface of this function is completely stupid, it requires a /* The interface of this function is completely stupid, it requires a
static buffer. We relax this a bit in that we allow at least one static buffer. We relax this a bit in that we allow at least one
buffer for each thread. */ buffer for each thread. */
__libc_lock_define_initialized (static, lock);
/* This is the key for the thread specific memory. */ /* This is the key for the thread specific memory. */
static __libc_key_t key; static __libc_key_t key;
/* If nonzero the key allocation failed and we should better use a
static buffer than fail. */
static char local_buf[18];
static char *static_buf;
/* Destructor for the thread-specific data. */ /* Destructor for the thread-specific data. */
static void init (void);
static void free_key_mem (void *mem); static void free_key_mem (void *mem);
char * char *
inet_ntoa (struct in_addr in) inet_ntoa (struct in_addr in)
{ {
static char static_buf[18]; __libc_once_define (once);
static int initialized = 0; char *buffer;
char *buffer = NULL;
unsigned char *bytes; unsigned char *bytes;
/* If we have not yet initialized the buffer do it now. */ /* If we have not yet initialized the buffer do it now. */
if (!initialized) __libc_once (once, init);
{
/* Make sure there is only one process doing the initialization. */
__libc_lock_lock (lock);
if (!initialized) if (static_buf != NULL)
{ return static_buf;
if (__libc_key_create (&key, free_key_mem))
/* Creating the key failed. This either means we run
have only a single-threaded application or something
really went wrong. In any case use a static buffer
which is better than nothing. */
buffer = static_buf;
else
/* We have a key. */
initialized = 1;
}
__libc_lock_unlock (lock); /* We don't use the static buffer and so we have a key. Use it to
} get the thread-specific buffer. */
if (buffer == NULL)
{
/* We don't use the static buffer and so we have a key. Use it
to get the thread-specific buffer. */
buffer = __libc_getspecific (key); buffer = __libc_getspecific (key);
if (buffer == NULL) if (buffer == NULL)
{ {
@ -76,11 +62,10 @@ inet_ntoa (struct in_addr in)
buffer = malloc (18); buffer = malloc (18);
if (buffer == NULL) if (buffer == NULL)
/* No more memory available. We use the static buffer. */ /* No more memory available. We use the static buffer. */
buffer = static_buf; buffer = local_buf;
else else
__libc_setspecific (key, buffer); __libc_setspecific (key, buffer);
} }
}
bytes = (unsigned char *) &in; bytes = (unsigned char *) &in;
snprintf (buffer, 18, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]); snprintf (buffer, 18, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]);
@ -89,12 +74,21 @@ inet_ntoa (struct in_addr in)
} }
/* Initialize buffer. */
static void
init (void)
{
if (__libc_key_create (&key, free_key_mem))
/* Creating the key failed. This means something really went
wrong. In any case use a static buffer which is better than
nothing. */
static_buf = local_buf;
}
/* free the thread specific data, this is done if a thread terminates. */
static void static void
free_key_mem (void *mem) free_key_mem (void *mem)
{ {
free (mem); free (mem);
/* And we must set the data to NULL so that the destructor is not
called again. */
__libc_setspecific (key, NULL);
} }

View File

@ -140,7 +140,7 @@ struct in_addr
#define IN_LOOPBACKNET 127 #define IN_LOOPBACKNET 127
/* Address to loopback in software to local host. */ /* Address to loopback in software to local host. */
#ifndef INADDR_LOOPBACK #ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet address 127.0.0.1. */ # define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet 127.0.0.1. */
#endif #endif
@ -208,7 +208,7 @@ struct ipv6_mreq
}; };
/* Get system-specific definitions. */ /* Get system-specific definitions. */
#include <netinet/inbits.h> #include <bits/in.h>
/* Functions to convert between host and network byte order. /* Functions to convert between host and network byte order.

59
inet/test_ifindex.c Normal file
View File

@ -0,0 +1,59 @@
/* Test interface name <-> index conversions.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <Philip.Blundell@pobox.com>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <net/if.h>
int
main (void)
{
int failures = 0;
struct if_nameindex *idx = if_nameindex (), *p;
if (idx == NULL)
{
if (errno != ENOSYS)
{
printf ("Couldn't get any interfaces.\n");
exit (1);
}
/* The function is simply not implemented. */
exit (0);
}
printf ("Idx Name | Idx Name\n");
for (p = idx; p->if_index || p->if_name; ++p)
{
char buf[IFNAMSIZ];
int ni, result;
printf ("%3d %15s | ", p->if_index, p->if_name);
printf ("%3d", ni = if_nametoindex (p->if_name));
printf ("%15s", if_indextoname (p->if_index, buf));
result = (ni != p->if_index || (strcmp (buf, p->if_name)));
printf ("%10s", result ? "fail" : "okay");
printf ("\n");
failures += result;
}
if_freenameindex (idx);
exit (failures ? 1 : 0);
}

View File

@ -1,5 +1,5 @@
/* bindtextdom.c -- implementation of the bindtextdomain(3) function /* Implementation of the bindtextdomain(3) function
Copyright (C) 1995, 1997 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib. the C library, however. The master source lives in /gd/gnu/lib.
@ -37,6 +37,9 @@ void free ();
# include <string.h> # include <string.h>
#else #else
# include <strings.h> # include <strings.h>
# ifndef memcpy
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif #endif
#ifdef _LIBC #ifdef _LIBC

View File

@ -545,7 +545,8 @@ category_to_name (category)
} }
/* Guess value of current locale from value of the environment variables. */ /* Guess value of current locale from value of the environment variables. */
static const char *guess_category_value (category, categoryname) static const char *
guess_category_value (category, categoryname)
int category; int category;
const char *categoryname; const char *categoryname;
{ {

View File

@ -1,4 +1,4 @@
/* finddomain.c -- handle list of needed message catalogs /* Handle list of needed message catalogs
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@ -43,6 +43,9 @@ void free ();
# include <string.h> # include <string.h>
#else #else
# include <strings.h> # include <strings.h>
# ifndef memcpy
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif #endif
#if !HAVE_STRCHR && !defined _LIBC #if !HAVE_STRCHR && !defined _LIBC
# ifndef strchr # ifndef strchr

View File

@ -31,6 +31,9 @@
# include <string.h> # include <string.h>
#else #else
# include <strings.h> # include <strings.h>
# ifndef memcpy
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif #endif
#if !HAVE_STRCHR && !defined _LIBC #if !HAVE_STRCHR && !defined _LIBC
# ifndef strchr # ifndef strchr

View File

@ -62,6 +62,9 @@ void free ();
# include <string.h> # include <string.h>
#else #else
# include <strings.h> # include <strings.h>
# ifndef memcpy
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif #endif
#if !HAVE_STRCHR && !defined _LIBC #if !HAVE_STRCHR && !defined _LIBC
# ifndef strchr # ifndef strchr

View File

@ -31,6 +31,9 @@
# include <string.h> # include <string.h>
#else #else
# include <strings.h> # include <strings.h>
# ifndef memcpy
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif #endif
#ifdef _LIBC #ifdef _LIBC

309
libc.map
View File

@ -83,10 +83,313 @@ GLIBC_2.0 {
_IO_str_seekoff; _IO_str_pbackfail; _IO_list_all; _IO_file_jumps; _IO_str_seekoff; _IO_str_pbackfail; _IO_list_all; _IO_file_jumps;
_IO_peekc_locked; _IO_peekc_locked;
_rpc_dtablesize; _null_auth; _seterr_reply; _rpc_dtablesize; _null_auth; _seterr_reply;
__res_randomid;
# all functions and variables in the normal name space # variables in normal name space
a*; b*; c*; d*; e*; f*; g*; h*; i*; j*; k*; l*; m*; argp_err_exit_status; argp_program_bug_address; argp_program_version;
n*; o*; p*; q*; r*; s*; t*; u*; v*; w*; x*; y*; z*; argp_program_version_hook;
daylight;
environ;
errno; error_message_count; error_one_per_line; error_print_progname;
getdate_err;
h_errlist; h_errno; h_nerr;
in6addr_any; in6addr_loopback;
loc1; loc2; locs;
mallwatch;
obstack_alloc_failed_handler; obstack_exit_failure;
optarg; opterr; optind; optopt;
program_invocation_name; program_invocation_short_name;
re_max_failures; re_syntax_options; rexecoptions; rpc_createerr;
stderr; stdin; stdout; svc_fdset; svcauthdes_stats;
sys_errlist; sys_nerr; sys_sigabbrev; sys_siglist;
timezone; tzname;
# functions in normal name space
# Please keep them sorted by name!
# a*
a64l; abort; abs; accept; access; acct; addmntent; addseverity;
adjtime; adjtimex; advance; alarm; alphasort;
argp_error; argp_failure; argp_fmtstream_free; argp_fmtstream_point;
argp_fmtstream_printf; argp_fmtstream_putc; argp_fmtstream_puts;
argp_fmtstream_set_lmargin; argp_fmtstream_set_rmargin;
argp_fmtstream_set_wmargin; argp_fmtstream_write; argp_help;
argp_make_fmtstream; argp_parse; argp_state_help; argp_usage;
argz_add; argz_add_sep; argz_append; argz_count; argz_create;
argz_create_sep; argz_delete; argz_extract; argz_insert; argz_next;
argz_replace; argz_stringify;
asctime; asctime_r; asprintf; atexit; atof; atoi; atol; atoll;
authdes_create; authdes_getucred; authdes_pk_create; authnone_create;
authunix_create; authunix_create_default;
# b*
basename; bcmp; bcopy; bdflush; bind; bindresvport;
bindtextdomain; brk; bsd_signal; bsearch; btowc; bzero;
# c*
cachectl; cacheflush; calloc; callrpc; canonicalize_file_name;
catclose; catgets; catopen;
cbc_crypt; cfgetispeed; cfgetospeed; cfmakeraw; cfree;
cfsetispeed; cfsetospeed; cfsetspeed; chdir; chflags; chmod; chown;
chroot; clearenv; clearerr; clearerr_unlocked;
clnt_broadcast; clnt_create; clnt_pcreateerror; clnt_perrno;
clnt_perror; clnt_spcreateerror; clnt_sperrno; clnt_sperror;
clntraw_create; clnttcp_create; clntudp_bufcreate; clntudp_create;
clock; clone; close; closedir; closelog; confstr; connect; copysign;
copysignf; copysignl; creat; create_module; ctermid; ctime; ctime_r;
cuserid;
# d*
daemon; dcgettext; delete_module; des_setparity; dgettext;
difftime; dirfd; dirname; div; dprintf; drand48; drand48_r; dup; dup2;
dysize;
# e*
ecb_crypt; ecvt; ecvt_r; endaliasent; endfsent; endgrent; endhostent;
endmntent; endnetent; endnetgrent; endprotoent; endpwent; endrpcent;
endservent; endspent; endttyent; endusershell; endutent; endutxent;
envz_add; envz_entry; envz_get; envz_merge; envz_remove;
envz_strip; erand48; erand48_r; err; error; error_at_line; errx;
ether_aton; ether_aton_r; ether_hostton; ether_line; ether_ntoa;
ether_ntoa_r; ether_ntohost;
euidaccess; execl; execle; execlp; execv; execve; execvp; exit;
# f*
fchdir; fchflags; fchmod; fchown; fclose; fcloseall; fcntl; fcvt;
fcvt_r; fdatasync; fdopen; feof; feof_unlocked; ferror;
ferror_unlocked; fexecve; fflush; fflush_unlocked; ffs; fgetc;
fgetgrent; fgetgrent_r; fgetpos; fgetpwent; fgetpwent_r; fgets;
fgetspent; fgetspent_r; fileno; fileno_unlocked; finite; finitef;
finitel; flock; flockfile; fmtmsg; fnmatch; fopen; fopencookie; fork;
fpathconf; fprintf; fputc; fputc_unlocked; fputs; fread; free;
freeaddrinfo; freopen; frexp; frexpf; frexpl; fscanf; fseek; fsetpos;
fstatfs; fsync; ftell; ftime; ftok; ftruncate; ftrylockfile;
fts_children; fts_close; fts_open; fts_read; fts_set; ftw;
funlockfile; fwrite;
# g*
gai_strerror; gcvt; get_avphys_pages; get_current_dir_name;
get_kernel_syms; get_myaddress; get_nprocs; get_nprocs_conf;
get_phys_pages; getaddrinfo; getaliasbyname; getaliasbyname_r;
getaliasent; getaliasent_r; getc; getc_unlocked; getchar;
getchar_unlocked; getcwd; getdate; getdate_r; getdelim; getdirentries;
getdomainname; getdtablesize; getegid; getenv; geteuid; getfsent;
getfsfile; getfsspec; getgid; getgrent; getgrent_r; getgrgid;
getgrgid_r; getgrnam; getgrnam_r; getgroups; gethostbyaddr;
gethostbyaddr_r; gethostbyname; gethostbyname2; gethostbyname2_r;
gethostbyname_r; gethostent; gethostent_r; gethostid; gethostname;
getitimer; getline; getlogin; getlogin_r; getmntent; getmntent_r;
getnameinfo; getnetbyaddr; getnetbyaddr_r; getnetbyname;
getnetbyname_r; getnetent; getnetent_r; getnetgrent; getnetgrent_r;
getnetname; getopt; getopt_long; getopt_long_only; getpagesize;
getpass; getpeername; getpgid; getpgrp; getpid; getppid; getpriority;
getprotobyname; getprotobyname_r; getprotobynumber;
getprotobynumber_r; getprotoent; getprotoent_r; getpublickey; getpw;
getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r;
getrlimit; getrpcbyname; getrpcbyname_r; getrpcbynumber;
getrpcbynumber_r; getrpcent; getrpcent_r; getrpcport; getrusage; gets;
getsecretkey; getservbyname; getservbyname_r; getservbyport;
getservbyport_r; getservent; getservent_r; getsid; getsockname;
getsockopt; getspent; getspent_r; getspnam; getspnam_r; getsubopt;
gettext; gettimeofday; getttyent; getttynam; getuid; getusershell;
getutent; getutent_r; getutid; getutid_r; getutline; getutline_r;
getutxent; getw; getwd; glob; glob_pattern_p; globfree; gmtime;
gmtime_r; group_member; gsignal; gtty;
# h*
hasmntopt; hcreate; hcreate_r; hdestroy; hdestroy_r; herror;
host2netname; hsearch; hsearch_r; hstrerror; htonl; htons;
# i*
if_freenameindex; if_indextoname; if_nameindex; if_nametoindex; index;
inet6_isipv4mapped; inet_addr; inet_aton; inet_lnaof; inet_makeaddr;
inet_netof; inet_network; inet_nsap_addr; inet_nsap_ntoa; inet_ntoa;
inet_ntop; inet_pton; init_module; initgroups; initstate; initstate_r;
innetgr; insque; ioctl; ioperm; iopl; iruserok;
isalnum; isalpha; isascii; isatty; isblank; iscntrl; isdigit;
isfdtype; isgraph; isinf; isinff; isinfl; islower; isnan; isnanf;
isnanl; isprint; ispunct; isspace; isupper; iswalnum; iswalpha;
iswblank; iswcntrl; iswctype; iswdigit; iswgraph; iswlower; iswprint;
iswpunct; iswspace; iswupper; iswxdigit; isxdigit;
# j*
jrand48; jrand48_r;
# k*
key_decryptsession; key_decryptsession_pk; key_encryptsession;
key_encryptsession_pk; key_gendes; key_get_conv; key_secretkey_is_set;
key_setnet; key_setsecret;
kill; killpg; klogctl;
# l*
l64a; labs; lchown; lckpwdf; lcong48; lcong48_r; ldexp; ldexpf;
ldexpl; ldiv; lfind; link; listen; llabs; lldiv; llseek; localeconv;
localtime; localtime_r; lockf; longjmp; lrand48; lrand48_r; lsearch;
lseek;
# m*
madvise;
mallinfo; malloc; malloc_get_state; malloc_set_state;
malloc_stats; malloc_trim; malloc_usable_size; mallopt;
mblen; mbrlen; mbrtowc; mbsinit; mbsnrtowcs; mbsrtowcs; mbstowcs;
mbtowc; mcheck; mcount;
memalign; memccpy; memchr; memcmp; memcpy; memfrob; memmem;
memmove; memset;
mkdir; mkfifo; mkstemp; mktemp; mktime; mlock;
mlockall; mmap; modf; modff; modfl; moncontrol; monstartup; mount;
mprobe; mprotect; mrand48; mrand48_r; mremap; msgctl; msgget; msgrcv;
msgsnd; msync; mtrace; munlock; munlockall; munmap; muntrace;
# n*
nanosleep; netname2host; netname2user; nftw; nice; nl_langinfo;
nrand48; nrand48_r; ntohl; ntohs;
# o*
obstack_free; obstack_printf; obstack_vprintf; on_exit; open;
open_memstream; opendir; openlog;
# p*
parse_printf_format; passwd2des; pathconf; pause; pclose; perror;
personality; pipe; pmap_getmaps; pmap_getport; pmap_rmtcall; pmap_set;
pmap_unset; poll; popen; printf; printf_size; printf_size_info;
profil; profil_counter; pselect; psignal;
pthread_attr_destroy;
pthread_attr_getdetachstate; pthread_attr_getinheritsched;
pthread_attr_getschedparam; pthread_attr_getschedpolicy;
pthread_attr_getscope; pthread_attr_init; pthread_attr_setdetachstate;
pthread_attr_setinheritsched; pthread_attr_setschedparam;
pthread_attr_setschedpolicy; pthread_attr_setscope;
pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init;
pthread_cond_signal; pthread_cond_wait; pthread_condattr_destroy;
pthread_condattr_init; pthread_equal; pthread_exit;
pthread_getschedparam; pthread_mutex_destroy; pthread_mutex_init;
pthread_mutex_lock; pthread_mutex_unlock;
pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np;
pthread_self; pthread_setcancelstate; pthread_setcanceltype;
pthread_setschedparam;
ptrace; putc; putc_unlocked; putchar;
putchar_unlocked; putenv; putpwent; puts; putspent; pututline;
pututxline; putw; pvalloc;
# q*
qecvt; qecvt_r; qfcvt; qfcvt_r; qgcvt; qsort; quotactl;
# r*
raise; rand; rand_r; random; random_r; rcmd;
re_comp; re_compile_fastmap; re_compile_pattern; re_exec; re_match;
re_match_2; re_search; re_search_2; re_set_registers; re_set_syntax;
read; readdir; readdir_r; readlink; readv; realloc; realpath; reboot;
recv; recvfrom; recvmsg; regcomp; regerror; regexec; regfree;
register_printf_function; registerrpc; remove; remque; rename;
res_init; revoke; rewind; rewinddir; rexec; rindex; rmdir; rpmatch;
rresvport; rtime; ruserok; ruserpass;
# s*
sbrk; scalbn; scalbnf; scalbnl; scandir; scanf;
sched_get_priority_max; sched_get_priority_min; sched_getparam;
sched_getscheduler; sched_rr_get_interval; sched_setparam;
sched_setscheduler; sched_yield;
seed48; seed48_r; seekdir; select;
semctl; semget; semop; send; sendmsg; sendto; setaliasent; setbuf;
setbuffer; setdomainname; setegid; setenv; seteuid; setfsent;
setfsgid; setfsuid; setgid; setgrent; setgroups; sethostent;
sethostid; sethostname; setitimer; setjmp; setlinebuf; setlocale;
setlogin; setlogmask; setmntent; setnetent; setnetgrent; setpgid;
setpgrp; setpriority; setprotoent; setpwent; setregid; setreuid;
setrlimit; setrpcent; setservent; setsid; setsockopt; setspent;
setstate; setstate_r; settimeofday; setttyent; setuid; setusershell;
setutent; setutxent; setvbuf; sgetspent; sgetspent_r; shmat; shmctl;
shmdt; shmget; shutdown;
sigaction; sigaddset; sigaltstack; sigandset; sigblock; sigdelset;
sigemptyset; sigfillset; siggetmask; siginterrupt; sigisemptyset;
sigismember; siglongjmp; signal; sigorset; sigpause; sigpending;
sigprocmask; sigreturn; sigsetmask; sigstack; sigsuspend; sigvec;
sigwait;
sleep; snprintf; socket; socketpair; sprintf; srand; srand48;
srand48_r; srandom; srandom_r; sscanf; ssignal; sstk; statfs; step;
stime; stpcpy; stpncpy; strcasecmp; strcat; strchr; strcmp; strcoll;
strcpy; strcspn; strdup; strerror; strerror_r; strfmon; strfry;
strftime; strlen; strncasecmp; strncat; strncmp; strncpy; strndup;
strnlen; strpbrk; strptime; strrchr; strsep; strsignal; strspn;
strstr; strtod; strtof; strtok; strtok_r; strtol; strtold; strtoll;
strtoq; strtoul; strtoull; strtouq; strverscmp; strxfrm; stty;
svc_exit; svc_getreq; svc_getreqset; svc_register; svc_run;
svc_sendreply; svc_unregister; svcerr_auth; svcerr_decode;
svcerr_noproc; svcerr_noprog; svcerr_progvers; svcerr_systemerr;
svcerr_weakauth; svcfd_create; svcraw_create; svctcp_create;
svcudp_bufcreate; svcudp_create; svcudp_enablecache;
swab; swapoff; swapon; symlink; sync;
syscall; sysconf; sysctl; sysinfo; syslog;
system;
# t*
tcdrain; tcflow; tcflush; tcgetattr; tcgetpgrp; tcsendbreak;
tcsetattr; tcsetpgrp; tdelete; tdestroy; telldir; tempnam; textdomain;
tfind; time; timegm; timelocal; times; tmpfile; tmpnam; tmpnam_r;
toascii; tolower; toupper; towctrans; towlower; towupper;
tr_break; truncate; tsearch; ttyname; ttyname_r; ttyslot; twalk;
tzset;
# u*
ualarm; ulckpwdf; ulimit; umask; umount; uname; ungetc; unlink;
unsetenv; updwtmp; uselib; user2netname; usleep; ustat; utime; utimes;
utmpname;
# v*
valloc; vasprintf; vdprintf; verr; verrx; versionsort; vfork;
vfprintf; vfscanf; vhangup; vlimit; vm86; vprintf; vscanf; vsnprintf;
vsprintf; vsscanf; vsyslog; vtimes; vwarn; vwarnx;
# w*
wait; wait3; wait4; waitpid; warn; warnx;
wcpcpy; wcpncpy; wcrtomb; wcscasecmp; wcscat; wcschr; wcscmp; wcscoll;
wcscpy; wcscspn; wcsdup; wcslen; wcsncasecmp; wcsncat; wcsncmp;
wcsncpy; wcsnrtombs; wcspbrk; wcsrchr; wcsrtombs; wcsspn; wcsstr;
wcstod; wcstof; wcstok; wcstol; wcstold; wcstoll; wcstombs; wcstoq;
wcstoul; wcstoull; wcstouq; wcswcs; wcswidth; wcsxfrm; wctob; wctomb;
wctrans; wctype; wcwidth;
wmemchr; wmemcmp; wmemcpy; wmemmove; wmemset; write; writev;
# x*
xdecrypt; xdr_accepted_reply; xdr_array; xdr_authdes_cred;
xdr_authdes_verf; xdr_authunix_parms; xdr_bool; xdr_bytes;
xdr_callhdr; xdr_callmsg; xdr_char; xdr_cryptkeyarg; xdr_cryptkeyarg2;
xdr_cryptkeyres; xdr_des_block; xdr_double; xdr_enum; xdr_float;
xdr_free; xdr_getcredres; xdr_int; xdr_key_netstarg; xdr_key_netstres;
xdr_keybuf; xdr_keystatus; xdr_long; xdr_netnamestr; xdr_netobj;
xdr_opaque; xdr_opaque_auth; xdr_pmap; xdr_pmaplist; xdr_pointer;
xdr_reference; xdr_rejected_reply; xdr_replymsg; xdr_rmtcall_args;
xdr_rmtcallres; xdr_short; xdr_string; xdr_u_char; xdr_u_int;
xdr_u_long; xdr_u_short; xdr_union; xdr_unixcred; xdr_vector;
xdr_void; xdr_wrapstring; xdrmem_create; xdrrec_create;
xdrrec_endofrecord; xdrrec_eof; xdrrec_skiprecord; xdrstdio_create;
xencrypt; xprt_register; xprt_unregister;
local: local:
*; *;

View File

@ -192,7 +192,7 @@ main (int argc, char *argv[])
} }
/* `m' requests the names of all available charmaps. The names can be /* `m' requests the names of all available charmaps. The names can be
used for the -f argument to localedef(3). */ used for the -f argument to localedef(1). */
if (do_charmaps != 0) if (do_charmaps != 0)
{ {
write_charmaps (); write_charmaps ();
@ -554,6 +554,25 @@ show_locale_vars (void)
} }
/* Some of the "string" we print contain non-printable characters. We
encode them here. */
static void
print_escaped (const char *string)
{
const unsigned char *ch;
ch = string;
while ('\0' != *ch)
{
if (isprint (*ch))
putchar (*ch);
else
printf("<0x%02x>", *ch);
++ch;
}
}
/* Show the information request for NAME. */ /* Show the information request for NAME. */
static void static void
show_info (const char *name) show_info (const char *name)
@ -568,9 +587,11 @@ show_info (const char *name)
switch (item->value_type) switch (item->value_type)
{ {
case string: case string:
printf ("%s%s%s", show_keyword_name ? "\"" : "", if (show_keyword_name)
nl_langinfo (item->item_id) ? : "", putchar ('"');
show_keyword_name ? "\"" : ""); print_escaped (nl_langinfo (item->item_id) ? : "");
if (show_keyword_name)
putchar ('"');
break; break;
case stringarray: case stringarray:
{ {
@ -583,11 +604,14 @@ show_info (const char *name)
for (cnt = 0; cnt < item->max - 1; ++cnt) for (cnt = 0; cnt < item->max - 1; ++cnt)
{ {
val = nl_langinfo (item->item_id + cnt); val = nl_langinfo (item->item_id + cnt);
printf ("%s;", val ? : ""); if (val != NULL)
print_escaped (val);
putchar (';');
} }
val = nl_langinfo (item->item_id + cnt); val = nl_langinfo (item->item_id + cnt);
printf ("%s", val ? : ""); if (val != NULL)
print_escaped (val);
if (show_keyword_name) if (show_keyword_name)
putchar ('"'); putchar ('"');

View File

@ -29,9 +29,9 @@
/* The various backends we have. */ /* The various backends we have. */
static int setutent_unknown (int reset);
static int getutent_r_unknown (struct utmp *buffer, struct utmp **result); static int getutent_r_unknown (struct utmp *buffer, struct utmp **result);
static struct utmp *pututline_unknown (const struct utmp *data); static struct utmp *pututline_unknown (const struct utmp *data);
static void setutent_unknown (void);
static void endutent_unknown (void); static void endutent_unknown (void);
/* Initial Jump table. */ /* Initial Jump table. */
@ -58,7 +58,7 @@ __setutent (void)
{ {
__libc_lock_lock (__libc_utmp_lock); __libc_lock_lock (__libc_utmp_lock);
(void) (*__libc_utmp_jump_table->setutent) (1); (*__libc_utmp_jump_table->setutent) ();
__libc_lock_unlock (__libc_utmp_lock); __libc_lock_unlock (__libc_utmp_lock);
} }
@ -66,36 +66,6 @@ weak_alias (__setutent, setutent)
weak_alias (__setutent, setutxent) weak_alias (__setutent, setutxent)
static int
setutent_unknown (int reset)
{
/* We have to test whether it is still not decided which backend to use. */
assert (__libc_utmp_jump_table == &__libc_utmp_unknown_functions);
/* See whether utmpd is running. */
if ((*__libc_utmp_daemon_functions.setutent) (reset))
__libc_utmp_jump_table = &__libc_utmp_daemon_functions;
else
{
/* Use the normal file, but if the current file is _PATH_UTMP or
_PATH_WTMP and the corresponding extended file (with an extra
'x' added to the pathname) exists, we use the extended file,
because the original file is in a different format. */
if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0
&& __access (_PATH_UTMP "x", F_OK) == 0)
__utmpname (_PATH_UTMP "x");
else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0
&& __access (_PATH_WTMP "x", F_OK) == 0)
__utmpname (_PATH_WTMP "x");
(*__libc_utmp_file_functions.setutent) (reset);
__libc_utmp_jump_table = &__libc_utmp_file_functions;
}
return 0;
}
void void
__endutent (void) __endutent (void)
{ {
@ -109,6 +79,20 @@ weak_alias (__endutent, endutent)
weak_alias (__endutent, endutxent) weak_alias (__endutent, endutxent)
static void
setutent_unknown (void)
{
/* See whether utmpd is running. */
if ((*__libc_utmp_daemon_functions.setutent) ())
__libc_utmp_jump_table = &__libc_utmp_daemon_functions;
else
{
(*__libc_utmp_file_functions.setutent) ();
__libc_utmp_jump_table = &__libc_utmp_file_functions;
}
}
static void static void
endutent_unknown (void) endutent_unknown (void)
{ {
@ -136,7 +120,7 @@ static int
getutent_r_unknown (struct utmp *buffer, struct utmp **result) getutent_r_unknown (struct utmp *buffer, struct utmp **result)
{ {
/* It is not yet initialized. */ /* It is not yet initialized. */
setutent_unknown (0); __setutent ();
return (*__libc_utmp_jump_table->getutent_r) (buffer, result); return (*__libc_utmp_jump_table->getutent_r) (buffer, result);
} }
@ -163,7 +147,7 @@ static struct utmp *
pututline_unknown (const struct utmp *data) pututline_unknown (const struct utmp *data)
{ {
/* It is not yet initialized. */ /* It is not yet initialized. */
setutent_unknown (0); __setutent ();
return (*__libc_utmp_jump_table->pututline) (data); return (*__libc_utmp_jump_table->pututline) (data);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com> Contributed by Ulrich Drepper <drepper@cygnus.com>
and Paul Janzen <pcj@primenet.com>, 1996. and Paul Janzen <pcj@primenet.com>, 1996.
@ -55,7 +55,7 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
__libc_lock_lock (__libc_utmp_lock); __libc_lock_lock (__libc_utmp_lock);
/* Not yet initialized. */ /* Not yet initialized. */
if ((*__libc_utmp_jump_table->setutent) (0)) if ((*__libc_utmp_jump_table->setutent) ())
retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result); retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
else else
*result = NULL; *result = NULL;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com> Contributed by Ulrich Drepper <drepper@cygnus.com>
and Paul Janzen <pcj@primenet.com>, 1996. and Paul Janzen <pcj@primenet.com>, 1996.
@ -43,7 +43,7 @@ __getutline_r (const struct utmp *line, struct utmp *buffer,
__libc_lock_lock (__libc_utmp_lock); __libc_lock_lock (__libc_utmp_lock);
/* Not yet initialized. */ /* Not yet initialized. */
if ((*__libc_utmp_jump_table->setutent) (0)) if ((*__libc_utmp_jump_table->setutent) ())
retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result); retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result);
else else
*result = NULL; *result = NULL;

View File

@ -52,6 +52,7 @@ static int get_mtime (int filedes, time_t *timer);
utmp_database * utmp_database *
open_database (const char *file, const char *old_file) open_database (const char *file, const char *old_file)
{ {
mode_t mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH;
utmp_database *database; utmp_database *database;
/* Allocate memory. */ /* Allocate memory. */
@ -65,7 +66,7 @@ open_database (const char *file, const char *old_file)
memset (database, 0, sizeof (utmp_database)); memset (database, 0, sizeof (utmp_database));
/* Open database, create it if it doesn't exist already. */ /* Open database, create it if it doesn't exist already. */
database->fd = open (file, O_RDWR | O_CREAT); database->fd = open (file, O_RDWR | O_CREAT, mode);
if (database->fd < 0) if (database->fd < 0)
{ {
error (0, errno, "%s", file); error (0, errno, "%s", file);
@ -81,7 +82,7 @@ open_database (const char *file, const char *old_file)
if (old_file) if (old_file)
{ {
database->old_fd = open (old_file, O_RDWR); database->old_fd = open (old_file, O_RDWR|O_CREAT, mode);
if (database->old_fd < 0) if (database->old_fd < 0)
{ {
error (0, errno, "%s", old_file); error (0, errno, "%s", old_file);

View File

@ -141,6 +141,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
if (check_pid (_PATH_UTMPDPID)) if (check_pid (_PATH_UTMPDPID))
error (EXIT_FAILURE, 0, _("already running")); error (EXIT_FAILURE, 0, _("already running"));
/* Cleanup files created by a previous `bind'. */
unlink (_PATH_UTMPD_RO);
unlink (_PATH_UTMPD_RW);
/* Open UTMP database. */ /* Open UTMP database. */
utmp_db = open_database (_PATH_UTMP "x", _PATH_UTMP); utmp_db = open_database (_PATH_UTMP "x", _PATH_UTMP);
if (utmp_db == NULL) if (utmp_db == NULL)
@ -248,6 +252,7 @@ make_socket (const char *name)
size = (offsetof (struct sockaddr_un, sun_path) size = (offsetof (struct sockaddr_un, sun_path)
+ strlen (addr.sun_path)); + strlen (addr.sun_path));
if (bind (sock, (struct sockaddr *) &addr, size) < 0) if (bind (sock, (struct sockaddr *) &addr, size) < 0)
error (EXIT_FAILURE, errno, "%s", name); error (EXIT_FAILURE, errno, "%s", name);

View File

@ -24,11 +24,10 @@
#include <utmp.h> #include <utmp.h>
/* The extra `int' argument for each function shows whether locking is /* The structure describing the functions in a backend. */
wanted or not. */
struct utfuncs struct utfuncs
{ {
int (*setutent) (int); int (*setutent) (void);
int (*getutent_r) (struct utmp *, struct utmp **); int (*getutent_r) (struct utmp *, struct utmp **);
int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **); int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **);
int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **); int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **);

View File

@ -35,7 +35,7 @@ static int daemon_sock = INT_MIN;
/* Functions defined here. */ /* Functions defined here. */
static int setutent_daemon (int reset); static int setutent_daemon (void);
static int getutent_r_daemon (struct utmp *buffer, struct utmp **result); static int getutent_r_daemon (struct utmp *buffer, struct utmp **result);
static int getutid_r_daemon (const struct utmp *line, struct utmp *buffer, static int getutid_r_daemon (const struct utmp *line, struct utmp *buffer,
struct utmp **result); struct utmp **result);
@ -74,9 +74,13 @@ static int send_request (int sock, const request_header *request,
static int static int
setutent_daemon (int reset) setutent_daemon (void)
{ {
if (daemon_sock == INT_MIN) if (access (_PATH_UTMPD_RW, F_OK) == -1
&& access (_PATH_UTMPD_RO, F_OK) == -1)
return 0;
if (daemon_sock < 0)
{ {
daemon_sock = open_socket (_PATH_UTMPD_RW); daemon_sock = open_socket (_PATH_UTMPD_RW);
if (daemon_sock < 0) if (daemon_sock < 0)
@ -86,17 +90,11 @@ setutent_daemon (int reset)
if (daemon_sock < 0) if (daemon_sock < 0)
return 0; return 0;
} }
}
/* Send request to the daemon. */ /* Send request to the daemon. */
if (do_setutent (daemon_sock) < 0) if (do_setutent (daemon_sock) < 0)
return 0; return 0;
}
else if (reset)
{
/* Send request to the daemon. */
if (do_setutent (daemon_sock) < 0)
return 0;
}
return 1; return 1;
} }
@ -121,7 +119,7 @@ getutent_r_daemon (struct utmp *buffer, struct utmp **result)
{ {
/* Open connection if not already done. */ /* Open connection if not already done. */
if (daemon_sock == INT_MIN) if (daemon_sock == INT_MIN)
setutent_daemon (1); setutent_daemon ();
if (daemon_sock < 0) if (daemon_sock < 0)
{ {
@ -189,9 +187,9 @@ getutid_r_daemon (const struct utmp *id, struct utmp *buffer,
static struct utmp * static struct utmp *
pututline_daemon (const struct utmp *utmp) pututline_daemon (const struct utmp *utmp)
{ {
/* Open connection if not already done. */
if (daemon_sock == INT_MIN) if (daemon_sock == INT_MIN)
/* The connection is closed. Open it again. */ setutent_daemon ();
setutent_daemon (0);
if (daemon_sock < 0) if (daemon_sock < 0)
/* Something went wrong. */ /* Something went wrong. */
@ -217,7 +215,10 @@ updwtmp_daemon (const char *file, const struct utmp *utmp)
/* Send request to the daemon. */ /* Send request to the daemon. */
if (do_updwtmp (sock, file, utmp) < 0) if (do_updwtmp (sock, file, utmp) < 0)
{
close (sock);
return -1; return -1;
}
close (sock); close (sock);
return 0; return 0;

View File

@ -39,7 +39,7 @@ static struct utmp last_entry;
/* Functions defined here. */ /* Functions defined here. */
static int setutent_file (int reset); static int setutent_file (void);
static int getutent_r_file (struct utmp *buffer, struct utmp **result); static int getutent_r_file (struct utmp *buffer, struct utmp **result);
static int getutid_r_file (const struct utmp *key, struct utmp *buffer, static int getutid_r_file (const struct utmp *key, struct utmp *buffer,
struct utmp **result); struct utmp **result);
@ -63,40 +63,39 @@ struct utfuncs __libc_utmp_file_functions =
static int static int
setutent_file (int reset) setutent_file (void)
{ {
if (file_fd == INT_MIN) if (file_fd < 0)
{ {
file_fd = open (__libc_utmp_file_name, O_RDWR); const char *file_name = __libc_utmp_file_name;
if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0
&& __access (_PATH_UTMP "x", F_OK) == 0)
file_name = _PATH_UTMP "x";
else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0
&& __access (_PATH_WTMP "x", F_OK) == 0)
file_name = _PATH_WTMP "x";
file_fd = open (file_name, O_RDWR);
if (file_fd == -1) if (file_fd == -1)
{ {
/* Hhm, read-write access did not work. Try read-only. */ /* Hhm, read-write access did not work. Try read-only. */
file_fd = open (__libc_utmp_file_name, O_RDONLY); file_fd = open (file_name, O_RDONLY);
if (file_fd == -1) if (file_fd == -1)
{ {
perror (_("while opening UTMP file")); perror (_("while opening UTMP file"));
return 0; return 0;
} }
} }
file_offset = 0;
#if _HAVE_UT_TYPE - 0
/* Make sure the entry won't match. */
last_entry.ut_type = -1;
#endif
} }
else if (reset)
{
lseek (file_fd, 0, SEEK_SET); lseek (file_fd, 0, SEEK_SET);
/* Remember we are at beginning of file. */
file_offset = 0; file_offset = 0;
#if _HAVE_UT_TYPE - 0 #if _HAVE_UT_TYPE - 0
/* Make sure the entry won't match. */ /* Make sure the entry won't match. */
last_entry.ut_type = -1; last_entry.ut_type = -1;
#endif #endif
}
return 1; return 1;
} }
@ -120,7 +119,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
/* Open utmp file if not already done. */ /* Open utmp file if not already done. */
if (file_fd == INT_MIN) if (file_fd == INT_MIN)
setutent_file (1); setutent_file ();
if (file_fd == -1 || file_offset == -1l) if (file_fd == -1 || file_offset == -1l)
{ {
@ -348,14 +347,14 @@ pututline_file (const struct utmp *data)
struct utmp *pbuf; struct utmp *pbuf;
int found; int found;
if (file_fd < 0) /* Open utmp file if not already done. */
if (file_fd == INT_MIN)
setutent_file ();
if (file_fd == -1)
/* Something went wrong. */ /* Something went wrong. */
return NULL; return NULL;
if (file_fd == INT_MIN)
/* The file is closed. Open it again. */
setutent_file (0);
/* Find the correct place to insert the data. */ /* Find the correct place to insert the data. */
if (file_offset > 0 if (file_offset > 0
&& ( && (

View File

@ -430,7 +430,7 @@ until some external condition makes it possible to read, write, or
connect (whatever the operation). You can use @code{select} to find out connect (whatever the operation). You can use @code{select} to find out
when the operation will be possible; @pxref{Waiting for I/O}. when the operation will be possible; @pxref{Waiting for I/O}.
@strong{Portability Note:} In older Unix many systems, this condition @strong{Portability Note:} In older many Unix systems, this condition
was indicated by @code{EWOULDBLOCK}, which was a distinct error code was indicated by @code{EWOULDBLOCK}, which was a distinct error code
different from @code{EAGAIN}. To make your program portable, you should different from @code{EAGAIN}. To make your program portable, you should
check for both codes and treat them the same. check for both codes and treat them the same.

View File

@ -852,7 +852,7 @@ local-address-within-network numbers in host byte order.
@comment arpa/inet.h @comment arpa/inet.h
@comment BSD @comment BSD
@deftypefun {int} inet_aton (const char *@var{name}, struct in_addr *@var{addr}) @deftypefun int inet_aton (const char *@var{name}, struct in_addr *@var{addr})
This function converts the Internet host address @var{name} This function converts the Internet host address @var{name}
from the standard numbers-and-dots notation into binary data and stores from the standard numbers-and-dots notation into binary data and stores
it in the @code{struct in_addr} that @var{addr} points to. it in the @code{struct in_addr} that @var{addr} points to.
@ -917,8 +917,7 @@ address @var{addr}.
@comment arpa/inet.h @comment arpa/inet.h
@comment IPv6 basic API @comment IPv6 basic API
@deftypefun int inet_pton (int @var{af}, const char *@var{cp}, void @deftypefun int inet_pton (int @var{af}, const char *@var{cp}, void *@var{buf})
*@var{buf})
This function converts an Internet address (either IPv4 or IPv6) from This function converts an Internet address (either IPv4 or IPv6) from
presentation (textual) to network (binary) format. @var{af} should be presentation (textual) to network (binary) format. @var{af} should be
either @code{AF_INET} or @code{AF_INET6}, as appropriate for the type of either @code{AF_INET} or @code{AF_INET6}, as appropriate for the type of
@ -929,8 +928,7 @@ responsibility to make sure the buffer is large enough.
@comment arpa/inet.h @comment arpa/inet.h
@comment IPv6 basic API @comment IPv6 basic API
@deftypefun char *inet_ntop(int @var{af}, const void *@var{cp}, char @deftypefun {char *} inet_ntop (int @var{af}, const void *@var{cp}, char *@var{buf}, size_t @var{len})
*@var{buf}, size_t @var{len})
This function converts an Internet address (either IPv4 or IPv6) from This function converts an Internet address (either IPv4 or IPv6) from
network (binary) to presentation (textual) form. @var{af} should be network (binary) to presentation (textual) form. @var{af} should be
either @code{AF_INET} or @code{AF_INET6}, as appropriate. @var{cp} is a either @code{AF_INET} or @code{AF_INET6}, as appropriate. @var{cp} is a

View File

@ -595,35 +595,6 @@ check_int (const char *test_name, int computed, int expected)
fpstack_test (test_name); fpstack_test (test_name);
} }
static void
check_int_exc (const char *test_name, int computed, int expected,
short exception)
{
int diff = computed - expected;
int result = diff == 0;
output_new_test (test_name);
test_exceptions (test_name, exception);
if (result)
{
output_pass_value ();
}
else
{
output_fail_value (test_name);
if (verbose > 1)
{
printf ("Result:\n");
printf (" is: %d\n", computed);
printf (" should be: %d\n", expected);
}
noErrors++;
}
fpstack_test (test_name);
}
/* /*
check that computed and expected values are equal (long int values) check that computed and expected values are equal (long int values)

View File

@ -36,6 +36,7 @@ libcrypt-map := libcrypt.map
onlymd5-routines := onlymd5-entry md5-crypt md5 onlymd5-routines := onlymd5-entry md5-crypt md5
distribute += onlymd5-entry.c distribute += onlymd5-entry.c
extra-objs := onlymd5-entry.o
include ../Makeconfig include ../Makeconfig

View File

@ -21,7 +21,7 @@
# #
subdir := nis subdir := nis
headers := $(wildcard rpcsvc/*.[hx]) headers := $(wildcard rpcsvc/*.[hx]) bits/nislib.h
distribute := nss-nis.h nss-nisplus.h nis_intern.h Banner \ distribute := nss-nis.h nss-nisplus.h nis_intern.h Banner \
nisplus-parser.h nisplus-parser.h

View File

@ -27,7 +27,6 @@
#include <rpcsvc/yp.h> #include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h> #include <rpcsvc/ypclnt.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include <nsswitch.h> #include <nsswitch.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -28,7 +28,6 @@
#include <rpcsvc/yp.h> #include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h> #include <rpcsvc/ypclnt.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include <nsswitch.h> #include <nsswitch.h>
#include "netgroup.h" #include "netgroup.h"

View File

@ -28,7 +28,6 @@
#include <rpcsvc/yp.h> #include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h> #include <rpcsvc/ypclnt.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include <nsswitch.h> #include <nsswitch.h>
#include "netgroup.h" #include "netgroup.h"

View File

@ -24,7 +24,6 @@
#include <aliases.h> #include <aliases.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"
@ -153,6 +152,8 @@ _nss_nisplus_parse_aliasent (nis_result *result, unsigned long entry,
static enum nss_status static enum nss_status
internal_setaliasent (void) internal_setaliasent (void)
{ {
enum nss_status status;
if (result) if (result)
nis_freeresult (result); nis_freeresult (result);
result = NULL; result = NULL;
@ -162,12 +163,13 @@ internal_setaliasent (void)
next_entry = 0; next_entry = 0;
result = nis_list(tablename_val, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); result = nis_list(tablename_val, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) status = niserr2nss (result->status);
if (status != NSS_STATUS_SUCCESS)
{ {
nis_freeresult (result); nis_freeresult (result);
result = NULL; result = NULL;
} }
return niserr2nss (result->status); return status;
} }
enum nss_status enum nss_status
@ -206,7 +208,13 @@ internal_nisplus_getaliasent_r (struct aliasent *alias,
int parse_res; int parse_res;
if (result == NULL) if (result == NULL)
internal_setaliasent (); {
enum nss_status status;
status = internal_setaliasent ();
if (result == NULL || status != NSS_STATUS_SUCCESS)
return status;
}
/* Get the next entry until we found a correct one. */ /* Get the next entry until we found a correct one. */
do do

View File

@ -25,7 +25,6 @@
#include <netdb.h> #include <netdb.h>
#include <netinet/ether.h> #include <netinet/ether.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"
@ -294,4 +293,3 @@ _nss_nisplus_getntohost_r (const struct ether_addr *addr,
} }
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
} }

View File

@ -24,7 +24,6 @@
#include <string.h> #include <string.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"
#include "nisplus-parser.h" #include "nisplus-parser.h"
@ -57,6 +56,8 @@ _nss_create_tablename (void)
static enum nss_status static enum nss_status
internal_setgrent (void) internal_setgrent (void)
{ {
enum nss_status status;
if (result) if (result)
nis_freeresult (result); nis_freeresult (result);
result = NULL; result = NULL;
@ -67,12 +68,13 @@ internal_setgrent (void)
return NSS_STATUS_UNAVAIL; return NSS_STATUS_UNAVAIL;
result = nis_list (tablename_val, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL); result = nis_list (tablename_val, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL);
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) status = niserr2nss (result->status);
if (status != NSS_STATUS_SUCCESS)
{ {
nis_freeresult (result); nis_freeresult (result);
result = NULL; result = NULL;
} }
return niserr2nss (result->status); return status;
} }
enum nss_status enum nss_status
@ -109,7 +111,13 @@ internal_nisplus_getgrent_r (struct group *gr, char *buffer, size_t buflen)
int parse_res; int parse_res;
if (result == NULL) if (result == NULL)
internal_setgrent (); {
enum nss_status status;
status = internal_setgrent ();
if (result == NULL || status != NSS_STATUS_SUCCESS)
return status;
}
/* Get the next entry until we found a correct one. */ /* Get the next entry until we found a correct one. */
do do

View File

@ -26,7 +26,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -25,7 +25,6 @@
#include <netgroup.h> #include <netgroup.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -25,7 +25,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -212,20 +212,23 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry,
room_left -= sizeof (char *); room_left -= sizeof (char *);
gr->gr_mem[count] = line; gr->gr_mem[count] = line;
while (*line != '\0' && *line != ',' && !isspace(*line)) while (*line != '\0' && *line != ',' && !isspace (*line))
++line; ++line;
if (line != gr->gr_mem[count]) if (*line == ',' || isspace (*line))
{
if (*line != '\0')
{ {
int is = isspace (*line);
*line = '\0'; *line = '\0';
if (is)
while (*line != '\0' && (*line == ',' || isspace (*line)))
++line;
else
++line; ++line;
}
++count; ++count;
} }
else else
gr->gr_mem[count] = NULL; gr->gr_mem[count+1] = NULL;
} }
if (room_left < sizeof (char *)) if (room_left < sizeof (char *))
goto no_more_room; goto no_more_room;

View File

@ -24,7 +24,6 @@
#include <string.h> #include <string.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -25,7 +25,6 @@
#include <syslog.h> #include <syslog.h>
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#ifdef HAVE_SECURE_RPC #ifdef HAVE_SECURE_RPC
#include <rpc/key_prot.h> #include <rpc/key_prot.h>
extern int xdecrypt (char *, char *); extern int xdecrypt (char *, char *);

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -24,7 +24,6 @@
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpc/netdb.h> #include <rpc/netdb.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -24,7 +24,6 @@
#include <string.h> #include <string.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
#include <rpcsvc/nis.h> #include <rpcsvc/nis.h>
#include <rpcsvc/nislib.h>
#include "nss-nisplus.h" #include "nss-nisplus.h"
#include "nisplus-parser.h" #include "nisplus-parser.h"

View File

@ -767,7 +767,7 @@ typedef enum name_pos name_pos;
#endif #endif
/* Prototypes, and extern declarations for the NIS library functions. */ /* Prototypes, and extern declarations for the NIS library functions. */
#include <rpcsvc/nislib.h> #include <bits/nislib.h>
#endif /* __NIS_RPCGEN_H */ #endif /* __NIS_RPCGEN_H */
/* EDIT_START */ /* EDIT_START */

View File

@ -423,7 +423,7 @@ program NIS_PROG {
%#endif %#endif
% %
%/* Prototypes, and extern declarations for the NIS library functions. */ %/* Prototypes, and extern declarations for the NIS library functions. */
%#include <rpcsvc/nislib.h> %#include <bits/nislib.h>
%#endif /* __NIS_RPCGEN_H */ %#endif /* __NIS_RPCGEN_H */
%/* EDIT_START */ %/* EDIT_START */
% %

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,20 @@ GLIBC_2.0 {
inet_net_ntop; inet_net_pton; inet_neta; res_gethostbyaddr; inet_net_ntop; inet_net_pton; inet_neta; res_gethostbyaddr;
res_gethostbyname; res_gethostbyname2; res_mkquery; res_query; res_gethostbyname; res_gethostbyname2; res_mkquery; res_query;
res_querydomain; res_search; res_send_setqhook; res_send_setrhook; res_querydomain; res_search; res_send_setqhook; res_send_setrhook;
__res_dnok; __res_hnok; __p_class; __hostalias; __dn_skipname; # Variables
__p_type; __p_class_syms; __p_type_syms;
# Private routines shared between libc/net, named, nslookup and others.
__b64_ntop; __b64_pton;
__dn_comp; __dn_count_labels; __dn_skipname;
__fp_nquery; __fp_query; __fp_resstat; __hostalias;
__loc_aton; __loc_ntoa;
__p_cdname; __p_cdnname; __p_class; __p_fqname; __p_fqnname; __p_option;
__p_query; __p_rr; __p_secstodate; __p_time; __p_type;
__putlong; __putshort;
__res_close; __res_dnok; __res_hnok; __res_isourserver; __res_mailok;
__res_nameinquery; __res_ownok; __res_queriesmatch;
__res_send;
__sym_ntop; __sym_ntos; __sym_ston;
local: local:
*; *;

View File

@ -30,11 +30,11 @@
#include <ctype.h> #include <ctype.h>
#include <float.h> #include <float.h>
#include <gmp-mparam.h> #include <gmp-mparam.h>
#include "../stdlib/gmp.h" #include <stdlib/gmp.h>
#include "../stdlib/gmp-impl.h" #include <stdlib/gmp-impl.h>
#include "../stdlib/longlong.h" #include <stdlib/longlong.h>
#include "../stdlib/fpioconst.h" #include <stdlib/fpioconst.h>
#include "../locale/localeinfo.h" #include <locale/localeinfo.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <printf.h> #include <printf.h>

View File

@ -27,7 +27,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "_itoa.h" #include "_itoa.h"
#include "../locale/localeinfo.h" #include <locale/localeinfo.h>
/* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */ /* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */
#include <assert.h> #include <assert.h>

View File

@ -87,8 +87,11 @@ static const struct severity_info infosev =
/* Start of the list. */ /* Start of the list. */
static struct severity_info *severity_list = (struct severity_info *) &infosev; static struct severity_info *severity_list = (struct severity_info *) &infosev;
/* Mask of values we will print. */
static int print;
/* Prototypes for local functions. */ /* Prototypes for local functions. */
static void init (void);
static int internal_addseverity (int severity, const char *string); static int internal_addseverity (int severity, const char *string);
@ -96,100 +99,12 @@ int
fmtmsg (long int classification, const char *label, int severity, fmtmsg (long int classification, const char *label, int severity,
const char *text, const char *action, const char *tag) const char *text, const char *action, const char *tag)
{ {
static int print = -1; __libc_once_define (once);
int result = MM_OK; int result = MM_OK;
struct severity_info *severity_rec; struct severity_info *severity_rec;
if (print == -1) /* make sure everything is initialized. */
{ __libc_once (once, init);
__libc_lock_lock (lock);
if (print == -1)
{
const char *msgverb_var = getenv ("MSGVERB");
const char *sevlevel_var = getenv ("SEV_LEVEL");
if (msgverb_var != NULL && msgverb_var[0] != '\0')
{
/* Using this extra variable allows us to work without
locking. */
print = 0;
do
{
size_t cnt;
for (cnt = 0; cnt < NKEYWORDS; ++cnt)
if (memcmp (msgverb_var,
keywords[cnt].name, keywords[cnt].len) == 0
&& (msgverb_var[keywords[cnt].len] == ':'
|| msgverb_var[keywords[cnt].len] == '\0'))
break;
if (cnt < NKEYWORDS)
{
print |= 1 << cnt;
msgverb_var += keywords[cnt].len;
if (msgverb_var[0] == ':')
++msgverb_var;
}
else
{
/* We found an illegal keyword in the
environment variable. The specifications say
that we print all fields. */
print = all_mask;
break;
}
}
while (msgverb_var[0] != '\0');
}
else
print = all_mask;
if (sevlevel_var != NULL)
while (sevlevel_var[0] != '\0')
{
const char *end = strchr (sevlevel_var, ':');
int level;
if (end == NULL)
end = strchr (sevlevel_var, '\0');
/* First field: keyword. This is not used here but it
must be present. */
while (sevlevel_var < end)
if (*sevlevel_var++ == ',')
break;
if (sevlevel_var < end)
{
/* Second field: severity level, a number. */
char *cp;
level = strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
const char *new_string;
new_string = __strndup (cp, end - cp);
if (new_string != NULL
&& (internal_addseverity (level, new_string)
!= MM_OK))
free ((char *) new_string);
}
}
sevlevel_var = end + (*end == ':' ? 1 : 0);
}
}
__libc_lock_unlock (lock);
}
/* Start the real work. First check whether the input is ok. */ /* Start the real work. First check whether the input is ok. */
if (label != MM_NULLLBL) if (label != MM_NULLLBL)
@ -268,6 +183,94 @@ fmtmsg (long int classification, const char *label, int severity,
} }
/* Initialize from environment variable content. */
static void
init (void)
{
const char *msgverb_var = getenv ("MSGVERB");
const char *sevlevel_var = getenv ("SEV_LEVEL");
if (msgverb_var != NULL && msgverb_var[0] != '\0')
{
/* Using this extra variable allows us to work without locking. */
do
{
size_t cnt;
for (cnt = 0; cnt < NKEYWORDS; ++cnt)
if (memcmp (msgverb_var,
keywords[cnt].name, keywords[cnt].len) == 0
&& (msgverb_var[keywords[cnt].len] == ':'
|| msgverb_var[keywords[cnt].len] == '\0'))
break;
if (cnt < NKEYWORDS)
{
print |= 1 << cnt;
msgverb_var += keywords[cnt].len;
if (msgverb_var[0] == ':')
++msgverb_var;
}
else
{
/* We found an illegal keyword in the environment
variable. The specifications say that we print all
fields. */
print = all_mask;
break;
}
}
while (msgverb_var[0] != '\0');
}
else
print = all_mask;
if (sevlevel_var != NULL)
{
__libc_lock_lock (lock);
while (sevlevel_var[0] != '\0')
{
const char *end = strchr (sevlevel_var, ':');
int level;
if (end == NULL)
end = strchr (sevlevel_var, '\0');
/* First field: keyword. This is not used here but it must be
present. */
while (sevlevel_var < end)
if (*sevlevel_var++ == ',')
break;
if (sevlevel_var < end)
{
/* Second field: severity level, a number. */
char *cp;
level = strtol (sevlevel_var, &cp, 0);
if (cp != sevlevel_var && cp < end && *cp++ == ','
&& level > MM_INFO)
{
const char *new_string;
new_string = __strndup (cp, end - cp);
if (new_string != NULL
&& (internal_addseverity (level, new_string)
!= MM_OK))
free ((char *) new_string);
}
}
sevlevel_var = end + (*end == ':' ? 1 : 0);
}
}
}
/* Add the new entry to the list. */ /* Add the new entry to the list. */
static int static int
internal_addseverity (int severity, const char *string) internal_addseverity (int severity, const char *string)

84
sysdeps/generic/bits/in.h Normal file
View File

@ -0,0 +1,84 @@
/* Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Generic version. */
#ifndef _NETINET_INBITS_H
#define _NETINET_INBITS_H 1
/* Link numbers. */
#define IMPLINK_IP 155
#define IMPLINK_LOWEXPER 156
#define IMPLINK_HIGHEXPER 158
/* Options for use with `getsockopt' and `setsockopt' at the IP level.
The first word in the comment at the right is the data type used;
"bool" means a boolean value stored in an `int'. */
#define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */
#define IP_HDRINCL 2 /* int; Header is included with data. */
#define IP_TOS 3 /* int; IP type of service and precedence. */
#define IP_TTL 4 /* int; IP time to live. */
#define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */
#define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */
#define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */
#define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */
#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */
#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
#define IP_MULTICAST_LOOP 11 /* i_char; set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
The `ip_dst' field is used for the first-hop gateway when using a
source route (this gets put into the header proper). */
struct ip_opts
{
struct in_addr ip_dst; /* First hop; zero without source route. */
char ip_opts[40]; /* Actually variable in size. */
};
/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */
struct ip_mreq
{
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
};
/* IPV6 socket options. */
#define IPV6_ADDRFORM 1
#define IPV6_RXINFO 2
#define IPV6_RXHOPOPTS 3
#define IPV6_RXDSTOPTS 4
#define IPV6_RXSRCRT 5
#define IPV6_PKTOPTIONS 6
#define IPV6_CHECKSUM 7
#define IPV6_HOPLIMIT 8
#define IPV6_TXINFO IPV6_RXINFO
#define SCM_SRCINFO IPV6_TXINFO
#define SCM_SRCRT IPV6_RXSRCRT
#define IPV6_UNICAST_HOPS 16
#define IPV6_MULTICAST_IF 17
#define IPV6_MULTICAST_HOPS 18
#define IPV6_MULTICAST_LOOP 19
#define IPV6_ADD_MEMBERSHIP 20
#define IPV6_DROP_MEMBERSHIP 21
#endif /* netinet/inbits.h */

View File

@ -29,28 +29,30 @@
__BEGIN_DECLS __BEGIN_DECLS
struct crypt_data
{
char keysched[(16 * 8) / sizeof (char)];
char sb0[32768 / sizeof (char)];
char sb1[32768 / sizeof (char)];
char sb2[32768 / sizeof (char)];
char sb3[32768 / sizeof (char)];
/* end-of-alignment-critical-data */
char crypt_3_buf[14];
char current_salt[2];
long current_saltbits;
int direction, initialized;
};
/* Encrypt at most 8 characters from KEY using salt to perturb DES. */ /* Encrypt at most 8 characters from KEY using salt to perturb DES. */
extern char *crypt __P ((__const char *__key, __const char *__salt)); extern char *crypt __P ((__const char *__key, __const char *__salt));
#ifdef __USE_GNU
/* Reentrant versions of the functions above. The additional argument /* Reentrant versions of the functions above. The additional argument
points to a structure where the results are placed in. */ points to a structure where the results are placed in. */
struct crypt_data
{
char keysched[16 * 8];
char sb0[32768];
char sb1[32768];
char sb2[32768];
char sb3[32768];
/* end-of-alignment-critical-data */
char crypt_3_buf[14];
char current_salt[2];
long int current_saltbits;
int direction, initialized;
};
extern char *crypt_r __P ((__const char *__key, __const char *__salt, extern char *crypt_r __P ((__const char *__key, __const char *__salt,
struct crypt_data *__data)); struct crypt_data *__data));
#endif
__END_DECLS __END_DECLS

View File

@ -43,7 +43,7 @@ vlimit (resource, value)
return -1; return -1;
lims.rlim_cur = value; lims.rlim_cur = value;
return setrlimit(rlimit_res, &lims); return setrlimit (rlimit_res, &lims);
} }
__set_errno (EINVAL); __set_errno (EINVAL);

View File

@ -38,8 +38,8 @@ vtimes_one (struct vtimes *vt, enum __rusage_who who)
if (getrusage (who, &usage) < 0) if (getrusage (who, &usage) < 0)
return -1; return -1;
vt->vm_utime = TIMEVAL_TO_VTIMES(usage.ru_utime); vt->vm_utime = TIMEVAL_TO_VTIMES (usage.ru_utime);
vt->vm_stime = TIMEVAL_TO_VTIMES(usage.ru_stime); vt->vm_stime = TIMEVAL_TO_VTIMES (usage.ru_stime);
vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss; vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss;
vt->vm_majflt = usage.ru_majflt; vt->vm_majflt = usage.ru_majflt;
vt->vm_minflt = usage.ru_minflt; vt->vm_minflt = usage.ru_minflt;
@ -58,8 +58,8 @@ vtimes (current, child)
struct vtimes *current; struct vtimes *current;
struct vtimes *child; struct vtimes *child;
{ {
if (vtimes_one(current, RUSAGE_SELF) < 0 || if (vtimes_one (current, RUSAGE_SELF) < 0
vtimes_one(child, RUSAGE_CHILDREN) < 0) || vtimes_one (child, RUSAGE_CHILDREN) < 0)
return -1; return -1;
return 0; return 0;
} }

View File

@ -249,7 +249,7 @@ TRANS until some external condition makes it possible to read, write, or
TRANS connect (whatever the operation). You can use @code{select} to find out TRANS connect (whatever the operation). You can use @code{select} to find out
TRANS when the operation will be possible; @pxref{Waiting for I/O}. TRANS when the operation will be possible; @pxref{Waiting for I/O}.
TRANS TRANS
TRANS @strong{Portability Note:} In older Unix many systems, this condition TRANS @strong{Portability Note:} In older many Unix systems, this condition
TRANS was indicated by @code{EWOULDBLOCK}, which was a distinct error code TRANS was indicated by @code{EWOULDBLOCK}, which was a distinct error code
TRANS different from @code{EAGAIN}. To make your program portable, you should TRANS different from @code{EAGAIN}. To make your program portable, you should
TRANS check for both codes and treat them the same. TRANS check for both codes and treat them the same.

View File

@ -0,0 +1 @@
/* We don't need any code here since the setjmp.S file contains it. */

View File

@ -0,0 +1 @@
/* We don't need any code here since the setjmp.S file contains it. */

72
sysdeps/i386/elf/setjmp.S Normal file
View File

@ -0,0 +1,72 @@
/* setjmp for i386, ELF version.
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <sysdep.h>
#define _ASM
#include <bits/setjmp.h>
/* We include the BSD entry points here as well but we make
them weak. */
ENTRY (setjmp)
.weak C_SYMBOL_NAME (setjmp)
popl %eax /* Pop return PC. */
popl %ecx /* Pop jmp_buf argument. */
pushl $1 /* Push second argument of zero. */
pushl %ecx /* Push back first argument. */
pushl %eax /* Push back return PC. */
jmp __sigsetjmp
END (setjmp)
/* Binary compatibility entry point. */
ENTRY (_setjmp)
.weak C_SYMBOL_NAME (_setjmp)
ENTRY (__setjmp)
popl %eax /* Pop return address. */
popl %ecx /* Pop jmp_buf. */
pushl $0 /* Push zero argument. */
pushl %ecx /* Push jmp_buf. */
pushl %eax /* Push back return address. */
ENTRY (__sigsetjmp)
movl 4(%esp), %eax /* User's jmp_buf in %eax. */
/* Save registers. */
movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax)
movl %ebp, (JB_BP*4)(%eax)
leal 4(%esp), %ecx /* Save SP as it will be after we return. */
movl %ecx, (JB_SP*4)(%eax)
movl 0(%esp), %ecx /* Save PC we are returning to now. */
movl %ecx, (JB_PC*4)(%eax)
/* Make a tail call to __sigjmp_save; it takes the same args. */
#ifdef PIC
/* We cannot use the PLT, because it requires that %ebx be set, but
we can't save and restore our caller's value. Instead, we do an
indirect jump through the GOT, using for the temporary register
%ecx, which is call-clobbered. */
call here
here: popl %ecx
addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx
movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx
jmp *%ecx
#else
jmp __sigjmp_save
#endif
END (__sigsetjmp)

View File

@ -29,7 +29,7 @@
all floating-point types. */ all floating-point types. */
# define isgreater(x, y) \ # define isgreater(x, y) \
({ int __result; \ ({ int __result; \
__asm__ ("fucompp; fnstsw; andb $0x45, %%ah; setz %%al;" \ __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al;" \
"andl $0x01, %0" \ "andl $0x01, %0" \
: "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \
__result; }) __result; })
@ -118,11 +118,11 @@
#endif #endif
#define __inline_mathop_decl_(float_type, func, op, params...) \ #define __inline_mathop_decl_(float_type, func, op, params...) \
__MATHINLINE float_type func (float_type); \ __MATH_INLINE float_type func (float_type); \
__MATHINLINE float_type func (float_type __x) \ __MATH_INLINE float_type func (float_type __x) \
{ \ { \
register float_type __result; \ register float_type __result; \
__asm __volatile__ (op : "=t" (__results) : params); \ __asm __volatile__ (op : "=t" (__result) : params); \
return __result; \ return __result; \
} }
@ -163,8 +163,9 @@
} }
/* Optimized inline implementation, sometimes woth reduced precision /* Optimized inline implementation, sometimes with reduced precision
and/or argument range. */ and/or argument range. */
#define __expm1_code \ #define __expm1_code \
register long double __value; \ register long double __value; \
register long double __exponent; \ register long double __exponent; \
@ -266,7 +267,7 @@ __inline_mathcode2 (pow, __x, __y, \
/* NOTREACHED */ \ /* NOTREACHED */ \
} \ } \
__asm __volatile__ \ __asm __volatile__ \
("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st1"); \ ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)"); \
__asm __volatile__ \ __asm __volatile__ \
("fmul %%st(1) # y * log2(x)\n\t" \ ("fmul %%st(1) # y * log2(x)\n\t" \
"fst %%st(1)\n\t" \ "fst %%st(1)\n\t" \
@ -285,26 +286,34 @@ __inline_mathcode2 (pow, __x, __y, \
__inline_mathop (sqrt, "fsqrt") __inline_mathop (sqrt, "fsqrt")
__inline_mathop_ (long double, __sqrtl, "fsqrt") __inline_mathop_ (long double, __sqrtl, "fsqrt")
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 8)
__inline_mathcode_ (fabs, __x, return __builtin_fabs (__x))
__inline_mathcode_ (fabsf, __x, return __builtin_fabsf (__x))
__inline_mathcode_ (fabsl, __x, return __builtin_fabsl (__x))
__inline_mathcode_ (__fabsl, __x, return __builtin_fabsl (__x))
#else
__inline_mathop (fabs, "fabs") __inline_mathop (fabs, "fabs")
__inline_mathop_ (long double, __fabsl, "fabs")
#endif
/* The argument range of this inline version is reduced. */ /* The argument range of this inline version is reduced. */
__inline_mathop (sin, "fsin") __inline_mathop (sin, "fsin")
/* The argument range of this inline version is reduced. */ /* The argument range of this inline version is reduced. */
__inline_mathop (cos, "fcos") __inline_mathop (cos, "fcos")
__inline_mathop (atan, "fld1; fpatan") __inline_mathop_decl (atan, "fpatan", "u" (__x), "0" (1.0) : "st(1)")
__inline_mathop (log, "fldln2; fxch; fyl2x") __inline_mathop (log, "fldln2; fxch; fyl2x")
__inline_mathop (log10, "fldlg2; fxch; fyl2x") __inline_mathop (log10, "fldlg2; fxch; fyl2x")
__inline_mathcode (asin, __x, return __atan2l (__x, __sqrtl (1.0 - __x * __x))) __inline_mathcode (asin, __x, return __atan2l (__x, __sqrtl (1.0 - __x * __x)))
__inline_mathcode (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x)) __inline_mathcode (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x))
__inline_mathcode (__sgn1, __x, return __x >= 0.0 ? 1.0 : -1.0) __inline_mathcode_ (long double, __sgn1l, __x, return __x >= 0.0 ? 1.0 : -1.0)
/* The argument range of the inline version of sinhl is slightly reduced. */ /* The argument range of the inline version of sinhl is slightly reduced. */
__inline_mathcode (sinh, __x, \ __inline_mathcode (sinh, __x, \
register long double __exm1 = __expm1l (__builtin_fabsl (__x)); \ register long double __exm1 = __expm1l (__fabsl (__x)); \
return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x)) return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x))
__inline_mathcode (cosh, __x, \ __inline_mathcode (cosh, __x, \
@ -312,7 +321,7 @@ __inline_mathcode (cosh, __x, \
return 0.5 * (__ex + 1.0 / __ex)) return 0.5 * (__ex + 1.0 / __ex))
__inline_mathcode (tanh, __x, \ __inline_mathcode (tanh, __x, \
register long double __exm1 = __expm1l (-__builtin_fabsl (__x + __x)); \ register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \
return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x)) return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x))
@ -338,6 +347,20 @@ __inline_mathcode (ceil, __x, \
__asm __volatile ("fldcw %0" : : "m" (__cw)); \ __asm __volatile ("fldcw %0" : : "m" (__cw)); \
return __value) return __value)
#define __ldexp_code \
register long double __value; \
__asm __volatile__ \
("fscale" \
: "=t" (__value) : "0" (__x), "u" ((long double) __y)); \
return __value
__MATH_INLINE double ldexp (double __x, int __y);
__MATH_INLINE double
ldexp (double __x, int __y)
{
__ldexp_code;
}
/* Optimized versions for some non-standardized functions. */ /* Optimized versions for some non-standardized functions. */
#if defined __USE_ISOC9X || defined __USE_MISC #if defined __USE_ISOC9X || defined __USE_MISC
@ -352,7 +375,7 @@ __inline_mathcode (expm1, __x, __expm1_code)
__inline_mathcode (log1p, __x, \ __inline_mathcode (log1p, __x, \
register long double __value; \ register long double __value; \
if (__builtin_fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \ if (__fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \
__value = logl (1.0 + __x); \ __value = logl (1.0 + __x); \
else \ else \
__asm __volatile__ \ __asm __volatile__ \
@ -365,7 +388,7 @@ __inline_mathcode (log1p, __x, \
/* The argument range of the inline version of asinhl is slightly reduced. */ /* The argument range of the inline version of asinhl is slightly reduced. */
__inline_mathcode (asinh, __x, \ __inline_mathcode (asinh, __x, \
register long double __y = __builtin_fabsl (__x); \ register long double __y = __fabsl (__x); \
return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) \ return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) \
* __sgn1l (__x)) * __sgn1l (__x))
@ -373,7 +396,7 @@ __inline_mathcode (acosh, __x, \
return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0))) return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0)))
__inline_mathcode (atanh, __x, \ __inline_mathcode (atanh, __x, \
register long double __y = __builtin_fabsl (__x); \ register long double __y = __fabsl (__x); \
return (-0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * \ return (-0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * \
__sgn1l (__x))) __sgn1l (__x)))
@ -389,17 +412,25 @@ __inline_mathcode(logb, __x, \
: "=t" (__junk), "=u" (__value) : "0" (__x)); \ : "=t" (__junk), "=u" (__value) : "0" (__x)); \
return __value) return __value)
__MATH_INLINE float ldexpf (float __x, int __y);
__MATH_INLINE float
ldexpf (float __x, int __y)
{
__ldexp_code;
}
__MATH_INLINE long double ldexpl (long double __x, int __y);
__MATH_INLINE long double
ldexpl (long double __x, int __y)
{
__ldexp_code;
}
__inline_mathcode2 (ldexp, __x, __y, \
register long double __value; \
__asm __volatile__ \
("fscale" \
: "=t" (__value) : "0" (__x), "u" ((long double) __y)); \
return __value)
#endif #endif
#ifdef __USE_MISC #ifdef __USE_MISC
__inline_mathcode2 (drem, __x, __y, \ __inline_mathcode2 (drem, __x, __y, \
register double __value; \ register double __value; \
__asm __volatile__ \ __asm __volatile__ \
@ -431,7 +462,7 @@ __inline_mathcode (__sgn, __x, \
return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)) return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0))
__inline_mathcode (__coshm1, __x, \ __inline_mathcode (__coshm1, __x, \
register long double __exm1 = __expm1l (__builtin_fabsl (__x)); \ register long double __exm1 = __expm1l (__fabsl (__x)); \
return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1) return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1)
__inline_mathcode (__acosh1p, __x, \ __inline_mathcode (__acosh1p, __x, \

View File

@ -80,6 +80,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
{ {
Elf32_Addr *got; Elf32_Addr *got;
extern void _dl_runtime_resolve (Elf32_Word); extern void _dl_runtime_resolve (Elf32_Word);
extern void _dl_runtime_profile (Elf32_Word);
if (l->l_info[DT_JMPREL] && lazy) if (l->l_info[DT_JMPREL] && lazy)
{ {
@ -90,9 +91,22 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
_GLOBAL_OFFSET_TABLE_[2]. */ _GLOBAL_OFFSET_TABLE_[2]. */
got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr); got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr);
got[1] = (Elf32_Addr) l; /* Identify this shared object. */ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
/* This function will get called to fix up the GOT entry
indicated by the offset on the stack, and then jump to the /* The got[2] entry contains the address of a function which gets
resolved address. */ called to get the address of a so far unresolved function and
jump to it. The profiling extension of the dynamic linker allows
to intercept the calls to collect information. In this case we
don't store the address in the GOT so that all future calls also
end in this function. */
if (profile)
{
got[2] = (Elf32_Addr) &_dl_runtime_profile;
/* Say that we really want profiling and the timers are started. */
_dl_profile_map = l;
}
else
/* This function will get called to fix up the GOT entry indicated by
the offset on the stack, and then jump to the resolved address. */
got[2] = (Elf32_Addr) &_dl_runtime_resolve; got[2] = (Elf32_Addr) &_dl_runtime_resolve;
} }
@ -101,16 +115,16 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
/* This code is used in dl-runtime.c to call the `fixup' function /* This code is used in dl-runtime.c to call the `fixup' function
and then redirect to the address it returns. */ and then redirect to the address it returns. */
#define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ #define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \
| Trampoline for _dl_runtime_resolver "| Trampoline for " #fixup_name "
.globl _dl_runtime_resolve .globl " #tramp_name "
.type _dl_runtime_resolve, @function .type " #tramp_name ", @function
_dl_runtime_resolve: " #tramp_name ":
| Save %a0 (struct return address) and %a1. | Save %a0 (struct return address) and %a1.
move.l %a0, -(%sp) move.l %a0, -(%sp)
move.l %a1, -(%sp) move.l %a1, -(%sp)
| Call the real address resolver. | Call the real address resolver.
jbsr fixup jbsr " #fixup_name "
| Restore register %a0 and %a1. | Restore register %a0 and %a1.
move.l (%sp)+, %a1 move.l (%sp)+, %a1
move.l (%sp)+, %a0 move.l (%sp)+, %a0
@ -118,8 +132,17 @@ _dl_runtime_resolve:
addq.l #8, %sp addq.l #8, %sp
| Call real function. | Call real function.
jmp (%d0) jmp (%d0)
.size _dl_runtime_resolve, . - _dl_runtime_resolve .size " #tramp_name ", . - " #tramp_name "\n"
"); #ifndef PROF
#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \
TRAMPOLINE_TEMPLATE (_dl_runtime_profile, profile_fixup));
#else
#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \
".globl _dl_runtime_profile\n" \
".set _dl_runtime_profile, _dl_runtime_resolve");
#endif
#define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1 #define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1
/* The PLT uses Elf32_Rela relocs. */ /* The PLT uses Elf32_Rela relocs. */
#define elf_machine_relplt elf_machine_rela #define elf_machine_relplt elf_machine_rela

View File

@ -100,9 +100,9 @@ elf_machine_load_address (void)
static inline void static inline void
elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
const Elf32_Sym *sym, const struct r_found_version *version) const Elf32_Sym *sym, const struct r_found_version *version,
Elf32_Addr *const reloc_addr)
{ {
Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
Elf32_Addr loadbase; Elf32_Addr loadbase;
if (ELF32_R_TYPE (reloc->r_info) == R_SPARC_RELATIVE) if (ELF32_R_TYPE (reloc->r_info) == R_SPARC_RELATIVE)

View File

@ -70,6 +70,20 @@
/* Unlock the recursive named lock variable. */ /* Unlock the recursive named lock variable. */
#define __libc_lock_unlock_recursive(NAME) #define __libc_lock_unlock_recursive(NAME)
/* Define once control variable. */
#define __libc_once_define(NAME) int NAME = 0
/* Call handler iff the first call. */
#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
do { \
if ((ONCE_CONTROL) == 0) { \
INIT_FUNCTION (); \
(ONCE_CONTROL) = 1; \
} \
} while (0)
/* Start critical region with cleanup. */ /* Start critical region with cleanup. */
#define __libc_cleanup_region_start(FCT, ARG) #define __libc_cleanup_region_start(FCT, ARG)

View File

@ -16,28 +16,36 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <errno.h>
#define __need_NULL #define __need_NULL
#include <stddef.h> #include <stddef.h>
unsigned int unsigned int
if_nametoindex (const char *ifname) if_nametoindex (const char *ifname)
{ {
__set_errno (ENOSYS);
return 0; return 0;
} }
stub_warning (if_nametoindex)
char * char *
if_indextoname (unsigned int ifindex, char *ifname) if_indextoname (unsigned int ifindex, char *ifname)
{ {
__set_errno (ENOSYS);
return NULL; return NULL;
} }
stub_warning (if_indextoname)
void void
if_freenameindex (struct if_nameindex *ifn) if_freenameindex (struct if_nameindex *ifn)
{ {
} }
stub_warning (if_freenameindex)
struct if_nameindex * struct if_nameindex *
if_nameindex (void) if_nameindex (void)
{ {
__set_errno (ENOSYS);
return NULL; return NULL;
} }
stub_warning (if_nameindex)

View File

@ -20,121 +20,158 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <net/if.h> #include <net/if.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <bits/libc-lock.h>
#define IF_INET6_FILENAME "/proc/net/if_inet6" /* Try to get a socket to talk to the kernel. */
static int
/* /proc/net/if_inet6 contains lines that look like this: opensock (void)
*
* fe8000000000000000000000836fc168 0b 00 20 80 sit7
*
* | | | | | |
* address --' | | | | |
* index --------' | | | |
* prefix length ---' | | |
* scope --------------' | |
* flags -----------------' |
* name -------------------------'
*
*/
static int get_one_interface(FILE *fd, char *interface, int iflen, unsigned int *index)
{ {
char buffer[80]; /* Cache the last AF that worked, to avoid many redundant calls to
static char seps[] = " \012"; socket(). */
char *c = buffer; static int sock_af = -1;
char *sp; int fd = -1;
if (!fgets(buffer, 80, fd)) __libc_lock_define_initialized (static, lock);
return 1;
if (strtok_r(buffer, seps, &sp) == NULL) return 1; if (sock_af != -1)
if (c = strtok_r(NULL, seps, &sp), c == NULL) return 1; {
*index = strtoul(c, NULL, 16); fd = socket (sock_af, SOCK_DGRAM, 0);
if (strtok_r(NULL, seps, &sp) == NULL) return 1; if (fd != -1)
if (strtok_r(NULL, seps, &sp) == NULL) return 1; return fd;
if (strtok_r(NULL, seps, &sp) == NULL) return 1; }
if (c = strtok_r(NULL, seps, &sp), c == NULL) return 1;
strncpy(interface, c, iflen); __libc_lock_lock (lock);
if (sock_af != -1)
fd = socket (sock_af, SOCK_DGRAM, 0);
if (fd == -1)
{
fd = socket (sock_af = AF_INET6, SOCK_DGRAM, 0);
if (fd < 0)
fd = socket (sock_af = AF_INET, SOCK_DGRAM, 0);
if (fd < 0)
fd = socket (sock_af = AF_IPX, SOCK_DGRAM, 0);
if (fd < 0)
fd = socket (sock_af = AF_AX25, SOCK_DGRAM, 0);
if (fd < 0)
fd = socket (sock_af = AF_APPLETALK, SOCK_DGRAM, 0);
}
__libc_lock_unlock (lock);
return fd;
}
unsigned int
if_nametoindex (const char *ifname)
{
struct ifreq ifr;
int fd = opensock ();
if (fd < 0)
return 0; return 0;
}
unsigned int if_nametoindex(const char *ifname) strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
{ if (ioctl (fd, SIOGIFINDEX, &ifr) < 0)
FILE *fd = fopen(IF_INET6_FILENAME, "r"); {
char this_ifname[IFNAMSIZ]; close (fd);
unsigned int this_index;
if (!fd) return 0;
while (get_one_interface(fd, this_ifname, IFNAMSIZ, &this_index) == 0) {
if (!strcmp(this_ifname, ifname)) {
fclose(fd);
return this_index;
}
}
fclose(fd);
return 0; return 0;
}
close (fd);
return ifr.ifr_ifindex;
} }
char *if_indextoname(unsigned int ifindex, char *ifname) void
{ if_freenameindex (struct if_nameindex *ifn)
FILE *fd = fopen(IF_INET6_FILENAME, "r");
unsigned int this_index;
if (!fd) return NULL;
while (get_one_interface(fd, ifname, IFNAMSIZ, &this_index) == 0) {
if (this_index == ifindex) {
fclose(fd);
return ifname;
}
}
fclose(fd);
return NULL;
}
void if_freenameindex(struct if_nameindex *ifn)
{ {
struct if_nameindex *ptr = ifn; struct if_nameindex *ptr = ifn;
while (ptr->if_name || ptr->if_index) while (ptr->if_name || ptr->if_index)
{ {
if (ptr->if_name) if (ptr->if_name)
free(ptr->if_name); free (ptr->if_name);
ptr++; ++ptr;
} }
free(ifn); free (ifn);
} }
struct if_nameindex *if_nameindex(void) struct if_nameindex *
if_nameindex (void)
{ {
FILE *fd = fopen(IF_INET6_FILENAME, "r"); int fd = opensock ();
struct if_nameindex *ifn = NULL; struct ifconf ifc;
int nifs = 0; unsigned int rq_ifs = 4, nifs, i;
if (!fd) return NULL; struct if_nameindex *idx = NULL;
if (fd < 0)
return NULL;
ifc.ifc_buf = NULL;
/* Read all the interfaces out of the kernel. */
do do
{ {
struct if_nameindex *newifn; rq_ifs *= 2;
nifs++; ifc.ifc_len = rq_ifs * sizeof (struct ifreq);
newifn = realloc(ifn, nifs*sizeof(struct if_nameindex)); ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
if (!newifn) if (ifc.ifc_buf == NULL)
{ {
/* We ran out of memory. */ close(fd);
if (--nifs)
{
free(ifn[nifs-1].if_name);
ifn[nifs-1].if_name = 0;
ifn[nifs-1].if_index = 0;
if_freenameindex(ifn);
}
return NULL; return NULL;
} }
ifn = newifn; if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
ifn[nifs-1].if_index = 0; goto jump;
ifn[nifs-1].if_name = malloc(IFNAMSIZ); }
if (ifn[nifs-1].if_name == NULL) while ((unsigned int) ifc.ifc_len == (rq_ifs * sizeof (struct ifreq)));
nifs = ifc.ifc_len / sizeof (struct ifreq);
ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len);
idx = malloc ((nifs+1) * sizeof (struct if_nameindex));
if (idx == NULL)
goto jump;
for (i = 0; i < nifs; ++i)
{ {
if_freenameindex(ifn); struct ifreq *ifr = &ifc.ifc_req[i];
return NULL; if ((idx[i].if_name = malloc (strlen (ifr->ifr_name)+1)) == NULL)
{
free (idx);
idx = NULL;
goto jump;
} }
strcpy (idx[i].if_name, ifr->ifr_name);
if (ioctl (fd, SIOGIFINDEX, ifr) < 0)
{
free (idx);
idx = NULL;
goto jump;
} }
while (get_one_interface(fd, ifn[nifs-1].if_name, IFNAMSIZ, idx[i].if_index = ifr->ifr_ifindex;
&ifn[nifs-1].if_index) == 0); }
free(ifn[nifs-1].if_name); idx[i].if_index = 0;
ifn[nifs-1].if_name = NULL; idx[i].if_name = NULL;
fclose(fd);
return ifn; jump:
free (ifc.ifc_buf);
close (fd);
return idx;
}
char *
if_indextoname (unsigned int ifindex, char *ifname)
{
struct if_nameindex *idx = if_nameindex ();
struct if_nameindex *p;
for (p = idx; p->if_index || p->if_name; ++p)
if (p->if_index == ifindex)
{
strncpy (ifname, p->if_name, IFNAMSIZ);
if_freenameindex (idx);
return ifname;
}
if_freenameindex (idx);
return NULL;
} }

View File

@ -52,6 +52,5 @@ ptrace (enum __ptrace_request request, ...)
return res; return res;
} }
__set_errno (-res);
return -1; return -1;
} }

View File

@ -20,7 +20,7 @@
#define _SYS_FSUID_H 1 #define _SYS_FSUID_H 1
#include <features.h> #include <features.h>
#include <gnu/types.h> #include <sys/types.h>
__BEGIN_DECLS __BEGIN_DECLS