diff options
author | Ulrich Drepper <drepper@redhat.com> | 1996-09-22 03:06:42 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1996-09-22 03:06:42 +0000 |
commit | 845dcb57b1de1b8c2ea88cd101d6e5a80181ee4e (patch) | |
tree | c13a286fe36773fc4d7d34af8527956a6ec8838b | |
parent | *** empty log message *** (diff) | |
download | glibc-845dcb57b1de1b8c2ea88cd101d6e5a80181ee4e.tar.gz glibc-845dcb57b1de1b8c2ea88cd101d6e5a80181ee4e.tar.bz2 glibc-845dcb57b1de1b8c2ea88cd101d6e5a80181ee4e.zip |
update from main archive 960921
Sun Sep 22 03:40:52 1996 Ulrich Drepper <drepper@cygnus.com>
* resolv/resolv.h: Update to bind-4.9.5-T4B.
* resolv/base64.c: Likewise.
* resolv/res_debug.c: Likewise.
* resolv/res_query.c: Likewise.
* resolv/gethnamaddr.c: Likewise.
* nss/nss_dns/dns-host.c: Likewise.
* resolv/res_comp.c: Likewise.
* resolv/res_send.c: Likewise.
* resolv/arpa/nameser.h: Likewise. Attention: MAXDNAME is much
higher now.
* resolv/Banner: New file.
* resolv/Makefile (distribute): Add Banner.
Sat Sep 21 19:15:24 1996 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/stub/getsysstats.c: New file.
* sysdeps/unix/sysv/linux/getsysstats.c: New file.
* misc/Makefile (headers): Add sys/sysinfo.h.
(routines): Add getsysstats.
* sysdeps/unix/sysv/linux/Makefile [$(subdir)==misc]
(sysdep_headers): Remove sys/sysinfo.h.
* sysdeps/generic/sys/sysinfo.h: New file.
* sysdeps/unix/sysv/linux/sys/sysinfo.h: Add prototype for get_nprocs,
get_phys_pages, and get_avphys_pages.
* misc/Makefile (routines): Add mntent_r.
* misc/mntent_r.c: New file.
* misc/mntent.c: Remove all functions but getmntent and use
__getmntent_r.
* misc/mntent.h: Add prototype for __getmntent_r.
* misc/fstab.c: Use __getmntent_r function instead of getmntent.
This will not clobber the state in getmntent.
* sysdeps/generic/confname.h: Add _SC_PROCESSORS_CONF,
_SC_NPROCESSORS_ONLN, _SC_PHYS_PAGES, _SC_AVPHYS_PAGES,
_SC_ATEXIT_MAX, and _SC_PASS_MAX.
* sysdeps/stub/sysconf.c: Add handling _SC_PROCESSORS_CONF and
_SC_NPROCESSORS_ONLN by calling __get_nprocs, _SC_PHYS_PAGES by
calling __get_phys_pages, _SY_AVPHYS_PAGES by calling
__get_avphys_pages, _SC_ATEXIT_MAX and _SC_PASS_MAX.
* sysdeps/posix/sysconf.c: Likewise.
* posix/getconf.c (vars): Add _NPROCESSORS_CONF, _NPROCESSORS_ONLN,
_PHYS_PAGES, _AVPHYS_PAGES, ATEXIT_MAX, and PASS_MAX entries.
Sat Sep 21 05:20:36 1996 Ulrich Drepper <drepper@cygnus.com>
* version.h (VERSION): Bump to 1.95.
* Make-dist (+tsrcs): Don't filter out files in subdirs which
match files in the sysdeps hierachy (welcome back,
sys/syscall.h!).
* resolv/Makefile (libresolv-routines): Remove getnetnamad.
Sat Sep 21 03:00:19 1996 Ulrich Drepper <drepper@cygnus.com>
* locale/loadlocale.c (_nl_free_locale): Remove function.
* locale/localeinfo.h: Remove prototype for _nl_free_locale.
* locale/setlocale.c (setlocale): Don't free locale data of
categories which succeeded to load after a wrong or missing data
file was observed.
* locale/setlocale (setlocale): Initialize NEWNAME correctly so
that it works even when the locale data is not used.
* stdlib/random_r.c: Fix typo in comment.
* stdlib/drand48-iter.c: Likewise.
* stdlib/drand48.c: Likewise.
* stdlib/erand48.c: Likewise.
* stdlib/jrand48.c: Likewise.
* stdlib/lcong48.c: Likewise.
* stdlib/lrand48.c: Likewise.
* stdlib/mrand48.c: Likewise.
* stdlib/nrand48.c: Likewise.
* stdlib/random.c: Likewise.
* stdlib/seed48.c: Likewise.
* stdlib/srand48.c: Likewise.
* misc/search.h: Likewise.
* misc/hsearch.c: Likewise.
* misc/hsearch_r.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location):
Thu Sep 19 23:36:19 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* hurd/hurdinit.c (__libc_argv): Provide common decl.
(_hurd_setproc): Don't declare __libc_argv here.
52 files changed, 1011 insertions, 304 deletions
@@ -56,6 +56,91 @@ Thu Sep 12 23:58:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> __funlockfile can't be protected the way the use of __flockfile can be. +Sun Sep 22 03:40:52 1996 Ulrich Drepper <drepper@cygnus.com> + + * resolv/resolv.h: Update to bind-4.9.5-T4B. + * resolv/base64.c: Likewise. + * resolv/res_debug.c: Likewise. + * resolv/res_query.c: Likewise. + * resolv/gethnamaddr.c: Likewise. + * nss/nss_dns/dns-host.c: Likewise. + * resolv/res_comp.c: Likewise. + * resolv/res_send.c: Likewise. + * resolv/arpa/nameser.h: Likewise. Attention: MAXDNAME is much + higher now. + + * resolv/Banner: New file. + * resolv/Makefile (distribute): Add Banner. + +Sat Sep 21 19:15:24 1996 Ulrich Drepper <drepper@cygnus.com> + + * sysdeps/stub/getsysstats.c: New file. + * sysdeps/unix/sysv/linux/getsysstats.c: New file. + + * misc/Makefile (headers): Add sys/sysinfo.h. + (routines): Add getsysstats. + * sysdeps/unix/sysv/linux/Makefile [$(subdir)==misc] + (sysdep_headers): Remove sys/sysinfo.h. + * sysdeps/generic/sys/sysinfo.h: New file. + * sysdeps/unix/sysv/linux/sys/sysinfo.h: Add prototype for get_nprocs, + get_phys_pages, and get_avphys_pages. + + * misc/Makefile (routines): Add mntent_r. + * misc/mntent_r.c: New file. + * misc/mntent.c: Remove all functions but getmntent and use + __getmntent_r. + * misc/mntent.h: Add prototype for __getmntent_r. + * misc/fstab.c: Use __getmntent_r function instead of getmntent. + This will not clobber the state in getmntent. + + * sysdeps/generic/confname.h: Add _SC_PROCESSORS_CONF, + _SC_NPROCESSORS_ONLN, _SC_PHYS_PAGES, _SC_AVPHYS_PAGES, + _SC_ATEXIT_MAX, and _SC_PASS_MAX. + * sysdeps/stub/sysconf.c: Add handling _SC_PROCESSORS_CONF and + _SC_NPROCESSORS_ONLN by calling __get_nprocs, _SC_PHYS_PAGES by + calling __get_phys_pages, _SY_AVPHYS_PAGES by calling + __get_avphys_pages, _SC_ATEXIT_MAX and _SC_PASS_MAX. + * sysdeps/posix/sysconf.c: Likewise. + * posix/getconf.c (vars): Add _NPROCESSORS_CONF, _NPROCESSORS_ONLN, + _PHYS_PAGES, _AVPHYS_PAGES, ATEXIT_MAX, and PASS_MAX entries. + +Sat Sep 21 05:20:36 1996 Ulrich Drepper <drepper@cygnus.com> + + * version.h (VERSION): Bump to 1.95. + + * Make-dist (+tsrcs): Don't filter out files in subdirs which + match files in the sysdeps hierachy (welcome back, + sys/syscall.h!). + + * resolv/Makefile (libresolv-routines): Remove getnetnamad. + +Sat Sep 21 03:00:19 1996 Ulrich Drepper <drepper@cygnus.com> + + * locale/loadlocale.c (_nl_free_locale): Remove function. + * locale/localeinfo.h: Remove prototype for _nl_free_locale. + * locale/setlocale.c (setlocale): Don't free locale data of + categories which succeeded to load after a wrong or missing data + file was observed. + + * locale/setlocale (setlocale): Initialize NEWNAME correctly so + that it works even when the locale data is not used. + + * stdlib/random_r.c: Fix typo in comment. + * stdlib/drand48-iter.c: Likewise. + * stdlib/drand48.c: Likewise. + * stdlib/erand48.c: Likewise. + * stdlib/jrand48.c: Likewise. + * stdlib/lcong48.c: Likewise. + * stdlib/lrand48.c: Likewise. + * stdlib/mrand48.c: Likewise. + * stdlib/nrand48.c: Likewise. + * stdlib/random.c: Likewise. + * stdlib/seed48.c: Likewise. + * stdlib/srand48.c: Likewise. + * misc/search.h: Likewise. + * misc/hsearch.c: Likewise. + * misc/hsearch_r.c: Likewise. + Thu Sep 19 21:50:55 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/posix/gettimeofday.c (__gettimeofday): Use localtime_r @@ -68,7 +153,7 @@ Thu Sep 19 21:50:55 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/i386/sysdep.S (__errno_location): Define even if !_LIBC_REENTRANT. - * sysdeps/unix/sysv/linux/i386/sysdep.S (__errno_location): + * sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location): Likewise. * sysdeps/posix/cuserid.h: Remove prototype for geteuid(). @@ -256,6 +341,11 @@ Thu Sep 12 19:56:07 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund. * inet/herrno.c (__h_errno_location): Fix return type. +Thu Sep 19 23:36:19 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * hurd/hurdinit.c (__libc_argv): Provide common decl. + (_hurd_setproc): Don't declare __libc_argv here. + Fri Sep 13 04:33:08 1996 Ulrich Drepper <drepper@cygnus.com> * sched.h: New file. Helper to access posix/sched.h. @@ -49,6 +49,12 @@ please let me know. [Q13] ``How do I configure GNU libc so that the essential libraries like libc.so go into /lib and the other into /usr/lib?'' + +[Q14] ``When linking with the new libc I get unresolved symbols + `crypt' and `setkey'. Why aren't these functions in the + libc anymore?'' + +[Q15] ``What are these `add-ons'?'' ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ [Q1] ``What systems does the GNU C Library run on?'' @@ -369,6 +375,56 @@ in a directory named /etc. ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +[Q14] ``When linking with the new libc I get unresolved symbols + `crypt' and `setkey'. Why aren't these functions in the + libc anymore?'' + +[A14] {UD} Remember the US restrictions of exporting cryptographic +programs and source code. Until this law gets abolished we cannot +ship the cryptographic function together with the libc. + +But of course we provide the code and there is an very easy way to use +this code. First get the extra package. People in the US way get it +from the same place they got the GNU libc from. People outside the US +should get the code from ftp.uni-c.dk [129.142.6.74], or another +archive site outside the USA. The README explains how to install the +sources. + +If you already have the crypt code on your system the reason for the +failure is probably that you failed to link with -lcrypt. The crypto +functions are in a separate library to make it possible to export GNU +libc binaries from the US. + + +~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +[Q15] ``What are these `add-ons'?'' + +[A15] {UD} To avoid complications with external or external source +code some optional parts of the libc are distributed as separate +packages (e.g., the crypt package, see Q14). + +To ease the use as part of GNU libc the installer just has to unpack +the package and tell the configuration script about these additional +subdirectories using the --enable-add-ons option. When you add the +crypt add-on you just have to use + + configure --enable-add-ons=crypt,XXX ... + +where XXX are possible other add-ons and ... means the rest of the +normal option list. + +You can use add-ons also to overwrite some files in glibc. The add-on +system dependent subdirs are search first. It is also possible to add +banner files (use a file named `Banner') or create shared libraries. + +Using add-ons has the big advantage that the makefiles of the GNU libc +can be used. Only some few stub rules must be written to get +everything running. Even handling of architecture dependent +compilation is provided. The GNU libc's sysdeps/ directory shows how +to use this feature. + + +~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Answers were given by: {UD} Ulrich Drepper, <drepper@cygnus.com> @@ -157,7 +157,7 @@ build the GNU C library: recommend you port GNU `make' instead. *Really.* We recommend version GNU `make' version 3.75 or later. - * GCC 2.7.2 + * GCC 2.7.2.1 On most platforms, the GNU C library can only be compiled with the GNU C compiler. We recommend GCC version 2.7.2 or later; earlier @@ -177,14 +177,19 @@ Supported Configurations The GNU C Library currently supports configurations that match the following patterns: - alpha-dec-osf1 alpha-ANYTHING-linux alpha-ANYTHING-linuxecoff - iX86-ANYTHING-bsd4.3 iX86-ANYTHING-gnu + iX86-ANYTHING-linux + m68k-ANYTHING-linux + + Former versions of this library used to support the following +configurations but the current status is unknown: + + alpha-dec-osf1 + iX86-ANYTHING-bsd4.3 iX86-ANYTHING-isc2.2 iX86-ANYTHING-isc3.N - iX86-ANYTHING-linux iX86-ANYTHING-sco3.2 iX86-ANYTHING-sco3.2v4 iX86-ANYTHING-sysv @@ -911,4 +916,3 @@ parts of the library were contributed or worked on by other people. or `Software.Distribution@CS.CMU.EDU' any improvements or extensions that they make and grant Carnegie Mellon the rights to redistribute these changes. - @@ -113,8 +113,7 @@ sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s) $(addsuffix .c,$(sysdep_routines)) \ $(+subdir-nodist) #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2) -+tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \ - $(sources) $(all-headers) $(distribute)) \ ++tsrcs := $(filter-out $(+out), $(sources) $(all-headers) $(distribute)) \ $(+sysdeps) foo:=$(shell echo 'made +tsrcs=$(+tsrcs)'>&2) foo:=$(shell echo generated='$(generated)' >&2) @@ -104,7 +104,7 @@ Version 2.0 * The new header file <fts.h> and suite of functions simplify programs that operate on directory trees. This code comes from 4.4 BSD. -* The resolver code has been updated from the BIND 4.9.5-T3A release. +* The resolver code has been updated from the BIND 4.9.5-T4B release. * The new function `malloc_find_object_address' finds the starting address of a malloc'd block, given any address within the block; @@ -2,21 +2,28 @@ This directory contains the version 1.94 test release of the GNU C Library. Many bugs have been fixed since the last release. Some bugs surely remain. -As of this release, the GNU C library has been ported to the following +As of this release, the GNU C library is known to run on the following configurations: + *-*-gnu GNU Hurd + i[3456]86-*-linux Linux-2.0 on Intel + m68k-*-linux Linux-2.0 on Motorola 680x0 + alpha-*-linux Linux-2.0 on DEC Alpha + + +Former releases of this library (version 1.09.1 and perhaps earlier +versions) used to run on the following configurations: + alpha-dec-osf1 - i[345]86-*-bsd4.3 - i[345]86-*-gnu - i[345]86-*-isc2.2 - i[345]86-*-isc3 - i[345]86-*-linux - i[345]86-*-sco3.2 - i[345]86-*-sco3.2v4 - i[345]86-*-sysv - i[345]86-*-sysv4 - i[345]86-force_cpu386-none - i[345]86-sequent-bsd + i[3456]86-*-bsd4.3 + i[3456]86-*-isc2.2 + i[3456]86-*-isc3 + i[3456]86-*-sco3.2 + i[3456]86-*-sco3.2v4 + i[3456]86-*-sysv + i[3456]86-*-sysv4 + i[3456]86-force_cpu386-none + i[3456]86-sequent-bsd i960-nindy960-none m68k-hp-bsd4.3 m68k-mvme135-none @@ -29,8 +36,9 @@ configurations: sparc-sun-solaris2 sparc-sun-sunos4 -Porting the library is not hard. If you are interested in doing a port, -please get on the mailing list by sending electronic mail to +Whether this is still true for this release is unknown. Porting the +library is not hard. If you are interested in doing a port, please +get on the mailing list by sending electronic mail to bug-glibc-request@prep.ai.mit.edu. The GNU C library now includes Michael Glad's Ultra Fast Crypt, which diff --git a/README.template b/README.template index 4ecd0a7587..4e983a1718 100644 --- a/README.template +++ b/README.template @@ -2,21 +2,28 @@ This directory contains the version VERSION test release of the GNU C Library. Many bugs have been fixed since the last release. Some bugs surely remain. -As of this release, the GNU C library has been ported to the following +As of this release, the GNU C library is known to run on the following configurations: + *-*-gnu GNU Hurd + i[3456]86-*-linux Linux-2.0 on Intel + m68k-*-linux Linux-2.0 on Motorola 680x0 + alpha-*-linux Linux-2.0 on DEC Alpha + + +Former releases of this library (version 1.09.1 and perhaps earlier +versions) used to run on the following configurations: + alpha-dec-osf1 - i[345]86-*-bsd4.3 - i[345]86-*-gnu - i[345]86-*-isc2.2 - i[345]86-*-isc3 - i[345]86-*-linux - i[345]86-*-sco3.2 - i[345]86-*-sco3.2v4 - i[345]86-*-sysv - i[345]86-*-sysv4 - i[345]86-force_cpu386-none - i[345]86-sequent-bsd + i[3456]86-*-bsd4.3 + i[3456]86-*-isc2.2 + i[3456]86-*-isc3 + i[3456]86-*-sco3.2 + i[3456]86-*-sco3.2v4 + i[3456]86-*-sysv + i[3456]86-*-sysv4 + i[3456]86-force_cpu386-none + i[3456]86-sequent-bsd i960-nindy960-none m68k-hp-bsd4.3 m68k-mvme135-none @@ -29,8 +36,9 @@ configurations: sparc-sun-solaris2 sparc-sun-sunos4 -Porting the library is not hard. If you are interested in doing a port, -please get on the mailing list by sending electronic mail to +Whether this is still true for this release is unknown. Porting the +library is not hard. If you are interested in doing a port, please +get on the mailing list by sending electronic mail to bug-glibc-request@prep.ai.mit.edu. The GNU C library now includes Michael Glad's Ultra Fast Crypt, which diff --git a/locale/loadlocale.c b/locale/loadlocale.c index d465ed131e..5894b074de 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -217,21 +217,3 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) __close (fd); file->data = newdata; } - -void -_nl_free_locale (const struct locale_data *data) -{ - int save = errno; - if (data == NULL) - /* Ignore a null pointer, like free does. */ - return; - if (data->name != NULL) - free ((void *) data->name); - if (__munmap ((caddr_t) data->filedata, data->filesize) < 0) - { - if (errno == ENOSYS) - free ((void *) data->filedata); - errno = save; - } - free ((void *) data); -} diff --git a/locale/localeinfo.h b/locale/localeinfo.h index 2b7c6faa84..0646f0e8db 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -113,9 +113,6 @@ extern const struct locale_data *_nl_find_locale (const char *locale_path, /* Try to load the file described by FILE. */ extern void _nl_load_locale (struct loaded_l10nfile *file, int category); -/* Free the locale data read in by a `_nl_load_locale' call. */ -extern void _nl_free_locale (const struct locale_data *); - /* Global variables for LC_COLLATE category data. */ extern const u_int32_t *__collate_table; diff --git a/locale/setlocale.c b/locale/setlocale.c index 4eeb5b3bce..d0d9223733 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -326,40 +326,22 @@ setlocale (int category, const char *locale) &newnames[category]); if (newdata[category] == NULL) - goto abort_composite; + break; } else { /* The data is never used; just change the name. */ newnames[category] = clever_copy (newnames[category]); if (newnames[category] == NULL) - goto abort_composite; + break; } /* Create new composite name. */ - composite = new_composite_name (LC_ALL, newnames); - if (composite == NULL) - { - /* Loading this part of the locale failed. Abort the - composite load. */ - int save_errno; - - category = -1; - abort_composite: - save_errno = errno; - - while (++category < LC_ALL) - if (_nl_current[category] != NULL - && newdata[category] != _nl_C[category]) - _nl_free_locale (newdata[category]); - else - if (_nl_current[category] == NULL - && newnames[category] != _nl_C_name) - free (newnames[category]); - - errno = save_errno; - composite = NULL; - } + if (category >= 0 + || (composite = new_composite_name (LC_ALL, newnames)) == NULL) + /* Loading this part of the locale failed. Abort the + composite load. */ + composite = NULL; else { /* Now we have loaded all the new data. Put it in place. */ @@ -379,7 +361,7 @@ setlocale (int category, const char *locale) else { const struct locale_data *newdata = NULL; - char *newname = NULL; + char *newname = (char *) locale; /* Protect global data. */ __libc_lock_lock (lock); @@ -387,7 +369,6 @@ setlocale (int category, const char *locale) if (_nl_current[category] != NULL) { /* Only actually load the data if anything will use it. */ - newname = (char *) locale; newdata = _nl_find_locale (locale_path, locale_path_len, category, (char **) &newname); if (newdata == NULL) @@ -398,14 +379,7 @@ setlocale (int category, const char *locale) composite = new_composite_name (category, &newname); if (composite == NULL) { - /* If anything went wrong free what we managed to allocate - so far. */ - int save_errno = errno; - - if (_nl_current[category] != NULL) - _nl_free_locale (newdata); - - errno = save_errno; + /* Say that we don't have any data loaded. */ abort_single: newname = NULL; } diff --git a/misc/Makefile b/misc/Makefile index 5bdb8252ed..343cc3ee62 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -28,7 +28,7 @@ headers := sys/uio.h iovec.h sys/ioctl.h ioctls.h ioctl-types.h \ ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \ sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h\ sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \ - sys/select.h ustat.h sys/ustat.h ustatbits.h + sys/select.h ustat.h sys/ustat.h ustatbits.h sys/sysinfo.h routines := brk sbrk sstk ioctl \ readv writev \ @@ -45,7 +45,7 @@ routines := brk sbrk sstk ioctl \ ualarm usleep \ gtty stty \ ptrace nlist \ - fstab mntent \ + fstab mntent mntent_r \ utimes \ truncate ftruncate \ chflags fchflags \ @@ -54,7 +54,8 @@ routines := brk sbrk sstk ioctl \ mmap munmap mprotect msync madvise \ efgcvt efgcvt_r qefgcvt qefgcvt_r \ hsearch hsearch_r tsearch lsearch \ - err error ustat + err error ustat \ + getsysstats aux := init-misc distribute := bsd-compat.c extra-objs := bsd-compat.o diff --git a/misc/fstab.c b/misc/fstab.c index c3c27df6ef..30a60a734c 100644 --- a/misc/fstab.c +++ b/misc/fstab.c @@ -1,5 +1,5 @@ -/* -Copyright (C) 1995 Free Software Foundation, Inc. +/* +Copyright (C) 1995, 1996 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 @@ -22,6 +22,9 @@ Cambridge, MA 02139, USA. */ #include <stdio.h> static FILE *fstab; +static struct mntent mntres; +static char buffer[8192]; + static FILE * fstab_stream (void) @@ -48,6 +51,10 @@ static struct fstab * mnt2fs (struct mntent *m) { static struct fstab f; + + if (m == NULL) + return NULL; + f.fs_spec = m->mnt_fsname; f.fs_file = m->mnt_dir; f.fs_vfstype = m->mnt_type; @@ -70,8 +77,8 @@ getfsent (void) if (! s) return NULL; - - return mnt2fs (getmntent (s)); + + return mnt2fs (__getmntent_r (s, &mntres, buffer, sizeof buffer)); } struct fstab * @@ -80,7 +87,7 @@ getfsspec (name) { struct mntent *m; if (setfsent ()) - while (m = getmntent (fstab)) + while (m = __getmntent_r (fstab, &mntres, buffer, sizeof buffer)) if (!strcmp (m->mnt_fsname, name)) return mnt2fs (m); return NULL; @@ -88,11 +95,11 @@ getfsspec (name) struct fstab * getfsfile (name) - register const char *name; + register const char *name; { struct mntent *m; if (setfsent ()) - while (m = getmntent (fstab)) + while (m = __getmntent_r (fstab, &mntres, buffer, sizeof buffer)) if (!strcmp (m->mnt_dir, name)) return mnt2fs (m); return NULL; diff --git a/misc/hsearch.c b/misc/hsearch.c index 7df8686dc3..e0b2e3e0ff 100644 --- a/misc/hsearch.c +++ b/misc/hsearch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> This file is part of the GNU C Library. @@ -19,11 +19,11 @@ Boston, MA 02111-1307, USA. */ #include <search.h> -/* The non-reenttrent version use a global space for storing the table. */ +/* The non-reentrant version use a global space for storing the table. */ static struct hsearch_data htab; -/* Define the non-reentrent function using the reentrent counterparts. */ +/* Define the non-reentrant function using the reentrant counterparts. */ ENTRY * hsearch (item, action) ENTRY item; diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index 86dbe793c0..151bb31efc 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ [Knuth] The Art of Computer Programming, part 3 (6.4) */ -/* The reentrent version has no static variables to maintain the state. +/* The reentrant version has no static variables to maintain the state. Instead the interface of all functions is extended to take an argument which describes the current status. */ typedef struct _ENTRY diff --git a/misc/mntent.c b/misc/mntent.c index 0aa1fb8cde..37a52a354b 100644 --- a/misc/mntent.c +++ b/misc/mntent.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 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 @@ -18,111 +18,12 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <mntent.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -/* Prepare to begin reading and/or writing mount table entries from the - beginning of FILE. MODE is as for `fopen'. */ -FILE * -setmntent (const char *file, const char *mode) -{ - return fopen (file, mode); -} - -/* Close a stream opened with `setmntent'. */ -int -endmntent (FILE *stream) -{ - if (stream) /* SunOS 4.x allows for NULL stream */ - fclose (stream); - return 1; /* SunOS 4.x says to always return 1 */ -} - - -/* Read one mount table entry from STREAM. Returns a pointer to storage - reused on the next call, or null for EOF or error (use feof/ferror to - check). */ struct mntent * getmntent (FILE *stream) { - static char *buf; - static size_t bufsiz; + static char buf[8192]; static struct mntent m; - ssize_t nread; - char *head; - - do - { - nread = getline (&buf, &bufsiz, stream); - if (nread <= 0) - return NULL; - - if (buf[nread - 1] == '\n') /* chop newline */ - buf[nread - 1] = '\0'; - - head = buf + strspn (buf, " \t"); - /* skip empty lines and comment lines: */ - } while (head[0] == '\0' || head[0] == '#'); - - m.mnt_fsname = strsep (&head, " \t") ?: (char *) ""; - if (head) - head += strspn (head, " \t"); - m.mnt_dir = strsep (&head, " \t") ?: (char *) ""; - if (head) - head += strspn (head, " \t"); - m.mnt_type = strsep (&head, " \t") ?: (char *) ""; - if (head) - head += strspn (head, " \t"); - m.mnt_opts = strsep (&head, " \t") ?: (char *) ""; - switch (head ? sscanf (head, " %d %d ", &m.mnt_freq, &m.mnt_passno) : 0) - { - case 0: - m.mnt_freq = 0; - case 1: - m.mnt_passno = 0; - case 2: - } - - return &m; -} - -/* Write the mount table entry described by MNT to STREAM. - Return zero on success, nonzero on failure. */ -int -addmntent (FILE *stream, const struct mntent *mnt) -{ - if (fseek (stream, 0, SEEK_END)) - return 1; - - return (fprintf (stream, "%s %s %s %s %d %d\n", - mnt->mnt_fsname, - mnt->mnt_dir, - mnt->mnt_type, - mnt->mnt_opts, - mnt->mnt_freq, - mnt->mnt_passno) - < 0 ? 1 : 0); -} - -/* Search MNT->mnt_opts for an option matching OPT. - Returns the address of the substring, or null if none found. */ -char * -hasmntopt (const struct mntent *mnt, const char *opt) -{ - const size_t optlen = strlen (opt); - char *rest = mnt->mnt_opts, *p; - - while ((p = strstr (rest, opt)) != NULL) - { - if (p == rest || p[-1] == ',' && - (p[optlen] == '\0' || - p[optlen] == '=' || - p[optlen] == ',')) - return p; - - rest = strchr (rest, ','); - } - return NULL; + return __getmntent_r (stream, &m, buf, sizeof buf); } diff --git a/misc/mntent.h b/misc/mntent.h index 99fa56ded4..8fa93f721b 100644 --- a/misc/mntent.h +++ b/misc/mntent.h @@ -1,5 +1,5 @@ /* <mntent.h> -- Utilities for reading/writing fstab, mtab, etc. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 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 @@ -50,6 +50,8 @@ struct mntent /* Prepare to begin reading and/or writing mount table entries from the beginning of FILE. MODE is as for `fopen'. */ +extern FILE *__setmntent __P ((__const char *__file, + __const char *__mode)); extern FILE *setmntent __P ((__const char *__file, __const char *__mode)); @@ -58,16 +60,31 @@ extern FILE *setmntent __P ((__const char *__file, check). */ extern struct mntent *getmntent __P ((FILE *__stream)); +#ifdef __USE_REENTRANT +/* Reentrant version of the above function. */ +extern struct mntent *__getmntent_r __P ((FILE *__stream, + struct mntent *__result, + char *__buffer, int __bufsize)); +extern struct mntent *getmntent_r __P ((FILE *__stream, + struct mntent *__result, + char *__buffer, int __bufsize)); +#endif + /* Write the mount table entry described by MNT to STREAM. Return zero on success, nonzero on failure. */ +extern int __addmntent __P ((FILE *__stream, + __const struct mntent *__mnt)); extern int addmntent __P ((FILE *__stream, __const struct mntent *__mnt)); /* Close a stream opened with `setmntent'. */ +extern int __endmntent __P ((FILE *__stream)); extern int endmntent __P ((FILE *__stream)); /* Search MNT->mnt_opts for an option matching OPT. Returns the address of the substring, or null if none found. */ +extern char *__hasmntopt __P ((__const struct mntent *__mnt, + __const char *__opt)); extern char *hasmntopt __P ((__const struct mntent *__mnt, __const char *__opt)); diff --git a/misc/mntent_r.c b/misc/mntent_r.c new file mode 100644 index 0000000000..93955254cd --- /dev/null +++ b/misc/mntent_r.c @@ -0,0 +1,141 @@ +/* Utilities for reading/writing fstab, mtab, etc. +Copyright (C) 1995, 1996 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., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include <mntent.h> +#include <stdio.h> +#include <string.h> +#include <sys/types.h> + +/* Prepare to begin reading and/or writing mount table entries from the + beginning of FILE. MODE is as for `fopen'. */ +FILE * +__setmntent (const char *file, const char *mode) +{ + return fopen (file, mode); +} +weak_alias (__setmntent, setmntent) + + +/* Close a stream opened with `setmntent'. */ +int +__endmntent (FILE *stream) +{ + if (stream) /* SunOS 4.x allows for NULL stream */ + fclose (stream); + return 1; /* SunOS 4.x says to always return 1 */ +} +weak_alias (__endmntent, endmntent) + + +/* Read one mount table entry from STREAM. Returns a pointer to storage + reused on the next call, or null for EOF or error (use feof/ferror to + check). */ +struct mntent * +__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) +{ + char *head; + + do + { + char *end_ptr; + + if (fgets (buffer, bufsiz, stream) == NULL) + return NULL; + + end_ptr = strchr (buffer, '\n'); + if (end_ptr != NULL) /* chop newline */ + *end_ptr = '\0'; + else + { + /* Not the whole line was read. Do it now but forget it. */ + char tmp[1024]; + while (fgets (tmp, sizeof tmp, stream) != NULL) + if (strchr (tmp, '\n') != NULL) + break; + } + + head = buffer + strspn (buffer, " \t"); + /* skip empty lines and comment lines: */ + } while (head[0] == '\0' || head[0] == '#'); + + mp->mnt_fsname = strsep (&head, " \t") ?: (char *) ""; + if (head) + head += strspn (head, " \t"); + mp->mnt_dir = strsep (&head, " \t") ?: (char *) ""; + if (head) + head += strspn (head, " \t"); + mp->mnt_type = strsep (&head, " \t") ?: (char *) ""; + if (head) + head += strspn (head, " \t"); + mp->mnt_opts = strsep (&head, " \t") ?: (char *) ""; + switch (head ? sscanf (head, " %d %d ", &mp->mnt_freq, &mp->mnt_passno) : 0) + { + case 0: + mp->mnt_freq = 0; + case 1: + mp->mnt_passno = 0; + case 2: + } + + return mp; +} +weak_alias (__getmntent_r, getmntent_r) + +/* Write the mount table entry described by MNT to STREAM. + Return zero on success, nonzero on failure. */ +int +__addmntent (FILE *stream, const struct mntent *mnt) +{ + if (fseek (stream, 0, SEEK_END)) + return 1; + + return (fprintf (stream, "%s %s %s %s %d %d\n", + mnt->mnt_fsname, + mnt->mnt_dir, + mnt->mnt_type, + mnt->mnt_opts, + mnt->mnt_freq, + mnt->mnt_passno) + < 0 ? 1 : 0); +} +weak_alias (__addmntent, addmntent) + + +/* Search MNT->mnt_opts for an option matching OPT. + Returns the address of the substring, or null if none found. */ +char * +__hasmntopt (const struct mntent *mnt, const char *opt) +{ + const size_t optlen = strlen (opt); + char *rest = mnt->mnt_opts, *p; + + while ((p = strstr (rest, opt)) != NULL) + { + if (p == rest || p[-1] == ',' && + (p[optlen] == '\0' || + p[optlen] == '=' || + p[optlen] == ',')) + return p; + + rest = strchr (rest, ','); + } + + return NULL; +} +weak_alias (__hasmntopt, hasmntopt) diff --git a/misc/search.h b/misc/search.h index 5e237a2791..158332cd61 100644 --- a/misc/search.h +++ b/misc/search.h @@ -70,7 +70,7 @@ ENTRY; /* Opaque type for internal use. */ struct _ENTRY; -/* Data type for reentrent functions. */ +/* Data type for reentrant functions. */ struct hsearch_data { struct _ENTRY *table; @@ -79,7 +79,7 @@ struct hsearch_data }; /* Family of hash table handling functions. The functions also have - reentrent counterparts ending with _r. */ + reentrant counterparts ending with _r. */ extern ENTRY *hsearch __P ((ENTRY __item, ACTION __action)); extern int hcreate __P ((unsigned int __nel)); extern void hdestroy __P ((void)); diff --git a/nss/nss_dns/dns-host.c b/nss/nss_dns/dns-host.c index df8677abfa..d9bf4d7be5 100644 --- a/nss/nss_dns/dns-host.c +++ b/nss/nss_dns/dns-host.c @@ -206,6 +206,41 @@ _nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result, if (!isdigit (*cp) && *cp != '.') break; } + if (isxdigit (name[0]) || name[0] == ':') + for (cp = name;; ++cp) + { + if (*cp == '\0') + { + char *bp; + + if (*--cp == '.') + break; + /* + * All-IPv6-legal, no dot at the end. Fake up a hostent + * as if we'd actually done a lookup. + */ + if (inet_pton (af, name, host_data->host_addr) <= 0) + { + *h_errnop = HOST_NOT_FOUND; + return NSS_STATUS_NOTFOUND; + } + + bp = __stpncpy (host_data->linebuffer, name, linebuflen); + host_data->linebuffer[linebuflen - 1] = '\0'; + linebuflen -= bp - host_data->linebuffer; + + result->h_name = host_data->linebuffer; + result->h_aliases = host_data->aliases; + host_data->aliases[0] = NULL; + host_data->h_addr_ptrs[0] = (char *) host_data->host_addr; + host_data->h_addr_ptrs[1] = NULL; + result->h_addr_list = host_data->h_addr_ptrs; + *h_errnop = NETDB_SUCCESS; + return NSS_STATUS_SUCCESS; + } + if (!isxdigit (*cp) && *cp != ':' && *cp != '.') + break; + } n = res_search (name, C_IN, type, host_buffer.buf, sizeof (host_buffer)); if (n < 0) @@ -354,7 +389,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, int n, ancount, qdcount; int haveanswer, had_error; char *bp, **ap, **hap; - char tbuf[MAXDNAME+1]; + char tbuf[MAXDNAME]; const char *tname; int (*name_ok) __P ((const char *)); diff --git a/posix/getconf.c b/posix/getconf.c index 4ee1446341..5a7b9b1de0 100644 --- a/posix/getconf.c +++ b/posix/getconf.c @@ -99,6 +99,13 @@ static struct conf vars[] = { "_POSIX_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT, SYSCONF }, { "_POSIX_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT, SYSCONF }, { "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF }, + { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF }, + { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF }, + { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF }, + { "PASS_MAX", _SC_PASS_MAX, SYSCONF }, + { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF }, + { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF }, + { "_XOPEN_VERSION", _SC_XOPEN_VERSION }, /* POSIX.2 */ { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF }, { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF }, diff --git a/posix/unistd.h b/posix/unistd.h index 526832ad4e..3b7cb0a0fb 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -55,6 +55,9 @@ __BEGIN_DECLS creation of locales with the localedef utility. */ #define _POSIX2_LOCALEDEF 1 +/* Library is conformant to X/Open version 4. */ +#define _XOPEN_VERSION 4 + /* Get values of POSIX options: diff --git a/resolv/Banner b/resolv/Banner new file mode 100644 index 0000000000..e08f0b4cd3 --- /dev/null +++ b/resolv/Banner @@ -0,0 +1 @@ +BIND-4.9.5-T4B diff --git a/resolv/Makefile b/resolv/Makefile index a141fc7569..9df98fab5a 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -22,13 +22,14 @@ subdir := resolv headers := resolv.h netdb.h arpa/nameser.h sys/bitypes.h -distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h +distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h \ + Banner routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init extra-libs := libresolv extra-libs-others = $(extra-libs) -libresolv-routines := gethnamaddr getnetnamadr res_comp res_debug \ +libresolv-routines := gethnamaddr res_comp res_debug \ res_data res_mkquery res_query res_send \ inet_net_ntop inet_net_pton inet_neta base64 diff --git a/resolv/arpa/nameser.h b/resolv/arpa/nameser.h index 7da0aef597..2352af684c 100644 --- a/resolv/arpa/nameser.h +++ b/resolv/arpa/nameser.h @@ -111,7 +111,7 @@ * Define constants based on rfc883 */ #define PACKETSZ 512 /* maximum packet size */ -#define MAXDNAME 256 /* maximum domain name */ +#define MAXDNAME 1025 /* maximum domain name */ #define MAXCDNAME 255 /* maximum compressed domain name */ #define MAXLABEL 63 /* maximum length of domain label */ #define HFIXEDSZ 12 /* #/bytes of fixed data in header */ diff --git a/resolv/base64.c b/resolv/base64.c index 98983e0a93..8b01de33f4 100644 --- a/resolv/base64.c +++ b/resolv/base64.c @@ -127,7 +127,7 @@ static const char Pad64 = '='; characters followed by one "=" padding character. */ -ssize_t +int b64_ntop(src, srclength, target, targsize) u_char const *src; size_t srclength; @@ -198,7 +198,7 @@ b64_ntop(src, srclength, target, targsize) it returns the number of data bytes stored at the target, or -1 on error. */ -ssize_t +int b64_pton(src, target, targsize) char const *src; u_char *target; diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c index 755fc52ea8..fb51e31003 100644 --- a/resolv/gethnamaddr.c +++ b/resolv/gethnamaddr.c @@ -167,7 +167,7 @@ getanswer(answer, anslen, qname, qtype) int type, class, buflen, ancount, qdcount; int haveanswer, had_error; int toobig = 0; - char tbuf[MAXDNAME+1]; + char tbuf[MAXDNAME]; const char *tname; int (*name_ok) __P((const char *)); @@ -417,6 +417,10 @@ gethostbyname(name) { struct hostent *hp; + if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + h_errno = NETDB_INTERNAL; + return (NULL); + } if (_res.options & RES_USE_INET6) { hp = gethostbyname2(name, AF_INET6); if (hp) @@ -502,6 +506,36 @@ gethostbyname2(name, af) } if (!isdigit(*cp) && *cp != '.') break; + } + if (isxdigit(name[0]) || name[0] == ':') + for (cp = name;; ++cp) { + if (!*cp) { + if (*--cp == '.') + break; + /* + * All-IPv6-legal, no dot at the end. + * Fake up a hostent as if we'd actually + * done a lookup. + */ + if (inet_pton(af, name, host_addr) <= 0) { + h_errno = HOST_NOT_FOUND; + return (NULL); + } + strncpy(hostbuf, name, MAXDNAME); + hostbuf[MAXDNAME] = '\0'; + bp = hostbuf + MAXDNAME; + len = sizeof hostbuf - MAXDNAME; + host.h_name = hostbuf; + host.h_aliases = host_aliases; + host_aliases[0] = NULL; + h_addr_ptrs[0] = (char *)host_addr; + h_addr_ptrs[1] = NULL; + host.h_addr_list = h_addr_ptrs; + h_errno = NETDB_SUCCESS; + return (&host); + } + if (!isxdigit(*cp) && *cp != ':' && *cp != '.') + break; } if ((n = res_search(name, C_IN, type, buf.buf, sizeof(buf))) < 0) { diff --git a/resolv/res_comp.c b/resolv/res_comp.c index 7da1c3e0f6..76f7cea5c5 100644 --- a/resolv/res_comp.c +++ b/resolv/res_comp.c @@ -526,6 +526,26 @@ putlong(l, msgp) __putlong(l, msgp); } +#undef dn_comp +int +dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) + const char *exp_dn; + u_char *comp_dn, **dnptrs, **lastdnptr; + int length; +{ + return (__dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)); +} + +#undef dn_expand +int +dn_expand(msg, eomorig, comp_dn, exp_dn, length) + const u_char *msg, *eomorig, *comp_dn; + char *exp_dn; + int length; +{ + return (__dn_expand(msg, eomorig, comp_dn, exp_dn, length)); +} + #undef dn_skipname dn_skipname(comp_dn, eom) const u_char *comp_dn, *eom; diff --git a/resolv/res_debug.c b/resolv/res_debug.c index b47667626f..61724bf23b 100644 --- a/resolv/res_debug.c +++ b/resolv/res_debug.c @@ -238,6 +238,7 @@ __p_query(msg) } #ifdef ultrix +#undef p_query /* ultrix 4.0's packaging has some icky packaging. alias for it here. * there is more junk of this kind over in res_comp.c. */ @@ -1041,8 +1042,8 @@ __p_option(option) /* * Return a mnemonic for a time to live */ -char * -__p_time(value) +const char * +p_time(value) u_int32_t value; { static char nbuf[40]; @@ -1369,7 +1370,7 @@ loc_aton(ascii, binary) } /* takes an on-the-wire LOC RR and formats it in a human readable format. */ -char * +const char * loc_ntoa(binary, ascii) const u_char *binary; char *ascii; diff --git a/resolv/res_query.c b/resolv/res_query.c index 135c6aa5c0..2d191d0332 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -86,7 +86,7 @@ static char rcsid[] = "$Id$"; #define MAXPACKET 1024 #endif -char *__hostalias __P((const char *)); +const char *hostalias __P((const char *)); /* @@ -321,7 +321,7 @@ res_querydomain(name, domain, class, type, answer, anslen) u_char *answer; /* buffer to put answer */ int anslen; /* size of answer */ { - char nbuf[2*MAXDNAME+2]; + char nbuf[MAXDNAME]; const char *longname = nbuf; int n; @@ -351,8 +351,8 @@ res_querydomain(name, domain, class, type, answer, anslen) return (res_query(longname, class, type, answer, anslen)); } -char * -__hostalias(name) +const char * +hostalias(name) register const char *name; { register char *cp1, *cp2; diff --git a/resolv/res_send.c b/resolv/res_send.c index 841baa64e3..4c258b99bf 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -781,3 +781,20 @@ _res_close() vc = 0; } } + +#ifdef ultrix +/* ultrix 4.0 had some icky packaging in its libc.a. alias for it here. + * there is more gunk of this kind over in res_debug.c. + */ + +#undef res_send +int +res_send(buf, buflen, ans, anssiz) + const u_char *buf; + int buflen; + u_char *ans; + int anssiz; +{ + return (__res_send(buf, buflen, ans, anssiz)); +} +#endif /* Ultrix 4.0 hackery */ diff --git a/resolv/resolv.h b/resolv/resolv.h index 23460c5280..e5ec75a4db 100644 --- a/resolv/resolv.h +++ b/resolv/resolv.h @@ -112,7 +112,7 @@ struct __res_state { #define nsaddr nsaddr_list[0] /* for backward compatibility */ u_short id; /* current packet id */ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ - char defdname[MAXDNAME]; /* default domain */ + char defdname[256]; /* default domain (deprecated) */ u_long pfcode; /* RES_PRF_ flags - see below. */ unsigned ndots:4; /* threshold for initial abs. query */ unsigned nsort:4; /* number of elements in sort_list[] */ @@ -205,6 +205,7 @@ extern const struct res_sym __p_type_syms[]; #define loc_ntoa __loc_ntoa #define loc_aton __loc_aton #define dn_skipname __dn_skipname +#define fp_resstat __fp_resstat #define fp_query __fp_query #define fp_nquery __fp_nquery #define hostalias __hostalias @@ -213,6 +214,7 @@ extern const struct res_sym __p_type_syms[]; #define p_class __p_class #define p_time __p_time #define p_type __p_type +#define p_query __p_query #define p_cdnname __p_cdnname #define p_cdname __p_cdname #define p_fqnname __p_fqnname @@ -221,59 +223,68 @@ extern const struct res_sym __p_type_syms[]; #define p_option __p_option #define p_secstodate __p_secstodate #define dn_count_labels __dn_count_labels +#define dn_comp __dn_comp +#define dn_expand __dn_expand +#define res_init __res_init #define res_randomid __res_randomid +#define res_query __res_query +#define res_search __res_search +#define res_querydomain __res_querydomain +#define res_mkquery __res_mkquery +#define res_send __res_send #define res_isourserver __res_isourserver #define res_nameinquery __res_nameinquery #define res_queriesmatch __res_queriesmatch __BEGIN_DECLS -int __res_hnok __P((const char *)); -int __res_ownok __P((const char *)); -int __res_mailok __P((const char *)); -int __res_dnok __P((const char *)); -int sym_ston __P((const struct res_sym *, char *, int *)); -const char *sym_ntos __P((const struct res_sym *, int, int *)); -const char *sym_ntop __P((const struct res_sym *, int, int *)); -ssize_t b64_ntop __P((u_char const *, size_t, char *, size_t)); -ssize_t b64_pton __P((char const *, u_char *, size_t)); -int __loc_aton __P((const char *ascii, u_char *binary)); -char * __loc_ntoa __P((const u_char *binary, char *ascii)); -int __dn_skipname __P((const u_char *, const u_char *)); -void __fp_resstat __P((struct __res_state *, FILE *)); -void __fp_query __P((const u_char *, FILE *)); -void __fp_nquery __P((const u_char *, int, FILE *)); -char *__hostalias __P((const char *)); -void __putlong __P((u_int32_t, u_char *)); -void __putshort __P((u_int16_t, u_char *)); -char *__p_time __P((u_int32_t)); -void __p_query __P((const u_char *)); -const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *)); -const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *)); -const u_char *__p_fqnname __P((const u_char *cp, const u_char *msg, +int res_hnok __P((const char *)); +int res_ownok __P((const char *)); +int res_mailok __P((const char *)); +int res_dnok __P((const char *)); +int sym_ston __P((const struct res_sym *, char *, int *)); +const char * sym_ntos __P((const struct res_sym *, int, int *)); +const char * sym_ntop __P((const struct res_sym *, int, int *)); +int b64_ntop __P((u_char const *, size_t, char *, size_t)); +int b64_pton __P((char const *, u_char *, size_t)); +int loc_aton __P((const char *, u_char *)); +const char * loc_ntoa __P((const u_char *, char *)); +int dn_skipname __P((const u_char *, const u_char *)); +void fp_resstat __P((struct __res_state *, FILE *)); +void fp_query __P((const u_char *, FILE *)); +void fp_nquery __P((const u_char *, int, FILE *)); +const char * hostalias __P((const char *)); +void putlong __P((u_int32_t, u_char *)); +void putshort __P((u_int16_t, u_char *)); +const char * p_class __P((int)); +const char * p_time __P((u_int32_t)); +const char * p_type __P((int)); +void p_query __P((const u_char *)); +const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *)); +const u_char * p_cdname __P((const u_char *, const u_char *, FILE *)); +const u_char * p_fqnname __P((const u_char *cp, const u_char *msg, int, char *, int)); -const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *)); -const u_char *__p_rr __P((const u_char *, const u_char *, FILE *)); -const char *__p_type __P((int)); -const char *__p_class __P((int)); -const char *__p_option __P((u_long option)); -char * __p_secstodate __P((unsigned long)); -int dn_count_labels __P((char *)); -int dn_comp __P((const char *, u_char *, int, u_char **, u_char **)); -int dn_expand __P((const u_char *, const u_char *, const u_char *, - char *, int)); -int res_init __P((void)); -u_int16_t res_randomid __P((void)); -int res_query __P((const char *, int, int, u_char *, int)); -int res_search __P((const char *, int, int, u_char *, int)); -int res_querydomain __P((const char *, const char *, int, int, - u_char *, int)); -int res_mkquery __P((int, const char *, int, int, const u_char *, int, - const u_char *, u_char *, int)); -int res_send __P((const u_char *, int, u_char *, int)); -int res_isourserver __P((const struct sockaddr_in *)); -int res_nameinquery __P((const char *, int, int, - const u_char *, const u_char *)); -int res_queriesmatch __P((const u_char *, const u_char *, - const u_char *, const u_char *)); +const u_char * p_fqname __P((const u_char *, const u_char *, FILE *)); +const u_char * p_rr __P((const u_char *, const u_char *, FILE *)); +const char * p_option __P((u_long option)); +char * p_secstodate __P((u_long)); +int dn_count_labels __P((char *)); +int dn_comp __P((const char *, u_char *, int, + u_char **, u_char **)); +int dn_expand __P((const u_char *, const u_char *, const u_char *, + char *, int)); +int res_init __P((void)); +u_int16_t res_randomid __P((void)); +int res_query __P((const char *, int, int, u_char *, int)); +int res_search __P((const char *, int, int, u_char *, int)); +int res_querydomain __P((const char *, const char *, int, int, + u_char *, int)); +int res_mkquery __P((int, const char *, int, int, const u_char *, int, + const u_char *, u_char *, int)); +int res_send __P((const u_char *, int, u_char *, int)); +int res_isourserver __P((const struct sockaddr_in *)); +int res_nameinquery __P((const char *, int, int, + const u_char *, const u_char *)); +int res_queriesmatch __P((const u_char *, const u_char *, + const u_char *, const u_char *)); __END_DECLS #endif /* !_RESOLV_H_ */ diff --git a/stdlib/drand48-iter.c b/stdlib/drand48-iter.c index 65e78eb3ce..6c15b15e1c 100644 --- a/stdlib/drand48-iter.c +++ b/stdlib/drand48-iter.c @@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA. */ #include <limits.h> #include <sys/types.h> -/* Global state for non-reentrent functions. */ +/* Global state for non-reentrant functions. */ struct drand48_data __libc_drand48_data; diff --git a/stdlib/drand48.c b/stdlib/drand48.c index e2d8450044..69e018bbfc 100644 --- a/stdlib/drand48.c +++ b/stdlib/drand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; double diff --git a/stdlib/erand48.c b/stdlib/erand48.c index b63c3bddea..a323d3deab 100644 --- a/stdlib/erand48.c +++ b/stdlib/erand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; double diff --git a/stdlib/jrand48.c b/stdlib/jrand48.c index bdd62fb241..6a02a8606f 100644 --- a/stdlib/jrand48.c +++ b/stdlib/jrand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; long diff --git a/stdlib/lcong48.c b/stdlib/lcong48.c index 7e4d18806f..779dcc7c40 100644 --- a/stdlib/lcong48.c +++ b/stdlib/lcong48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; void diff --git a/stdlib/lrand48.c b/stdlib/lrand48.c index a3e6ea1a7d..ff79606bd1 100644 --- a/stdlib/lrand48.c +++ b/stdlib/lrand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; long diff --git a/stdlib/mrand48.c b/stdlib/mrand48.c index e71b23465e..eb69891904 100644 --- a/stdlib/mrand48.c +++ b/stdlib/mrand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; long diff --git a/stdlib/nrand48.c b/stdlib/nrand48.c index 0dd2c2b34f..455892e7ab 100644 --- a/stdlib/nrand48.c +++ b/stdlib/nrand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; long diff --git a/stdlib/random.c b/stdlib/random.c index 6d2ee85f3e..e2b191b696 100644 --- a/stdlib/random.c +++ b/stdlib/random.c @@ -19,7 +19,7 @@ * This is derived from the Berkeley source: * @(#)random.c 5.5 (Berkeley) 7/6/88 * It was reworked for the GNU C Library by Roland McGrath. - * Rewritten to use reentrent functions by Ulrich Drepper, 1995. + * Rewritten to use reentrant functions by Ulrich Drepper, 1995. */ #include <limits.h> @@ -118,13 +118,13 @@ static int32_t randtbl[DEG_3 + 1] = { TYPE_3, - -1726662223, 379960547, 1735697613, 1040273694, 1313901226, - 1627687941, -179304937, -2073333483, 1780058412, -1989503057, - -615974602, 344556628, 939512070, -1249116260, 1507946756, - -812545463, 154635395, 1388815473, -1926676823, 525320961, - -1009028674, 968117788, -123449607, 1284210865, 435012392, - -2017506339, -911064859, -370259173, 1132637927, 1398500161, - -205601318, + -1726662223, 379960547, 1735697613, 1040273694, 1313901226, + 1627687941, -179304937, -2073333483, 1780058412, -1989503057, + -615974602, 344556628, 939512070, -1249116260, 1507946756, + -812545463, 154635395, 1388815473, -1926676823, 525320961, + -1009028674, 968117788, -123449607, 1284210865, 435012392, + -2017506339, -911064859, -370259173, 1132637927, 1398500161, + -205601318, }; diff --git a/stdlib/random_r.c b/stdlib/random_r.c index 611deaf804..f2fe923143 100644 --- a/stdlib/random_r.c +++ b/stdlib/random_r.c @@ -19,7 +19,7 @@ * This is derived from the Berkeley source: * @(#)random.c 5.5 (Berkeley) 7/6/88 * It was reworked for the GNU C Library by Roland McGrath. - * Rewritten to be reentrent by Ulrich Drepper, 1995 + * Rewritten to be reentrant by Ulrich Drepper, 1995 */ #include <errno.h> diff --git a/stdlib/seed48.c b/stdlib/seed48.c index 634f9a72fc..c002f82b21 100644 --- a/stdlib/seed48.c +++ b/stdlib/seed48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; unsigned short int * diff --git a/stdlib/srand48.c b/stdlib/srand48.c index 80ada310c3..b9baad99a2 100644 --- a/stdlib/srand48.c +++ b/stdlib/srand48.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. */ #include <stdlib.h> -/* Global state for non-reentrent functions. Defined in drand48-iter.c. */ +/* Global state for non-reentrant functions. Defined in drand48-iter.c. */ extern struct drand48_data __libc_drand48_data; void diff --git a/sysdeps/generic/confname.h b/sysdeps/generic/confname.h index d0968a1ba5..3d76843d12 100644 --- a/sysdeps/generic/confname.h +++ b/sysdeps/generic/confname.h @@ -224,6 +224,21 @@ enum #define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT _SC_THREAD_PROCESS_SHARED, #define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED + + _SC_NPROCESSORS_CONF, +#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF + _SC_NPROCESSORS_ONLN, +#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN + _SC_PHYS_PAGES, +#define _SC_PHYS_PAGES _SC_PHYS_PAGES + _SC_AVPHYS_PAGES, +#define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES + _SC_ATEXIT_MAX, +#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX + _SC_PASS_MAX, +#define _SC_PASS_MAX _SC_PASS_MAX + _SC_XOPEN_VERSION +#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION }; #ifdef __USE_POSIX2 diff --git a/sysdeps/generic/sys/sysinfo.h b/sysdeps/generic/sys/sysinfo.h new file mode 100644 index 0000000000..e9f667499e --- /dev/null +++ b/sysdeps/generic/sys/sysinfo.h @@ -0,0 +1,41 @@ +/* Copyright (C) 1996 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. */ + +#ifndef _SYS_SYSINFO_H + +#define _SYS_SYSINFO_H 1 +#include <features.h> + +/* Return number of configured processors. */ +extern int __get_nproc_conf __P ((void)); +extern int get_nproc_conf __P ((void)); + +/* Return number of available processors. */ +extern int __get_nproc __P ((void)); +extern int get_nproc __P ((void)); + + +/* Return number of physical pages of memory in the system. */ +extern int __get_phys_pages __P ((void)); +extern int get_phys_pages __P ((void)); + +/* Return number of available physical pages of memory in the system. */ +extern int __get_avphys_pages __P ((void)); +extern int get_avphys_pages __P ((void)); + +#endif /* sys/sysinfo.h */ diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c index 29d06135c6..14ee58cafb 100644 --- a/sysdeps/posix/sysconf.c +++ b/sysdeps/posix/sysconf.c @@ -24,6 +24,7 @@ Cambridge, MA 02139, USA. */ #include <stdio.h> #include <time.h> #include <unistd.h> +#include <sys/sysinfo.h> extern int __getdtablesize __P ((void)); extern size_t __getpagesize __P ((void)); @@ -595,6 +596,30 @@ __sysconf (name) #else return -1; #endif + + case _SC_NPROCESSORS_CONF: + return __get_nprocs_conf (); + + case _SC_NPROCESSORS_ONLN: + return __get_nprocs (); + + case _SC_PHYS_PAGES: + return __get_phys_pages (); + + case _SC_AVPHYS_PAGES: + return __get_avphys_pages (); + + case _SC_ATEXIT_MAX: + /* We have no limit since we use lists. */ + return INT_MAX; + + case _SC_PASS_MAX: + /* We have no limit but since the return value might be used to + allocate a buffer we restrict the value. */ + return BUFSIZ; + + case _SC_XOPEN_VERSION: + return _XOPEN_VERSION; } } diff --git a/sysdeps/stub/getsysstats.c b/sysdeps/stub/getsysstats.c new file mode 100644 index 0000000000..c8fe700ded --- /dev/null +++ b/sysdeps/stub/getsysstats.c @@ -0,0 +1,68 @@ +/* getsysstats - Determine various system internal values, stub version. +Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. + +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 <sys/sysinfo.h> + +int +__get_nprocs_conf () +{ + /* We don't know how to determine the number. Simply return always 1. */ + return 1; +} +weak_alias (__get_nprocs_conf, get_nprocs_conf) + +link_warning (get_nprocs_conf, "warning: get_nprocs_conf will always return 1") + + + +int +__get_nprocs () +{ + /* We don't know how to determine the number. Simply return always 1. */ + return 1; +} +weak_alias (__get_nprocs, get_nprocs) + +link_warning (get_nprocs, "warning: get_nprocs will always return 1") + + +int +__get_phys_pages () +{ + /* We have no general way to determine this value. */ + errno = ENOSYS; + return -1; +} +weak_alias (__get_phys_pages, get_phys_pages) + +link_warning (get_phys_pages, "warning: get_phys_pages will always fail") + + +int +__get_avphys_pages () +{ + /* We have no general way to determine this value. */ + errno = ENOSYS; + return -1; +} +weak_alias (__get_avphys_pages, get_avphys_pages) + +link_warning (get_avphys_pages, "warning: get_avphys_pages will always fail") diff --git a/sysdeps/stub/sysconf.c b/sysdeps/stub/sysconf.c index 613ef674b8..1351b48fe0 100644 --- a/sysdeps/stub/sysconf.c +++ b/sysdeps/stub/sysconf.c @@ -17,9 +17,11 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <errno.h> +#include <stdio.h> #include <unistd.h> #include <time.h> #include <limits.h> +#include <sys/sysinfo.h> /* Get the value of the system variable NAME. */ @@ -64,6 +66,27 @@ __sysconf (name) return -1; #endif + case _SC_NPROCESSORS_CONF: + return __get_nprocs_conf (); + + case _SC_NPROCESSORS_ONLN: + return __get_nprocs (); + + case _SC_PHYS_PAGES: + return __get_phys_pages (); + + case _SC_AVPHYS_PAGES: + return __get_avphys_pages (); + + case _SC_ATEXIT_MAX: + /* We have no limit since we use lists. */ + return INT_MAX; + + case _SC_PASS_MAX: + /* We have no limit but since the return value might be used to + allocate a buffer we restrict the value. */ + return BUFSIZ; + case _SC_ARG_MAX: case _SC_CHILD_MAX: case _SC_CLK_TCK: @@ -145,6 +168,8 @@ __sysconf (name) case _SC_THREAD_PRIO_PROTECT: case _SC_THREAD_PROCESS_SHARED: + case _SC_XOPEN_VERSION: + break; } diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 02b44a8fc5..33220df5f6 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -5,7 +5,7 @@ endif ifeq ($(subdir), misc) sysdep_routines += sysctl clone -sysdep_headers += sys/mount.h sys/sysinfo.h sys/acct.h sys/sysctl.h \ +sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ sys/module.h sys/io.h sys/klog.h sys/kdaemon.h \ sys/user.h syscall-list.h sys/sysmacros.h sys/procfs.h diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c new file mode 100644 index 0000000000..81946b422f --- /dev/null +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -0,0 +1,200 @@ +/* getsysstats - Determine various system internal values, Linux version. +Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. + +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 <mntent.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/sysinfo.h> + + +/* Determine the path to the /proc filesystem if available. */ +static char * +get_proc_path (char *buffer, size_t bufsize) +{ + FILE *fp; + struct mntent mount_point; + struct mntent *entry; + char *result; + + /* First find the mount point of the proc filesystem. */ + fp = __setmntent (_PATH_MNTTAB, "r"); + if (fp == NULL) + /* Cannot find mount table file. */ + result = NULL; + else + { + while ((entry = __getmntent_r (fp, &mount_point, buffer, bufsize)) + != NULL) + if (strcmp (mount_point.mnt_type, "proc") == 0) + { + result = mount_point.mnt_dir; + break; + } + __endmntent (fp); + } + + return result; +} + + +/* How we can determine the number of available processors depends on + the configuration. There is currently (as of version 2.0.21) no + system call to determine the number. It is planned for the 2.1.x + series to add this, though. + + One possibility to implement it for systems using Linux 2.0 is to + examine the pseudo file /proc/meminfo. Here we have one entry for + each processor. + + But not all systems have support for the /proc filesystem. If it + is not available we simply return 1 since there is no way. */ +int +__get_nprocs () +{ + FILE *fp; + char buffer[8192]; + char *proc_path; + int result = 1; + + /* XXX Here will come a test for the new system call. */ + + /* Get mount point of proc filesystem. */ + proc_path = get_proc_path (buffer, sizeof buffer); + + /* If we haven't found an appropriate entry return 1. */ + if (proc_path != NULL) + { + char *proc_cpuinfo = alloca (strlen (proc_path) + sizeof ("/cpuinfo")); + __stpcpy (__stpcpy (proc_cpuinfo, proc_path), "/cpuinfo"); + + fp = fopen (proc_cpuinfo, "r"); + if (fp != NULL) + { + result = 0; + /* Read all lines and count the lines starting with the + string "processor". We don't have to fear extremely long + lines since the kernel will not generate them. 8192 + bytes are really enough. */ + while (fgets (buffer, sizeof buffer, fp) != NULL) + if (strncmp (buffer, "processor", 9) == 0) + ++result; + + fclose (fp); + } + } + + return result; +} +weak_alias (__get_nprocs, get_nprocs) + +/* As far as I know Linux has no separate numbers for configured and + available processors. So make the `get_nprocs_conf' function an + prototype. */ +strong_alias (__get_nprocs, __get_nprocs_conf) +weak_alias (__get_nprocs, get_nprocs_conf) + + +/* General function to get information about memory status from proc + filesystem. */ +static int +phys_pages_info (const char *format) +{ + FILE *fp; + char buffer[8192]; + char *proc_path; + int result = -1; + + /* Get mount point of proc filesystem. */ + proc_path = get_proc_path (buffer, sizeof buffer); + + /* If we haven't found an appropriate entry return 1. */ + if (proc_path != NULL) + { + char *proc_meminfo = alloca (strlen (proc_path) + sizeof ("/meminfo")); + __stpcpy (__stpcpy (proc_meminfo, proc_path), "/meminfo"); + + fp = fopen (proc_meminfo, "r"); + if (fp != NULL) + { + result = 0; + /* Read all lines and count the lines starting with the + string "processor". We don't have to fear extremely long + lines since the kernel will not generate them. 8192 + bytes are really enough. */ + while (fgets (buffer, sizeof buffer, fp) != NULL) + if (sscanf (buffer, format, &result) == 1) + { + result /= (__getpagesize () / 1024); + break; + } + + fclose (fp); + } + } + + if (result == -1) + /* We cannot get the needed value: signal an error. */ + errno = ENOSYS; + + return result; +} + + +/* Return the number of pages of physical memory in the system. There + is currently (as of version 2.0.21) no system call to determine the + number. It is planned for the 2.1.x series to add this, though. + + One possibility to implement it for systems using Linux 2.0 is to + examine the pseudo file /proc/cpuinfo. Here we have one entry for + each processor. + + But not all systems have support for the /proc filesystem. If it + is not available we return -1 as an error signal. */ +int +__get_phys_pages () +{ + /* XXX Here will come a test for the new system call. */ + + return phys_pages_info ("MemTotal: %d kB"); +} +weak_alias (__get_phys_pages, get_phys_pages) + + +/* Return the number of available pages of physical memory in the + system. There is currently (as of version 2.0.21) no system call + to determine the number. It is planned for the 2.1.x series to add + this, though. + + One possibility to implement it for systems using Linux 2.0 is to + examine the pseudo file /proc/cpuinfo. Here we have one entry for + each processor. + + But not all systems have support for the /proc filesystem. If it + is not available we return -1 as an error signal. */ +int +__get_avphys_pages () +{ + /* XXX Here will come a test for the new system call. */ + + return phys_pages_info ("MemFree: %d kB"); +} +weak_alias (__get_avphys_pages, get_avphys_pages) diff --git a/sysdeps/unix/sysv/linux/sys/sysinfo.h b/sysdeps/unix/sysv/linux/sys/sysinfo.h index c05da05b3d..1fabb06392 100644 --- a/sysdeps/unix/sysv/linux/sys/sysinfo.h +++ b/sysdeps/unix/sysv/linux/sys/sysinfo.h @@ -27,4 +27,22 @@ Boston, MA 02111-1307, USA. */ /* Returns information on overall system statistics. */ extern int sysinfo __P ((struct sysinfo *__info)); + +/* Return number of configured processors. */ +extern int __get_nproc_conf __P ((void)); +extern int get_nproc_conf __P ((void)); + +/* Return number of available processors. */ +extern int __get_nproc __P ((void)); +extern int get_nproc __P ((void)); + + +/* Return number of physical pages of memory in the system. */ +extern int __get_phys_pages __P ((void)); +extern int get_phys_pages __P ((void)); + +/* Return number of available physical pages of memory in the system. */ +extern int __get_avphys_pages __P ((void)); +extern int get_avphys_pages __P ((void)); + #endif /* sys/sysinfo.h */ @@ -1,4 +1,4 @@ /* This file just defines the current version number of libc. */ #define RELEASE "alpha" -#define VERSION "1.94" +#define VERSION "1.95" |