summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-11-06 04:24:40 +0000
committerUlrich Drepper <drepper@redhat.com>1996-11-06 04:24:40 +0000
commit2c6fe0bd3b270fc644dd4c773f2d47b93f404efe (patch)
treea578bcc93bbeaafacb6012213c458e33b7907528
parentf5311448f83eada5c5cabf55aae2619dcb1869c0 (diff)
update from main archive 961105cvs/libc-961106
Wed Nov 6 04:30:26 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/syscalls.list: Add weak alias llseek for _llseek syscall. Reported by Andy Sewell <puck@pookhill.demon.co.uk>. * string/argz.h: Don't protect by __USE_GNU. Tue Nov 5 23:38:28 1996 Ulrich Drepper <drepper@cygnus.com> * Lots of files: Update and reformat copyright. * Makefile (headers): Add xopen_lim.h. * catgets/nl_types.h: Move __BEGIN_DECLS before definition of nl_catd. * grp/grp.h: Define setgrent, getgrent, endgrent, and getgrent_r if __USE_XOPEN_EXTENDED is defined. * pwd/pwd.h: Define setpwent, getpwent, endpwent, and getpwent_r if __USE_XOPEN_EXTENDED is defined. * io/Makefile (routines): Add lchown. * io/sys/poll.h: Add definition of POLLWRNORM. * io/sys/stat.h: Declare lstat, fchmod, mknod when __USE_XOPEN_EXTENDED is defined. * libio/Makefile (routines): Add obprintf. * libio/obprintf.c: New file. * libio/iolibio.h: Add prototypes for _IO_obstack_vprintf and _IO_obstack_printf. * libio/libio.h: Fix typo. * libio/stdio.h: Declare tempnam if __USE_XOPEN_EXTENDED is defined. Add prototypes for obstack_vprintf and obstack_printf. * manual/creature.texi: Describe _XOPEN_SOURCE macro. * manual/intro.texi: Add reference to NSS chapter. * manual/libc.texinfo: Update UPDATED. Comment out `@printindex cp'. It works again. * manual/memory.texi: Add description for obstack_ptr_grow, obstack_int_grow, obstack_ptr_grow_fast, and obstack_int_grow_fast. * manual/nss.texi: Add a few @cindex entries and change NSS_STATUS_* index entries to @vindex. * manual/users.texi: Correct @cindex entry for Netgroup. * math/mathcalls.h: Use __USE_XOPEN and __USE_XOPEN_EXTENDED to make declarations visible for X/Open sources. * misc/search.h: Declare insque/remque only is __USE_SVID or __USE_XOPEN_EXTENDED is defined. * misc/sys/uio.h (readv, writev): Change return value from int to ssize_t. * posix/Makefile (headers): Add re_comp.h. * posix/re_comp.h: New file. XPG interface to regex functions. * posix/getconf.c: Add all names from XPG4.2. * posix/posix1_lim.h: Increase minimum values for _POSIX_CHILD_MAX and _POSIX_OPEN_MAX to minimums from XPG4.2. * sysdeps/generic/confname.h: Add all _SC_* names from XPG4.2. * sysdeps/posix/sysconf.c: Handle new _SC_* values. * sysdeps/stub/sysconf.c: Likewise. * posix/unistd.h: Add declaration of ualarm and lchown. Declare usleep, fchown, fchdir, nice, getpgid, setsid, getsid, setreuid, setregid, vfork, ttyslot, symlink, readlink, gethostid, truncate, ftruncate, getdtablesize, brk, sbrk, lockf when __USE_XOPEN_EXTENDED is defined. * posix/sys/wait.h: Declare wait3 if __USE_XOPEN_EXTENDED is defined. * shadow/shadow.h: Define SHADOW using _PATH_SHADOW. * sysdeps/generic/paths.h: Define _PATH_SHADOW. * sysdeps/unix/sysv/linux/paths.h: Likewise. * signal/signal.h: Declare killpg, sigstack and sigaltstack when __USE_XOPEN_EXTENDED is defined. * stdio/stdio.h: Declare tempnam when __USE_XOPEN is defined. * stdlib/stdlib.h: Make rand48 functions available when __USE_XOPEN is defined. Likewise for valloc, putenv, realpath, [efg]cvt*, and getsubopt functions. * string/string.h: Make memccpy, strdup, bcmp, bcopy, bzero, index, and rindex available when __USE_XOPEN_EXTENDED is defined. * sysdeps/mach/getpagesize.c: De-ANSI-fy. Change return type to int. * sysdeps/posix/getpagesize.c: Likewise. * sysdeps/stub/getpagesize.c: Likewise. * sysdeps/unix/getpagesize.c: Likewise. * time/africa: Update from tzdata1996l. * time/asia: Likewise. * time/australia: Likewise. * time/europe: Likewise. * time/northamerica: Likewise. * time/pacificnew: Likewise. * time/southamerica: Likewise. * time/tzfile.h: Update from tzcode1996m. * time/time.h: Declare strptime if __USE_XOPEN. Declare daylight and timezone also if __USE_XOPEN. * time/sys/time.h: Remove declaration of ualarm. * wctype/wctype.h: Just reference ISO C standard. Tue Nov 5 01:26:32 1996 Richard Henderson <rth@tamu.edu> * crypt/Makefile: Add crypt routines to libc as well iff $(crypt-in-libc) is set. Do this for temporary binary compatibility on existing Linux/Alpha installations. * stdlib/div.c, sysdeps/generic/div.c: Move file to .../generic/. * stdlib/ldiv.c, sysdeps/generic/ldiv.c: Likewise. * stdlib/lldiv.c, sysdeps/generic/lldiv.c: Likewise. * sysdeps/alpha/Makefile (divrem): Add divlu, dviqu, remlu, and remqu. * sysdeps/alpha/div.S: New file. * sysdeps/alpha/ldiv.S: New file. * sysdeps/alpha/lldiv.S: New file. * sysdeps/alpha/divrem.h: Merge signed and unsigned division. Take pointers from Linus and tighten the inner loops a bit. * sysdeps/alpha/divl.S: Change defines for merged routines. * sysdeps/alpha/divq.S: Likewise. * sysdeps/alpha/reml.S: Likewise. * sysdeps/alpha/remq.S: Likewise. * sysdeps/alpha/divlu.S: Remove file. * sysdeps/alpha/divqu.S: Likewise. * sysdeps/alpha/remlu.S: Likewise. * sysdeps/alpha/remqu.S: Likewise. * sysdeps/alpha/bsd-_setjmp.S: If PROF, call _mcount. * sysdeps/alpha/bsd-setjmp.S: Likewise. * sysdeps/alpha/bzero.S: Likewise. * sysdeps/alpha/ffs.S: Likewise. * sysdeps/alpha/htonl.S: Likewise. * sysdeps/alpha/htons.S: Likewise. * sysdeps/alpha/memchr.S: Likewise. * sysdeps/alpha/memset.S: Likewise. * sysdeps/alpha/s_copysign.S: Likewise. * sysdeps/alpha/s_fabs.S: Likewise. * sysdeps/alpha/setjmp.S: Likewise. * sysdeps/alpha/stpcpy.S: Likewise. * sysdeps/alpha/stpncpy.S: Likewise. * sysdeps/alpha/strcat.S: Likewise. * sysdeps/alpha/strchr.S: Likewise. * sysdeps/alpha/strcpy.S: Likewise. * sysdeps/alpha/strlen.S: Likewise. * sysdeps/alpha/strncat.S: Likewise. * sysdeps/alpha/strncpy.S: Likewise. * sysdeps/alpha/strrchr.S: Likewise. * sysdeps/alpha/udiv_qrnnd.S: Likewise. Fix private labels. Convert two small jumps to use conditional moves. * sysdeps/unix/alpha/sysdep.h: Compress all __STDC__ nastiness. (PSEUDO): If PROF, call _mcount. * sysdeps/unix/sysv/linux/alpha/brk.S: If PROF, call _mcount. * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise. * sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S: Likewise. * sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S: Likewise. * sysdeps/unix/sysv/linux/alpha/llseek.S: Likewise. * sysdeps/unix/sysv/linux/alpha/sigsuspend.S: Likewise. * sysdeps/unix/sysv/linux/alpha/syscall.S: Likewise. * sysdeps/alpha/memcpy.S: New file. Odd layout because it should eventually contain memmove as well. * sysdeps/alpha/strcmp.S: New file. * sysdeps/alpha/strncmp.S: New file. * sysdeps/alpha/w_sqrt.S: New file. Tue Nov 5 18:06:06 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/mach/hurd/ttyname_r.c: Use `size_t' for len variable. Tue Nov 5 12:09:29 1996 Ulrich Drepper <drepper@cygnus.com> * sysdep/generic/sysdep.h: Define END only if not yet defined. * sysdep/unix/sysdep.h: Define PSEUDO_END only if not yet defined. Reported by Thomas Bushnell, n/BSG. Mon Nov 4 22:46:53 1996 Ulrich Drepper <drepper@cygnus.com> * manual/users.texi (Netgroup Data): Remove { } around @cindex. Mon Nov 4 19:07:05 1996 Ulrich Drepper <drepper@cygnus.com> * malloc/calloc.c: Check for overflow before trying to allocate memory. Proposed by Neil Matthews <nm@adv.sbc.sony.co.jp>. Fri Nov 1 18:18:32 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * manual/llio.texi (Operating Modes): Add missing arguments to @deftypevr in O_NONBLOCK description. * manual/time.texi (Time Zone Functions): Enclose type name in braces in description of tzname. FIXME: this does not yet work correctly in info. Sun Nov 3 17:29:06 1996 Ulrich Drepper <drepper@cygnus.com> * features.h: Add X/Open macros. * posix/unistd.h: Define X/Open macros. * sysdeps/generic/confname.h: Add _SC_XOPEN_XCU_VERSION, _SC_XOPEN_UNIX, _SC_XOPEN_CRYPT, _SC_XOPEN_ENH_I18N, _SC_XOPEN_SHM, _SC_2_CHAR_TERM, _SC_2_C_VERSION, and _SC_2_UPE. * sysdeps/posix/sysconf.c: Handle new constants. * sysdeps/stub/sysconf.c: Likewise. * sysdeps/unix/sysv/linux/posix_opt.h: Add definition of _XOPEN_SHM. * catgets/catgets.c (catopen): Set errno to ENOMEM when we run out of memory. (catgets): Set errno to EBADF when catalog handle is invalid. Set errno to ENOMSG when translation is not available. (catclose): Set errno to EBADF when catalog handle is invalid. * ctype/ctype.h: Declare isascii and toascii when __USE_XOPEN. Likewise for _toupper and _tolower. * manual/arith.texi: Document strtoq, strtoll, strtouq, strtoull, strtof, and strtold. * manual/math.texi: Document HUGE_VALf and HUGE_VALl. * manual/stdio.h: Document ' flag for numeric formats of scanf. * manual/users.texi: Document that cuserid shouldn't be used. * misc/Makefile (routines): Add dirname. (headers): Add libgen.h. (tests): Add tst-dirname. * misc/dirname.c: New file. * misc/libgen.h: New file. * misc/tst-dirname.c: New file. * misc/search.h: Parameter of hcreate must be of type size_t. * misc/hsearch.c: Likewise. * misc/hsearch_r.c: Likewise for hcreate_r. * misc/search.h: Parameters of insque and remque must be `void *'. * misc/insremque.c: Likewise. * posix/unistd.h: Move declarations of mktemp and mkstemp to... * stdlib/stdlib.h: ...here. * posix/unistd.h [__USE_XOPEN]: Add prototypes for crypt, setkey, encrypt, and swab. * stdio-common/printf-parse.h (struct printf_spec): Add pa_wchar and pa_wstring. (parse_one_spec): Remove Linux compatibility code. Recognize %C and %S formats. * stdio-common/printf.h: Add PA_WCHAR and PA_WSTRING. * stdio-common/vfprintf.c: Add implementation of %C and %S format. * stdio-common/vfscanf.c: Likewise for scanf. * stdlib/l64a.c: Return value for 0 must be the empty string. * stdlib/stdlib.h: Declare reentrant function from rand49 family only if __USE_REENTRANT. Declare rand48 functions also if __USE_XOPEN. * stdlib/strtol.c: Return 0 and set errno to EINVAL when BASE is not a legal value. Return 0 and set errno to EINVAL when strou* sees negativ number. * stdlib/tst-strtol.c: De-ANSI-fy. Change expected results for test of unsigned function and negative input. * string/stratcliff.c: Prevent warnings. * string.h: Move declaration of swab to <unistd.h>. * string/swab.c: De-ANSI-fy. * sysdeps/posix/cuserid.c: Implement using getpwuid_r. * sysdeps/posix/mkstemp.c: Include <stdlib.h> for prototype. * sysdeps/posix/mktemp.c: Likewise. * sysdeps/stub/mkstemp.c: Likewise. * sysdeps/stub/mktemp.c: Likewise. * sysvipc/sys/ipc.h: Prototypes of ftok have to be of types `const char *' and `int'. * sysvipc/ftok.c: Likewise. Make sure only lower 8 bits of PROJ_ID are used. Sun Nov 3 03:21:28 1996 Heiko Schroeder <Heiko.Schroeder@post.rwth-aachen.de> * locale/programs/ld-numeric.c (numeric_output): Compute idx[0] correctly. Sat Nov 2 17:44:32 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/posix/cuserid.c: Use reentrant functions. * manual/users.texi: Tell that cuserid is marked to be withdrawn in XPG4.2. Sat Nov 2 14:26:37 1996 Ulrich Drepper <drepper@cygnus.com> Linus said he will make sure no system call will return a value in -1 ... -4095 as a valid result. * sysdeps/unix/sysv/linux/i386/sysdep.h: Correct test for error. * sysdeps/unix/sysv/linux/i386/syscall.S: Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise. Sat Nov 2 16:54:49 1996 NIIBE Yutaka <gniibe@mri.co.jp> * sysdeps/stub/lockfile.c [!USE_IN_LIBIO]: Define weak alias for __funlockfile, not a circular alias. Define __IO_ftrylockfile if USE_IN_LIBIO and __ftrylockfile if not, not vice versa. * sysdeps/unix/sysv/linux/i386/sysdep.S (__errno_location): Make it a weak symbol. * sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location): Likewise. Likewise. * crypt/Makefile (rpath-link): Extend search path to current directory.
-rw-r--r--ChangeLog319
-rw-r--r--Makefile8
-rw-r--r--README.libm827
-rw-r--r--catgets/catgets.c43
-rw-r--r--catgets/nl_types.h32
-rw-r--r--catgets/open_catalog.c28
-rw-r--r--ctype/ctype.h4
-rw-r--r--features.h57
-rw-r--r--grp/grp.h33
-rw-r--r--hurd/hurdsig.c32
-rw-r--r--io/Makefile8
-rw-r--r--io/sys/poll.h32
-rw-r--r--io/sys/stat.h32
-rw-r--r--libio/Makefile2
-rw-r--r--libio/iolibio.h5
-rw-r--r--libio/libio.h2
-rw-r--r--libio/obprintf.c164
-rw-r--r--libio/stdio.h10
-rw-r--r--limits.h96
-rw-r--r--locale/programs/ld-numeric.c30
-rw-r--r--manual/arith.texi126
-rw-r--r--manual/creature.texi26
-rw-r--r--manual/intro.texi46
-rw-r--r--manual/libc.texinfo9
-rw-r--r--manual/llio.texi34
-rw-r--r--manual/math.texi45
-rw-r--r--manual/memory.texi32
-rw-r--r--manual/nss.texi11
-rw-r--r--manual/stdio.texi11
-rw-r--r--manual/time.texi2
-rw-r--r--manual/users.texi5
-rw-r--r--math/mathcalls.h87
-rw-r--r--misc/Makefile5
-rw-r--r--misc/dirname.c52
-rw-r--r--misc/hsearch.c30
-rw-r--r--misc/hsearch_r.c30
-rw-r--r--misc/insremque.c51
-rw-r--r--misc/libgen.h30
-rw-r--r--misc/search.h36
-rw-r--r--misc/sys/select.h34
-rw-r--r--misc/sys/uio.h35
-rw-r--r--misc/tst-dirname.c59
-rw-r--r--posix/Makefile2
-rw-r--r--posix/getconf.c168
-rw-r--r--posix/posix1_lim.h30
-rw-r--r--posix/re_comp.h26
-rw-r--r--posix/sys/wait.h35
-rw-r--r--posix/unistd.h193
-rw-r--r--pwd/pwd.h30
-rw-r--r--shadow/shadow.h33
-rw-r--r--signal/signal.h53
-rw-r--r--stdio-common/printf-parse.h40
-rw-r--r--stdio-common/printf.h2
-rw-r--r--stdio-common/vfprintf.c104
-rw-r--r--stdio-common/vfscanf.c345
-rw-r--r--stdio/obstream.c32
-rw-r--r--stdio/stdio.h2
-rw-r--r--stdlib/atexit.c32
-rw-r--r--stdlib/l64a.c40
-rw-r--r--stdlib/stdlib.h127
-rw-r--r--stdlib/strtol.c10
-rw-r--r--stdlib/tst-strtol.c23
-rw-r--r--string/argz.h6
-rw-r--r--string/stratcliff.c26
-rw-r--r--string/string.h28
-rw-r--r--string/swab.c36
-rw-r--r--sysdeps/alpha/Makefile2
-rw-r--r--sysdeps/alpha/bsd-_setjmp.S4
-rw-r--r--sysdeps/alpha/bsd-setjmp.S4
-rw-r--r--sysdeps/alpha/bzero.S7
-rw-r--r--sysdeps/alpha/div.S110
-rw-r--r--sysdeps/alpha/divl.S4
-rw-r--r--sysdeps/alpha/divlu.S6
-rw-r--r--sysdeps/alpha/divq.S4
-rw-r--r--sysdeps/alpha/divqu.S6
-rw-r--r--sysdeps/alpha/divrem.h308
-rw-r--r--sysdeps/alpha/ffs.S7
-rw-r--r--sysdeps/alpha/htonl.S8
-rw-r--r--sysdeps/alpha/htons.S8
-rw-r--r--sysdeps/alpha/ldiv.S109
-rw-r--r--sysdeps/alpha/lldiv.S1
-rw-r--r--sysdeps/alpha/memchr.S7
-rw-r--r--sysdeps/alpha/memcpy.S276
-rw-r--r--sysdeps/alpha/memset.S7
-rw-r--r--sysdeps/alpha/reml.S4
-rw-r--r--sysdeps/alpha/remlu.S6
-rw-r--r--sysdeps/alpha/remq.S4
-rw-r--r--sysdeps/alpha/remqu.S6
-rw-r--r--sysdeps/alpha/s_copysign.S8
-rw-r--r--sysdeps/alpha/s_fabs.S8
-rw-r--r--sysdeps/alpha/setjmp.S4
-rw-r--r--sysdeps/alpha/stpcpy.S4
-rw-r--r--sysdeps/alpha/stpncpy.S35
-rw-r--r--sysdeps/alpha/strcat.S33
-rw-r--r--sysdeps/alpha/strchr.S36
-rw-r--r--sysdeps/alpha/strcmp.S195
-rw-r--r--sysdeps/alpha/strcpy.S4
-rw-r--r--sysdeps/alpha/strlen.S9
-rw-r--r--sysdeps/alpha/strncat.S4
-rw-r--r--sysdeps/alpha/strncmp.S224
-rw-r--r--sysdeps/alpha/strncpy.S4
-rw-r--r--sysdeps/alpha/strrchr.S7
-rw-r--r--sysdeps/alpha/udiv_qrnnd.S44
-rw-r--r--sysdeps/alpha/w_sqrt.S161
-rw-r--r--sysdeps/generic/confname.h105
-rw-r--r--sysdeps/generic/div.c (renamed from stdlib/div.c)0
-rw-r--r--sysdeps/generic/ldiv.c (renamed from stdlib/ldiv.c)0
-rw-r--r--sysdeps/generic/lldiv.c (renamed from stdlib/lldiv.c)0
-rw-r--r--sysdeps/generic/paths.h1
-rw-r--r--sysdeps/generic/sysdep.h30
-rw-r--r--sysdeps/i386/sysdep.h34
-rw-r--r--sysdeps/mach/getpagesize.c35
-rw-r--r--sysdeps/mach/hurd/ttyname_r.c30
-rw-r--r--sysdeps/posix/cuserid.c34
-rw-r--r--sysdeps/posix/getpagesize.c34
-rw-r--r--sysdeps/posix/mkstemp.c27
-rw-r--r--sysdeps/posix/mktemp.c27
-rw-r--r--sysdeps/posix/sysconf.c193
-rw-r--r--xopen_lim.h90
119 files changed, 4999 insertions, 1302 deletions
diff --git a/ChangeLog b/ChangeLog
index bb350ca894..1d4d396c90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,314 @@
+Wed Nov 6 04:30:26 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/syscalls.list: Add weak alias llseek for
+ _llseek syscall. Reported by Andy Sewell <puck@pookhill.demon.co.uk>.
+
+ * string/argz.h: Don't protect by __USE_GNU.
+
+Tue Nov 5 23:38:28 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * Lots of files: Update and reformat copyright.
+
+ * Makefile (headers): Add xopen_lim.h.
+
+ * catgets/nl_types.h: Move __BEGIN_DECLS before definition of nl_catd.
+
+ * grp/grp.h: Define setgrent, getgrent, endgrent, and getgrent_r
+ if __USE_XOPEN_EXTENDED is defined.
+ * pwd/pwd.h: Define setpwent, getpwent, endpwent, and getpwent_r
+ if __USE_XOPEN_EXTENDED is defined.
+
+ * io/Makefile (routines): Add lchown.
+
+ * io/sys/poll.h: Add definition of POLLWRNORM.
+
+ * io/sys/stat.h: Declare lstat, fchmod, mknod when
+ __USE_XOPEN_EXTENDED is defined.
+
+ * libio/Makefile (routines): Add obprintf.
+ * libio/obprintf.c: New file.
+ * libio/iolibio.h: Add prototypes for _IO_obstack_vprintf and
+ _IO_obstack_printf.
+ * libio/libio.h: Fix typo.
+ * libio/stdio.h: Declare tempnam if __USE_XOPEN_EXTENDED is defined.
+ Add prototypes for obstack_vprintf and obstack_printf.
+
+ * manual/creature.texi: Describe _XOPEN_SOURCE macro.
+ * manual/intro.texi: Add reference to NSS chapter.
+ * manual/libc.texinfo: Update UPDATED.
+ Comment out `@printindex cp'. It works again.
+ * manual/memory.texi: Add description for obstack_ptr_grow,
+ obstack_int_grow, obstack_ptr_grow_fast, and obstack_int_grow_fast.
+ * manual/nss.texi: Add a few @cindex entries and change NSS_STATUS_*
+ index entries to @vindex.
+ * manual/users.texi: Correct @cindex entry for Netgroup.
+
+ * math/mathcalls.h: Use __USE_XOPEN and __USE_XOPEN_EXTENDED to
+ make declarations visible for X/Open sources.
+
+ * misc/search.h: Declare insque/remque only is __USE_SVID or
+ __USE_XOPEN_EXTENDED is defined.
+
+ * misc/sys/uio.h (readv, writev): Change return value from int to
+ ssize_t.
+
+ * posix/Makefile (headers): Add re_comp.h.
+ * posix/re_comp.h: New file. XPG interface to regex functions.
+
+ * posix/getconf.c: Add all names from XPG4.2.
+ * posix/posix1_lim.h: Increase minimum values for _POSIX_CHILD_MAX
+ and _POSIX_OPEN_MAX to minimums from XPG4.2.
+ * sysdeps/generic/confname.h: Add all _SC_* names from XPG4.2.
+ * sysdeps/posix/sysconf.c: Handle new _SC_* values.
+ * sysdeps/stub/sysconf.c: Likewise.
+
+ * posix/unistd.h: Add declaration of ualarm and lchown. Declare
+ usleep, fchown, fchdir, nice, getpgid, setsid, getsid, setreuid,
+ setregid, vfork, ttyslot, symlink, readlink, gethostid, truncate,
+ ftruncate, getdtablesize, brk, sbrk, lockf when
+ __USE_XOPEN_EXTENDED is defined.
+
+ * posix/sys/wait.h: Declare wait3 if __USE_XOPEN_EXTENDED is defined.
+
+ * shadow/shadow.h: Define SHADOW using _PATH_SHADOW.
+ * sysdeps/generic/paths.h: Define _PATH_SHADOW.
+ * sysdeps/unix/sysv/linux/paths.h: Likewise.
+
+ * signal/signal.h: Declare killpg, sigstack and sigaltstack when
+ __USE_XOPEN_EXTENDED is defined.
+
+ * stdio/stdio.h: Declare tempnam when __USE_XOPEN is defined.
+
+ * stdlib/stdlib.h: Make rand48 functions available when __USE_XOPEN
+ is defined.
+ Likewise for valloc, putenv, realpath, [efg]cvt*, and getsubopt
+ functions.
+
+ * string/string.h: Make memccpy, strdup, bcmp, bcopy, bzero, index,
+ and rindex available when __USE_XOPEN_EXTENDED is defined.
+
+ * sysdeps/mach/getpagesize.c: De-ANSI-fy. Change return type to int.
+ * sysdeps/posix/getpagesize.c: Likewise.
+ * sysdeps/stub/getpagesize.c: Likewise.
+ * sysdeps/unix/getpagesize.c: Likewise.
+
+ * time/africa: Update from tzdata1996l.
+ * time/asia: Likewise.
+ * time/australia: Likewise.
+ * time/europe: Likewise.
+ * time/northamerica: Likewise.
+ * time/pacificnew: Likewise.
+ * time/southamerica: Likewise.
+ * time/tzfile.h: Update from tzcode1996m.
+
+ * time/time.h: Declare strptime if __USE_XOPEN.
+ Declare daylight and timezone also if __USE_XOPEN.
+
+ * time/sys/time.h: Remove declaration of ualarm.
+
+ * wctype/wctype.h: Just reference ISO C standard.
+
+Tue Nov 5 01:26:32 1996 Richard Henderson <rth@tamu.edu>
+
+ * crypt/Makefile: Add crypt routines to libc as well iff
+ $(crypt-in-libc) is set. Do this for temporary binary compatibility
+ on existing Linux/Alpha installations.
+
+ * stdlib/div.c, sysdeps/generic/div.c: Move file to .../generic/.
+ * stdlib/ldiv.c, sysdeps/generic/ldiv.c: Likewise.
+ * stdlib/lldiv.c, sysdeps/generic/lldiv.c: Likewise.
+ * sysdeps/alpha/Makefile (divrem): Add divlu, dviqu, remlu, and
+ remqu.
+ * sysdeps/alpha/div.S: New file.
+ * sysdeps/alpha/ldiv.S: New file.
+ * sysdeps/alpha/lldiv.S: New file.
+ * sysdeps/alpha/divrem.h: Merge signed and unsigned division.
+ Take pointers from Linus and tighten the inner loops a bit.
+ * sysdeps/alpha/divl.S: Change defines for merged routines.
+ * sysdeps/alpha/divq.S: Likewise.
+ * sysdeps/alpha/reml.S: Likewise.
+ * sysdeps/alpha/remq.S: Likewise.
+ * sysdeps/alpha/divlu.S: Remove file.
+ * sysdeps/alpha/divqu.S: Likewise.
+ * sysdeps/alpha/remlu.S: Likewise.
+ * sysdeps/alpha/remqu.S: Likewise.
+
+ * sysdeps/alpha/bsd-_setjmp.S: If PROF, call _mcount.
+ * sysdeps/alpha/bsd-setjmp.S: Likewise.
+ * sysdeps/alpha/bzero.S: Likewise.
+ * sysdeps/alpha/ffs.S: Likewise.
+ * sysdeps/alpha/htonl.S: Likewise.
+ * sysdeps/alpha/htons.S: Likewise.
+ * sysdeps/alpha/memchr.S: Likewise.
+ * sysdeps/alpha/memset.S: Likewise.
+ * sysdeps/alpha/s_copysign.S: Likewise.
+ * sysdeps/alpha/s_fabs.S: Likewise.
+ * sysdeps/alpha/setjmp.S: Likewise.
+ * sysdeps/alpha/stpcpy.S: Likewise.
+ * sysdeps/alpha/stpncpy.S: Likewise.
+ * sysdeps/alpha/strcat.S: Likewise.
+ * sysdeps/alpha/strchr.S: Likewise.
+ * sysdeps/alpha/strcpy.S: Likewise.
+ * sysdeps/alpha/strlen.S: Likewise.
+ * sysdeps/alpha/strncat.S: Likewise.
+ * sysdeps/alpha/strncpy.S: Likewise.
+ * sysdeps/alpha/strrchr.S: Likewise.
+ * sysdeps/alpha/udiv_qrnnd.S: Likewise. Fix private labels.
+ Convert two small jumps to use conditional moves.
+ * sysdeps/unix/alpha/sysdep.h: Compress all __STDC__ nastiness.
+ (PSEUDO): If PROF, call _mcount.
+ * sysdeps/unix/sysv/linux/alpha/brk.S: If PROF, call _mcount.
+ * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/llseek.S: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/sigsuspend.S: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/syscall.S: Likewise.
+
+ * sysdeps/alpha/memcpy.S: New file. Odd layout because it should
+ eventually contain memmove as well.
+ * sysdeps/alpha/strcmp.S: New file.
+ * sysdeps/alpha/strncmp.S: New file.
+ * sysdeps/alpha/w_sqrt.S: New file.
+
+Tue Nov 5 18:06:06 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/mach/hurd/ttyname_r.c: Use `size_t' for len variable.
+
+Tue Nov 5 12:09:29 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdep/generic/sysdep.h: Define END only if not yet defined.
+ * sysdep/unix/sysdep.h: Define PSEUDO_END only if not yet defined.
+ Reported by Thomas Bushnell, n/BSG.
+
+Mon Nov 4 22:46:53 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * manual/users.texi (Netgroup Data): Remove { } around @cindex.
+
+Mon Nov 4 19:07:05 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * malloc/calloc.c: Check for overflow before trying to allocate
+ memory. Proposed by Neil Matthews <nm@adv.sbc.sony.co.jp>.
+
+Fri Nov 1 18:18:32 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * manual/llio.texi (Operating Modes): Add missing arguments to
+ @deftypevr in O_NONBLOCK description.
+
+ * manual/time.texi (Time Zone Functions): Enclose type name in
+ braces in description of tzname. FIXME: this does not yet work
+ correctly in info.
+
+Sun Nov 3 17:29:06 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * features.h: Add X/Open macros.
+ * posix/unistd.h: Define X/Open macros.
+ * sysdeps/generic/confname.h: Add _SC_XOPEN_XCU_VERSION,
+ _SC_XOPEN_UNIX, _SC_XOPEN_CRYPT, _SC_XOPEN_ENH_I18N,
+ _SC_XOPEN_SHM, _SC_2_CHAR_TERM, _SC_2_C_VERSION, and _SC_2_UPE.
+ * sysdeps/posix/sysconf.c: Handle new constants.
+ * sysdeps/stub/sysconf.c: Likewise.
+ * sysdeps/unix/sysv/linux/posix_opt.h: Add definition of _XOPEN_SHM.
+
+ * catgets/catgets.c (catopen): Set errno to ENOMEM when
+ we run out of memory.
+ (catgets): Set errno to EBADF when catalog handle is invalid.
+ Set errno to ENOMSG when translation is not available.
+ (catclose): Set errno to EBADF when catalog handle is invalid.
+
+ * ctype/ctype.h: Declare isascii and toascii when __USE_XOPEN.
+ Likewise for _toupper and _tolower.
+
+ * manual/arith.texi: Document strtoq, strtoll, strtouq, strtoull,
+ strtof, and strtold.
+ * manual/math.texi: Document HUGE_VALf and HUGE_VALl.
+ * manual/stdio.h: Document ' flag for numeric formats of scanf.
+ * manual/users.texi: Document that cuserid shouldn't be used.
+
+ * misc/Makefile (routines): Add dirname.
+ (headers): Add libgen.h.
+ (tests): Add tst-dirname.
+ * misc/dirname.c: New file.
+ * misc/libgen.h: New file.
+ * misc/tst-dirname.c: New file.
+
+ * misc/search.h: Parameter of hcreate must be of type size_t.
+ * misc/hsearch.c: Likewise.
+ * misc/hsearch_r.c: Likewise for hcreate_r.
+ * misc/search.h: Parameters of insque and remque must be `void *'.
+ * misc/insremque.c: Likewise.
+
+ * posix/unistd.h: Move declarations of mktemp and mkstemp to...
+ * stdlib/stdlib.h: ...here.
+ * posix/unistd.h [__USE_XOPEN]: Add prototypes for crypt, setkey,
+ encrypt, and swab.
+
+ * stdio-common/printf-parse.h (struct printf_spec): Add pa_wchar
+ and pa_wstring.
+ (parse_one_spec): Remove Linux compatibility code.
+ Recognize %C and %S formats.
+ * stdio-common/printf.h: Add PA_WCHAR and PA_WSTRING.
+ * stdio-common/vfprintf.c: Add implementation of %C and %S format.
+ * stdio-common/vfscanf.c: Likewise for scanf.
+
+ * stdlib/l64a.c: Return value for 0 must be the empty string.
+ * stdlib/stdlib.h: Declare reentrant function from rand49 family
+ only if __USE_REENTRANT.
+ Declare rand48 functions also if __USE_XOPEN.
+
+ * stdlib/strtol.c: Return 0 and set errno to EINVAL when BASE is
+ not a legal value.
+ Return 0 and set errno to EINVAL when strou* sees negativ number.
+ * stdlib/tst-strtol.c: De-ANSI-fy.
+ Change expected results for test of unsigned function and negative
+ input.
+
+ * string/stratcliff.c: Prevent warnings.
+ * string.h: Move declaration of swab to <unistd.h>.
+ * string/swab.c: De-ANSI-fy.
+
+ * sysdeps/posix/cuserid.c: Implement using getpwuid_r.
+ * sysdeps/posix/mkstemp.c: Include <stdlib.h> for prototype.
+ * sysdeps/posix/mktemp.c: Likewise.
+ * sysdeps/stub/mkstemp.c: Likewise.
+ * sysdeps/stub/mktemp.c: Likewise.
+
+ * sysvipc/sys/ipc.h: Prototypes of ftok have to be of types `const
+ char *' and `int'.
+ * sysvipc/ftok.c: Likewise. Make sure only lower 8 bits of
+ PROJ_ID are used.
+
+Sun Nov 3 03:21:28 1996 Heiko Schroeder <Heiko.Schroeder@post.rwth-aachen.de>
+
+ * locale/programs/ld-numeric.c (numeric_output): Compute idx[0]
+ correctly.
+
+Sat Nov 2 17:44:32 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/posix/cuserid.c: Use reentrant functions.
+ * manual/users.texi: Tell that cuserid is marked to be withdrawn in
+ XPG4.2.
+
+Sat Nov 2 14:26:37 1996 Ulrich Drepper <drepper@cygnus.com>
+
+ Linus said he will make sure no system call will return a value
+ in -1 ... -4095 as a valid result.
+ * sysdeps/unix/sysv/linux/i386/sysdep.h: Correct test for error.
+ * sysdeps/unix/sysv/linux/i386/syscall.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/syscall.S: Likewise.
+
+Sat Nov 2 16:54:49 1996 NIIBE Yutaka <gniibe@mri.co.jp>
+
+ * sysdeps/stub/lockfile.c [!USE_IN_LIBIO]: Define weak alias for
+ __funlockfile, not a circular alias.
+ Define __IO_ftrylockfile if USE_IN_LIBIO and __ftrylockfile if not,
+ not vice versa.
+
+ * sysdeps/unix/sysv/linux/i386/sysdep.S (__errno_location): Make
+ it a weak symbol.
+ * sysdeps/unix/sysv/linux/m68k/sysdep.S (__errno_location): Likewise.
+
Tue Nov 5 00:04:48 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* stdio-common/vfprintf.c: Include <libc-lock.h>.
@@ -10,7 +321,7 @@ Mon Nov 4 16:57:42 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/stub/lockfile.c [! USE_IN_LIBIO]: Second definition of
__internal_funlockfile (in terms of itself) should actually be a
definition of __funlockfile.
-
+
* pwd/pwd.h: Get `size_t' from <stddef.h>.
* grp/grp.h: Likewise.
* shadow/shadow.h: Likewise.
@@ -18,12 +329,12 @@ Mon Nov 4 16:57:42 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* stdlib/atexit.c (__new_exitfn): Add missing semicolons after
calls to __libc_lock_lock and __libc_lock_unlock.
* stdlib/random.c (__srandom, __initstate, __setstate, __random):
- Likewise.
+ Likewise.
* hurd/hurdsig.c (write_corefile): Fix typo.
* sysdeps/mach/hurd/sigwait.c: New file.
-
+
Sat Nov 2 01:48:47 1996 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/errnos.h: Move declaration of errno
@@ -624,7 +935,7 @@ Tue Oct 15 22:41:27 1996 Ulrich Drepper <drepper@cygnus.com>
Tue Oct 15 08:06:02 1996 Andreas Jaeger <aj@arthur.pfalz.de>
- * crypt/Makefiel (rpath-link): Extend search path to current directory.
+ * crypt/Makefile (rpath-link): Extend search path to current directory.
Fri Oct 11 09:18:06 1996 Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
diff --git a/Makefile b/Makefile
index ac9e822b48..ac32185440 100644
--- a/Makefile
+++ b/Makefile
@@ -12,9 +12,9 @@
# 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.
+# 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.
#
# Master Makefile for the GNU C library
@@ -82,7 +82,7 @@ subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
$(addprefix install-, no-libc.a bin lib data headers others)
headers := errno.h sys/errno.h errnos.h limits.h values.h \
- features.h gnu-versions.h libc-lock.h
+ features.h gnu-versions.h libc-lock.h xopen_lim.h
aux = sysdep $(libc-init) version
before-compile = $(objpfx)version-info.h
diff --git a/README.libm b/README.libm
index 40edd3177a..33ace8c065 100644
--- a/README.libm
+++ b/README.libm
@@ -27,3 +27,830 @@ s_atanl.c
s_erfl.c
s_expm1l.c
s_log1pl.c
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Methods
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+arcsin
+~~~~~~
+ * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
+ * we approximate asin(x) on [0,0.5] by
+ * asin(x) = x + x*x^2*R(x^2)
+ * where
+ * R(x^2) is a rational approximation of (asin(x)-x)/x^3
+ * and its remez error is bounded by
+ * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
+ *
+ * For x in [0.5,1]
+ * asin(x) = pi/2-2*asin(sqrt((1-x)/2))
+ * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2;
+ * then for x>0.98
+ * asin(x) = pi/2 - 2*(s+s*z*R(z))
+ * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo)
+ * For x<=0.98, let pio4_hi = pio2_hi/2, then
+ * f = hi part of s;
+ * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z)
+ * and
+ * asin(x) = pi/2 - 2*(s+s*z*R(z))
+ * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo)
+ * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+arccos
+~~~~~~
+ * Method :
+ * acos(x) = pi/2 - asin(x)
+ * acos(-x) = pi/2 + asin(x)
+ * For |x|<=0.5
+ * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
+ * For x>0.5
+ * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
+ * = 2asin(sqrt((1-x)/2))
+ * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
+ * = 2f + (2c + 2s*z*R(z))
+ * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
+ * for f so that f+c ~ sqrt(z).
+ * For x<-0.5
+ * acos(x) = pi - 2asin(sqrt((1-|x|)/2))
+ * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+atan2
+~~~~~
+ * Method :
+ * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
+ * 2. Reduce x to positive by (if x and y are unexceptional):
+ * ARG (x+iy) = arctan(y/x) ... if x > 0,
+ * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+atan
+~~~~
+ * Method
+ * 1. Reduce x to positive by atan(x) = -atan(-x).
+ * 2. According to the integer k=4t+0.25 chopped, t=x, the argument
+ * is further reduced to one of the following intervals and the
+ * arctangent of t is evaluated by the corresponding formula:
+ *
+ * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
+ * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
+ * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
+ * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
+ * [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+exp
+~~~
+ * Method
+ * 1. Argument reduction:
+ * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
+ * Given x, find r and integer k such that
+ *
+ * x = k*ln2 + r, |r| <= 0.5*ln2.
+ *
+ * Here r will be represented as r = hi-lo for better
+ * accuracy.
+ *
+ * 2. Approximation of exp(r) by a special rational function on
+ * the interval [0,0.34658]:
+ * Write
+ * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
+ * We use a special Reme algorithm on [0,0.34658] to generate
+ * a polynomial of degree 5 to approximate R. The maximum error
+ * of this polynomial approximation is bounded by 2**-59. In
+ * other words,
+ * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
+ * (where z=r*r, and the values of P1 to P5 are listed below)
+ * and
+ * | 5 | -59
+ * | 2.0+P1*z+...+P5*z - R(z) | <= 2
+ * | |
+ * The computation of exp(r) thus becomes
+ * 2*r
+ * exp(r) = 1 + -------
+ * R - r
+ * r*R1(r)
+ * = 1 + r + ----------- (for better accuracy)
+ * 2 - R1(r)
+ * where
+ * 2 4 10
+ * R1(r) = r - (P1*r + P2*r + ... + P5*r ).
+ *
+ * 3. Scale back to obtain exp(x):
+ * From step 1, we have
+ * exp(x) = 2^k * exp(r)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+hypot
+~~~~~
+ * If (assume round-to-nearest) z=x*x+y*y
+ * has error less than sqrt(2)/2 ulp, than
+ * sqrt(z) has error less than 1 ulp (exercise).
+ *
+ * So, compute sqrt(x*x+y*y) with some care as
+ * follows to get the error below 1 ulp:
+ *
+ * Assume x>y>0;
+ * (if possible, set rounding to round-to-nearest)
+ * 1. if x > 2y use
+ * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
+ * where x1 = x with lower 32 bits cleared, x2 = x-x1; else
+ * 2. if x <= 2y use
+ * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
+ * where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1,
+ * y1= y with lower 32 bits chopped, y2 = y-y1.
+ *
+ * NOTE: scaling may be necessary if some argument is too
+ * large or too tiny
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+j0/y0
+~~~~~
+ * Method -- j0(x):
+ * 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ...
+ * 2. Reduce x to |x| since j0(x)=j0(-x), and
+ * for x in (0,2)
+ * j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x;
+ * (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 )
+ * for x in (2,inf)
+ * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0))
+ * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ * as follow:
+ * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
+ * = 1/sqrt(2) * (cos(x) + sin(x))
+ * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * (To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.)
+ *
+ * Method -- y0(x):
+ * 1. For x<2.
+ * Since
+ * y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...)
+ * therefore y0(x)-2/pi*j0(x)*ln(x) is an even function.
+ * We use the following function to approximate y0,
+ * y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2
+ * where
+ * U(z) = u00 + u01*z + ... + u06*z^6
+ * V(z) = 1 + v01*z + ... + v04*z^4
+ * with absolute approximation error bounded by 2**-72.
+ * Note: For tiny x, U/V = u0 and j0(x)~1, hence
+ * y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27)
+ * 2. For x>=2.
+ * y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0))
+ * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0)
+ * by the method mentioned above.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+j1/y1
+~~~~~
+ * Method -- j1(x):
+ * 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ...
+ * 2. Reduce x to |x| since j1(x)=-j1(-x), and
+ * for x in (0,2)
+ * j1(x) = x/2 + x*z*R0/S0, where z = x*x;
+ * (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 )
+ * for x in (2,inf)
+ * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1))
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * as follow:
+ * cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4)
+ * = 1/sqrt(2) * (sin(x) - cos(x))
+ * sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
+ * = -1/sqrt(2) * (sin(x) + cos(x))
+ * (To avoid cancellation, use
+ * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
+ * to compute the worse one.)
+ *
+ * Method -- y1(x):
+ * 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN
+ * 2. For x<2.
+ * Since
+ * y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...)
+ * therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function.
+ * We use the following function to approximate y1,
+ * y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2
+ * where for x in [0,2] (abs err less than 2**-65.89)
+ * U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4
+ * V(z) = 1 + v0[0]*z + ... + v0[4]*z^5
+ * Note: For tiny x, 1/x dominate y1 and hence
+ * y1(tiny) = -2/pi/tiny, (choose tiny<2**-54)
+ * 3. For x>=2.
+ * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1))
+ * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1)
+ * by method mentioned above.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+jn/yn
+~~~~~
+ * Note 2. About jn(n,x), yn(n,x)
+ * For n=0, j0(x) is called,
+ * for n=1, j1(x) is called,
+ * for n<x, forward recursion us used starting
+ * from values of j0(x) and j1(x).
+ * for n>x, a continued fraction approximation to
+ * j(n,x)/j(n-1,x) is evaluated and then backward
+ * recursion is used starting from a supposed value
+ * for j(n,x). The resulting value of j(0,x) is
+ * compared with the actual value to correct the
+ * supposed value of j(n,x).
+ *
+ * yn(n,x) is similar in all respects, except
+ * that forward recursion is used for all
+ * values of n>1.
+
+jn:
+ /* (x >> n**2)
+ * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+ * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+ * Let s=sin(x), c=cos(x),
+ * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
+ *
+ * n sin(xn)*sqt2 cos(xn)*sqt2
+ * ----------------------------------
+ * 0 s-c c+s
+ * 1 -s-c -c+s
+ * 2 -s+c -c-s
+ * 3 s+c c-s
+...
+ /* x is tiny, return the first Taylor expansion of J(n,x)
+ * J(n,x) = 1/n!*(x/2)^n - ...
+...
+ /* use backward recurrence */
+ /* x x^2 x^2
+ * J(n,x)/J(n-1,x) = ---- ------ ------ .....
+ * 2n - 2(n+1) - 2(n+2)
+ *
+ * 1 1 1
+ * (for large x) = ---- ------ ------ .....
+ * 2n 2(n+1) 2(n+2)
+ * -- - ------ - ------ -
+ * x x x
+ *
+ * Let w = 2n/x and h=2/x, then the above quotient
+ * is equal to the continued fraction:
+ * 1
+ * = -----------------------
+ * 1
+ * w - -----------------
+ * 1
+ * w+h - ---------
+ * w+2h - ...
+ *
+ * To determine how many terms needed, let
+ * Q(0) = w, Q(1) = w(w+h) - 1,
+ * Q(k) = (w+k*h)*Q(k-1) - Q(k-2),
+ * When Q(k) > 1e4 good for single
+ * When Q(k) > 1e9 good for double
+ * When Q(k) > 1e17 good for quadruple
+
+...
+ /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n)
+ * Hence, if n*(log(2n/x)) > ...
+ * single 8.8722839355e+01
+ * double 7.09782712893383973096e+02
+ * long double 1.1356523406294143949491931077970765006170e+04
+ * then recurrent value may overflow and the result is
+ * likely underflow to zero
+
+yn:
+ /* (x >> n**2)
+ * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+ * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi)
+ * Let s=sin(x), c=cos(x),
+ * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then
+ *
+ * n sin(xn)*sqt2 cos(xn)*sqt2
+ * ----------------------------------
+ * 0 s-c c+s
+ * 1 -s-c -c+s
+ * 2 -s+c -c-s
+ * 3 s+c c-s
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+lgamma
+~~~~~~
+ * Method:
+ * 1. Argument Reduction for 0 < x <= 8
+ * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
+ * reduce x to a number in [1.5,2.5] by
+ * lgamma(1+s) = log(s) + lgamma(s)
+ * for example,
+ * lgamma(7.3) = log(6.3) + lgamma(6.3)
+ * = log(6.3*5.3) + lgamma(5.3)
+ * = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)
+ * 2. Polynomial approximation of lgamma around its
+ * minimun ymin=1.461632144968362245 to maintain monotonicity.
+ * On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
+ * Let z = x-ymin;
+ * lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
+ * where
+ * poly(z) is a 14 degree polynomial.
+ * 2. Rational approximation in the primary interval [2,3]
+ * We use the following approximation:
+ * s = x-2.0;
+ * lgamma(x) = 0.5*s + s*P(s)/Q(s)
+ * with accuracy
+ * |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
+ * Our algorithms are based on the following observation
+ *
+ * zeta(2)-1 2 zeta(3)-1 3
+ * lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ...
+ * 2 3
+ *
+ * where Euler = 0.5771... is the Euler constant, which is very
+ * close to 0.5.
+ *
+ * 3. For x>=8, we have
+ * lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
+ * (better formula:
+ * lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
+ * Let z = 1/x, then we approximation
+ * f(z) = lgamma(x) - (x-0.5)(log(x)-1)
+ * by
+ * 3 5 11
+ * w = w0 + w1*z + w2*z + w3*z + ... + w6*z
+ * where
+ * |w - f(z)| < 2**-58.74
+ *
+ * 4. For negative x, since (G is gamma function)
+ * -x*G(-x)*G(x) = pi/sin(pi*x),
+ * we have
+ * G(x) = pi/(sin(pi*x)*(-x)*G(-x))
+ * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
+ * Hence, for x<0, signgam = sign(sin(pi*x)) and
+ * lgamma(x) = log(|Gamma(x)|)
+ * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);
+ * Note: one should avoid compute pi*(-x) directly in the
+ * computation of sin(pi*(-x)).
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+log
+~~~
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Approximation of log(1+f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Reme algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
+ * (the values of Lg1 to Lg7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lg1*s +...+Lg7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log(1+f) = f - s*(f - R) (if f is not too large)
+ * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
+ *
+ * 3. Finally, log(x) = k*ln2 + log(1+f).
+ * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ * Here ln2 is split into two floating point number:
+ * ln2_hi + ln2_lo,
+ * where n*ln2_hi is always exact for |n| < 2000.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+log10
+~~~~~
+ * Method :
+ * Let log10_2hi = leading 40 bits of log10(2) and
+ * log10_2lo = log10(2) - log10_2hi,
+ * ivln10 = 1/log(10) rounded.
+ * Then
+ * n = ilogb(x),
+ * if(n<0) n = n+1;
+ * x = scalbn(x,-n);
+ * log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
+ *
+ * Note 1:
+ * To guarantee log10(10**n)=n, where 10**n is normal, the rounding
+ * mode must set to Round-to-Nearest.
+ * Note 2:
+ * [1/log(10)] rounded to 53 bits has error .198 ulps;
+ * log10 is monotonic at all binary break points.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+pow
+~~~
+ * Method: Let x = 2 * (1+f)
+ * 1. Compute and return log2(x) in two pieces:
+ * log2(x) = w1 + w2,
+ * where w1 has 53-24 = 29 bit trailing zeros.
+ * 2. Perform y*log2(x) = n+y' by simulating muti-precision
+ * arithmetic, where |y'|<=0.5.
+ * 3. Return x**y = 2**n*exp(y'*log2)
+ *
+ * Special cases:
+ * 1. (anything) ** 0 is 1
+ * 2. (anything) ** 1 is itself
+ * 3. (anything) ** NAN is NAN
+ * 4. NAN ** (anything except 0) is NAN
+ * 5. +-(|x| > 1) ** +INF is +INF
+ * 6. +-(|x| > 1) ** -INF is +0
+ * 7. +-(|x| < 1) ** +INF is +0
+ * 8. +-(|x| < 1) ** -INF is +INF
+ * 9. +-1 ** +-INF is NAN
+ * 10. +0 ** (+anything except 0, NAN) is +0
+ * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
+ * 12. +0 ** (-anything except 0, NAN) is +INF
+ * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF
+ * 14. -0 ** (odd integer) = -( +0 ** (odd integer) )
+ * 15. +INF ** (+anything except 0,NAN) is +INF
+ * 16. +INF ** (-anything except 0,NAN) is +0
+ * 17. -INF ** (anything) = -0 ** (-anything)
+ * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
+ * 19. (-anything except 0 and inf) ** (non-integer) is NAN
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+rem_pio2 return the remainder of x rem pi/2 in y[0]+y[1]
+~~~~~~~~
+This is one of the basic functions which is written with highest accuracy
+in mind.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+sinh
+~~~~
+ * Method :
+ * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
+ * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
+ * 2.
+ * E + E/(E+1)
+ * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
+ * 2
+ *
+ * 22 <= x <= lnovft : sinh(x) := exp(x)/2
+ * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
+ * ln2ovft < x : sinh(x) := x*shuge (overflow)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+sqrt
+~~~~
+ * Method:
+ * Bit by bit method using integer arithmetic. (Slow, but portable)
+ * 1. Normalization
+ * Scale x to y in [1,4) with even powers of 2:
+ * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then
+ * sqrt(x) = 2^k * sqrt(y)
+ * 2. Bit by bit computation
+ * Let q = sqrt(y) truncated to i bit after binary point (q = 1),
+ * i 0
+ * i+1 2
+ * s = 2*q , and y = 2 * ( y - q ). (1)
+ * i i i i
+ *
+ * To compute q from q , one checks whether
+ * i+1 i
+ *
+ * -(i+1) 2
+ * (q + 2 ) <= y. (2)
+ * i
+ * -(i+1)
+ * If (2) is false, then q = q ; otherwise q = q + 2 .
+ * i+1 i i+1 i
+ *
+ * With some algebric manipulation, it is not difficult to see
+ * that (2) is equivalent to
+ * -(i+1)
+ * s + 2 <= y (3)
+ * i i
+ *
+ * The advantage of (3) is that s and y can be computed by
+ * i i
+ * the following recurrence formula:
+ * if (3) is false
+ *
+ * s = s , y = y ; (4)
+ * i+1 i i+1 i
+ *
+ * otherwise,
+ * -i -(i+1)
+ * s = s + 2 , y = y - s - 2 (5)
+ * i+1 i i+1 i i
+ *
+ * One may easily use induction to prove (4) and (5).
+ * Note. Since the left hand side of (3) contain only i+2 bits,
+ * it does not necessary to do a full (53-bit) comparison
+ * in (3).
+ * 3. Final rounding
+ * After generating the 53 bits result, we compute one more bit.
+ * Together with the remainder, we can decide whether the
+ * result is exact, bigger than 1/2ulp, or less than 1/2ulp
+ * (it will never equal to 1/2ulp).
+ * The rounding mode can be detected by checking whether
+ * huge + tiny is equal to huge, and whether huge - tiny is
+ * equal to huge for some floating point number "huge" and "tiny".
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+cos
+~~~
+ * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x.
+ *
+ * Algorithm
+ * 1. Since cos(-x) = cos(x), we need only to consider positive x.
+ * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
+ * 3. cos(x) is approximated by a polynomial of degree 14 on
+ * [0,pi/4]
+ * 4 14
+ * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
+ * where the remez error is
+ *
+ * | 2 4 6 8 10 12 14 | -58
+ * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2
+ * | |
+ *
+ * 4 6 8 10 12 14
+ * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then
+ * cos(x) = 1 - x*x/2 + r
+ * since cos(x+y) ~ cos(x) - sin(x)*y
+ * ~ cos(x) - x*y,
+ * a correction term is necessary in cos(x) and hence
+ * cos(x+y) = 1 - (x*x/2 - (r - x*y))
+ * For better accuracy when x > 0.3, let qx = |x|/4 with
+ * the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125.
+ * Then
+ * cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)).
+ * Note that 1-qx and (x*x/2-qx) is EXACT here, and the
+ * magnitude of the latter is at least a quarter of x*x/2,
+ * thus, reducing the rounding error in the subtraction.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+sin
+~~~
+ * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x.
+ * Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
+ *
+ * Algorithm
+ * 1. Since sin(-x) = -sin(x), we need only to consider positive x.
+ * 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0.
+ * 3. sin(x) is approximated by a polynomial of degree 13 on
+ * [0,pi/4]
+ * 3 13
+ * sin(x) ~ x + S1*x + ... + S6*x
+ * where
+ *
+ * |sin(x) 2 4 6 8 10 12 | -58
+ * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2
+ * | x |
+ *
+ * 4. sin(x+y) = sin(x) + sin'(x')*y
+ * ~ sin(x) + (1-x*x/2)*y
+ * For better accuracy, let
+ * 3 2 2 2 2
+ * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
+ * then 3 2
+ * sin(x) = x + (S1*x + (x *(r-y/2)+y))
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+tan
+~~~
+ * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
+ * Input x is assumed to be bounded by ~pi/4 in magnitude.
+ * Input y is the tail of x.
+ * Input k indicates whether tan (if k=1) or
+ * -1/tan (if k= -1) is returned.
+ *
+ * Algorithm
+ * 1. Since tan(-x) = -tan(x), we need only to consider positive x.
+ * 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0.
+ * 3. tan(x) is approximated by a odd polynomial of degree 27 on
+ * [0,0.67434]
+ * 3 27
+ * tan(x) ~ x + T1*x + ... + T13*x
+ * where
+ *
+ * |tan(x) 2 4 26 | -59.2
+ * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2
+ * | x |
+ *
+ * Note: tan(x+y) = tan(x) + tan'(x)*y
+ * ~ tan(x) + (1+x*x)*y
+ * Therefore, for better accuracy in computing tan(x+y), let
+ * 3 2 2 2 2
+ * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
+ * then
+ * 3 2
+ * tan(x+y) = x + (T1*x + (x *(r+y)+y))
+ *
+ * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then
+ * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
+ * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+atan
+~~~~
+ * Method
+ * 1. Reduce x to positive by atan(x) = -atan(-x).
+ * 2. According to the integer k=4t+0.25 chopped, t=x, the argument
+ * is further reduced to one of the following intervals and the
+ * arctangent of t is evaluated by the corresponding formula:
+ *
+ * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
+ * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
+ * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
+ * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
+ * [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+erf
+~~~
+ * x
+ * 2 |\
+ * erf(x) = --------- | exp(-t*t)dt
+ * sqrt(pi) \|
+ * 0
+ *
+ * erfc(x) = 1-erf(x)
+ * Note that
+ * erf(-x) = -erf(x)
+ * erfc(-x) = 2 - erfc(x)
+ *
+ * Method:
+ * 1. For |x| in [0, 0.84375]
+ * erf(x) = x + x*R(x^2)
+ * erfc(x) = 1 - erf(x) if x in [-.84375,0.25]
+ * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375]
+ * where R = P/Q where P is an odd poly of degree 8 and
+ * Q is an odd poly of degree 10.
+ * -57.90
+ * | R - (erf(x)-x)/x | <= 2
+ *
+ *
+ * Remark. The formula is derived by noting
+ * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
+ * and that
+ * 2/sqrt(pi) = 1.128379167095512573896158903121545171688
+ * is close to one. The interval is chosen because the fix
+ * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
+ * near 0.6174), and by some experiment, 0.84375 is chosen to
+ * guarantee the error is less than one ulp for erf.
+ *
+ * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and
+ * c = 0.84506291151 rounded to single (24 bits)
+ * erf(x) = sign(x) * (c + P1(s)/Q1(s))
+ * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0
+ * 1+(c+P1(s)/Q1(s)) if x < 0
+ * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
+ * Remark: here we use the taylor series expansion at x=1.
+ * erf(1+s) = erf(1) + s*Poly(s)
+ * = 0.845.. + P1(s)/Q1(s)
+ * That is, we use rational approximation to approximate
+ * erf(1+s) - (c = (single)0.84506291151)
+ * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
+ * where
+ * P1(s) = degree 6 poly in s
+ * Q1(s) = degree 6 poly in s
+ *
+ * 3. For x in [1.25,1/0.35(~2.857143)],
+ * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
+ * erf(x) = 1 - erfc(x)
+ * where
+ * R1(z) = degree 7 poly in z, (z=1/x^2)
+ * S1(z) = degree 8 poly in z
+ *
+ * 4. For x in [1/0.35,28]
+ * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
+ * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
+ * = 2.0 - tiny (if x <= -6)
+ * erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6, else
+ * erf(x) = sign(x)*(1.0 - tiny)
+ * where
+ * R2(z) = degree 6 poly in z, (z=1/x^2)
+ * S2(z) = degree 7 poly in z
+ *
+ * Note1:
+ * To compute exp(-x*x-0.5625+R/S), let s be a single
+ * precision number and s := x; then
+ * -x*x = -s*s + (s-x)*(s+x)
+ * exp(-x*x-0.5626+R/S) =
+ * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
+ * Note2:
+ * Here 4 and 5 make use of the asymptotic series
+ * exp(-x*x)
+ * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
+ * x*sqrt(pi)
+ * We use rational approximation to approximate
+ * g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
+ * Here is the error bound for R1/S1 and R2/S2
+ * |R1/S1 - f(x)| < 2**(-62.57)
+ * |R2/S2 - f(x)| < 2**(-61.52)
+ *
+ * 5. For inf > x >= 28
+ * erf(x) = sign(x) *(1 - tiny) (raise inexact)
+ * erfc(x) = tiny*tiny (raise underflow) if x > 0
+ * = 2 - tiny if x<0
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+expm1 Returns exp(x)-1, the exponential of x minus 1
+~~~~~
+ * Method
+ * 1. Argument reduction:
+ * Given x, find r and integer k such that
+ *
+ * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658
+ *
+ * Here a correction term c will be computed to compensate
+ * the error in r when rounded to a floating-point number.
+ *
+ * 2. Approximating expm1(r) by a special rational function on
+ * the interval [0,0.34658]:
+ * Since
+ * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
+ * we define R1(r*r) by
+ * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
+ * That is,
+ * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+ * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+ * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+ * We use a special Reme algorithm on [0,0.347] to generate
+ * a polynomial of degree 5 in r*r to approximate R1. The
+ * maximum error of this polynomial approximation is bounded
+ * by 2**-61. In other words,
+ * R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+ * where Q1 = -1.6666666666666567384E-2,
+ * Q2 = 3.9682539681370365873E-4,
+ * Q3 = -9.9206344733435987357E-6,
+ * Q4 = 2.5051361420808517002E-7,
+ * Q5 = -6.2843505682382617102E-9;
+ * (where z=r*r, and the values of Q1 to Q5 are listed below)
+ * with error bounded by
+ * | 5 | -61
+ * | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2
+ * | |
+ *
+ * expm1(r) = exp(r)-1 is then computed by the following
+ * specific way which minimize the accumulation rounding error:
+ * 2 3
+ * r r [ 3 - (R1 + R1*r/2) ]
+ * expm1(r) = r + --- + --- * [--------------------]
+ * 2 2 [ 6 - r*(3 - R1*r/2) ]
+ *
+ * To compensate the error in the argument reduction, we use
+ * expm1(r+c) = expm1(r) + c + expm1(r)*c
+ * ~ expm1(r) + c + r*c
+ * Thus c+r*c will be added in as the correction terms for
+ * expm1(r+c). Now rearrange the term to avoid optimization
+ * screw up:
+ * ( 2 2 )
+ * ({ ( r [ R1 - (3 - R1*r/2) ] ) } r )
+ * expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+ * ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 )
+ * ( )
+ *
+ * = r - E
+ * 3. Scale back to obtain expm1(x):
+ * From step 1, we have
+ * expm1(x) = either 2^k*[expm1(r)+1] - 1
+ * = or 2^k*[expm1(r) + (1-2^-k)]
+ * 4. Implementation notes:
+ * (A). To save one multiplication, we scale the coefficient Qi
+ * to Qi*2^i, and replace z by (x^2)/2.
+ * (B). To achieve maximum accuracy, we compute expm1(x) by
+ * (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+ * (ii) if k=0, return r-E
+ * (iii) if k=-1, return 0.5*(r-E)-0.5
+ * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E)
+ * else return 1.0+2.0*(r-E);
+ * (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+ * (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+ * (vii) return 2^k(1-((E+2^-k)-r))
+ *
+ * Special cases:
+ * expm1(INF) is INF, expm1(NaN) is NaN;
+ * expm1(-INF) is -1, and
+ * for finite argument, only expm1(0)=0 is exact.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+log1p
+~~~~~
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * 1+x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * Note. If k=0, then f=x is exact. However, if k!=0, then f
+ * may not be representable exactly. In that case, a correction
+ * term is need. Let u=1+x rounded. Let c = (1+x)-u, then
+ * log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
+ * and add back the correction term c/u.
+ * (Note: when x > 2**53, one can simply return log(x))
+ *
+ * 2. Approximation of log1p(f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Reme algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s
+ * (the values of Lp1 to Lp7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lp1*s +...+Lp7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log1p(f) = f - (hfsq - s*(hfsq+R)).
+ *
+ * 3. Finally, log1p(x) = k*ln2 + log1p(f).
+ * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ * Here ln2 is split into two floating point number:
+ * ln2_hi + ln2_lo,
+ * where n*ln2_hi is always exact for |n| < 2000.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/catgets/catgets.c b/catgets/catgets.c
index 7c45b4569a..ab7d28a682 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -1,23 +1,24 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
-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 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.
+ 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. */
+ 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 <alloca.h>
+#include <errno.h>
#include <nl_types.h>
#include <stdlib.h>
#include <string.h>
@@ -45,6 +46,7 @@ catopen (const char *cat_name, int flag)
if (result->cat_name == NULL)
{
free (result);
+ __set_errno (ENOMEM);
return (nl_catd) -1;
}
@@ -76,6 +78,7 @@ catopen (const char *cat_name, int flag)
{
free ((void *) result->cat_name);
free ((void *) result);
+ __set_errno (ENOMEM);
return (nl_catd) -1;
}
@@ -89,6 +92,7 @@ catopen (const char *cat_name, int flag)
free ((void *) result->cat_name);
free ((void *) result->env_var);
free ((void *) result);
+ __set_errno (ENOMEM);
return (nl_catd) -1;
}
}
@@ -120,7 +124,10 @@ catgets (nl_catd catalog_desc, int set, int message, const char *string)
__open_catalog (catalog, 1);
if (catalog->status == nonexisting)
- return (char *) string;
+ {
+ __set_errno (EBADF);
+ return (char *) string;
+ }
idx = ((set * message) % catalog->plane_size) * 3;
cnt = 0;
@@ -134,6 +141,7 @@ catgets (nl_catd catalog_desc, int set, int message, const char *string)
}
while (++cnt < catalog->plane_depth);
+ __set_errno (ENOMSG);
return (char *) string;
}
@@ -151,7 +159,10 @@ catclose (nl_catd catalog_desc)
else if (catalog->status == malloced)
free ((void *) catalog->file_ptr);
else if (catalog->status != closed && catalog->status != nonexisting)
- return -1;
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
if (catalog->nlspath)
free ((void *) catalog->nlspath);
diff --git a/catgets/nl_types.h b/catgets/nl_types.h
index 9f78d67468..40fb965508 100644
--- a/catgets/nl_types.h
+++ b/catgets/nl_types.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 _NL_TYPES_H
#define _NL_TYPES_H 1
@@ -26,12 +26,12 @@ Boston, MA 02111-1307, USA. */
/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */
#define NL_CAT_LOCALE 1
-/* Message catalog descriptor type. */
-typedef void *nl_catd;
-
__BEGIN_DECLS
+/* Message catalog descriptor type. */
+typedef void *nl_catd;
+
/* Open message catalog for later use, returning descriptor. */
extern nl_catd catopen __P ((__const char *__cat_name, int __flag));
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 2a52877bbe..5335b433c7 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -1,21 +1,21 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
-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 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.
+ 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. */
+ 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 <endian.h>
#include <fcntl.h>
diff --git a/ctype/ctype.h b/ctype/ctype.h
index 18e3a3dbad..f4048b3dc7 100644
--- a/ctype/ctype.h
+++ b/ctype/ctype.h
@@ -114,7 +114,7 @@ extern int tolower __P ((int __c));
extern int toupper __P ((int __c));
-#if defined(__USE_SVID) || defined(__USE_MISC)
+#if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN)
/* Return nonzero iff C is in the ASCII set
(i.e., is no more than 7 bits wide). */
@@ -126,7 +126,7 @@ extern int toascii __P ((int __c));
#endif /* Use SVID or use misc. */
-#ifdef __USE_SVID
+#if defined(__USE_SVID) || defined(__USE_XOPEN)
/* These are the same as `toupper' and `tolower'. */
__exctype (_toupper);
__exctype (_tolower);
diff --git a/features.h b/features.h
index deacda1663..9b20512c51 100644
--- a/features.h
+++ b/features.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 _FEATURES_H
@@ -26,6 +26,8 @@ Cambridge, MA 02139, USA. */
__STRICT_ANSI__ ANSI Standard C.
_POSIX_SOURCE IEEE Std 1003.1.
_POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if ==2 add IEEE Std 1003.2.
+ _XOPEN_SOURCE Includes POSIX and XPG things.
+ _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
_BSD_SOURCE ANSI, POSIX, and 4.3BSD things.
_SVID_SOURCE ANSI, POSIX, and SVID things.
_GNU_SOURCE All of the above, plus GNU extensions.
@@ -43,6 +45,8 @@ Cambridge, MA 02139, USA. */
__USE_POSIX Define IEEE Std 1003.1 things.
__USE_POSIX2 Define IEEE Std 1003.2 things.
+ __USE_XOPEN Define XPG things.
+ __USE_XOPEN_EXTENDED Define X/Open Unix things.
__USE_BSD Define 4.3BSD things.
__USE_SVID Define SVID things.
__USE_MISC Define things common to BSD and System V Unix.
@@ -62,6 +66,8 @@ Cambridge, MA 02139, USA. */
/* Undefine everything, so we get a clean slate. */
#undef __USE_POSIX
#undef __USE_POSIX2
+#undef __USE_XOPEN
+#undef __USE_XOPEN_EXTENDED
#undef __USE_BSD
#undef __USE_SVID
#undef __USE_MISC
@@ -71,7 +77,7 @@ Cambridge, MA 02139, USA. */
#undef __KERNEL_STRICT_NAMES
/* Suppress kernel-name space pollution unless user expressedly asks
- for it: */
+ for it. */
#ifndef _LOOSE_KERNEL_NAMES
# define __KERNEL_STRICT_NAMES
#endif
@@ -83,8 +89,9 @@ Cambridge, MA 02139, USA. */
/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
#if defined (_BSD_SOURCE) && \
!(defined (_POSIX_SOURCE) || defined (_POSIX_C_SOURCE) || \
+ defined (_XOPEN_SOURCE) || defined (_XOPEN_SOURCE_DEFINED) || \
defined (_GNU_SOURCE) || defined (_SVID_SOURCE))
-#define __FAVOR_BSD 1
+# define __FAVOR_BSD 1
#endif
/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
@@ -93,6 +100,10 @@ Cambridge, MA 02139, USA. */
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 2
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 1
+#undef _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_SOURCE_EXTENDED 1
#undef _BSD_SOURCE
#define _BSD_SOURCE 1
#undef _SVID_SOURCE
@@ -102,7 +113,8 @@ Cambridge, MA 02139, USA. */
/* If nothing (other than _GNU_SOURCE) is defined,
define _BSD_SOURCE and _SVID_SOURCE. */
#if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) && \
- !defined (_POSIX_C_SOURCE) && !defined (_BSD_SOURCE) && \
+ !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE) && \
+ !defined (_XOPEN_SOURCE_EXTENDED) && !defined (_BSD_SOURCE) && \
!defined (_SVID_SOURCE))
#define _BSD_SOURCE 1
#define _SVID_SOURCE 1
@@ -115,14 +127,23 @@ Cambridge, MA 02139, USA. */
#define _POSIX_C_SOURCE 2
#endif
-#if defined (_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1
+#if (defined (_POSIX_SOURCE) || _POSIX_C_SOURCE >= 1 || \
+ defined (_XOPEN_SOURCE))
#define __USE_POSIX 1
#endif
-#if defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 2
+#if (defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 2 || \
+ defined (_XOPEN_SOURCE))
#define __USE_POSIX2 1
#endif
+#ifdef _XOPEN_SOURCE
+#define __USE_XOPEN 1
+#ifdef _XOPEN_SOURCE_EXTENDED
+#define __USE_XOPEN_EXTENDED 1
+#endif
+#endif
+
#if defined (_BSD_SOURCE) || defined (_SVID_SOURCE)
#define __USE_MISC 1
#endif
diff --git a/grp/grp.h b/grp/grp.h
index c37985a40f..5243afee7a 100644
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 9.2.1 Group Database Access <grp.h>
@@ -32,6 +32,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <stddef.h>
+#define __need_size_t
+#include <stddef.h>
+
/* The group structure. */
struct group
@@ -66,7 +69,7 @@ extern struct group *__grpscan __P ((__ptr_t *__p,
#endif
-#if defined(__USE_SVID) || defined(__USE_MISC) || defined (__USE_BSD)
+#if defined(__USE_SVID) || defined (__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Rewind the group-file stream. */
extern void setgrent __P ((void));
@@ -98,7 +101,7 @@ extern struct group *getgrnam __P ((__const char *__name));
PLEASE NOTE: these functions are not yet standardized. The interface
may change in later versions of this library. */
-#if defined(__USE_SVID) || defined(__USE_MISC) || defined (__USE_BSD)
+#if defined(__USE_SVID) || defined (__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
extern int getgrent_r __P ((struct group *__resultbuf, char *buffer,
size_t __buflen, struct group **__result));
#endif
diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c
index bc2ad9ef40..30e2919d82 100644
--- a/hurd/hurdsig.c
+++ b/hurd/hurdsig.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96, 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. */
+ 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 <stdlib.h>
#include <stdio.h>
diff --git a/io/Makefile b/io/Makefile
index 552a3db255..ca17832220 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -12,9 +12,9 @@
# 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.
+# 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.
#
# Sub-makefile for I/O portion of the library.
@@ -39,7 +39,7 @@ routines := \
creat \
chdir fchdir \
getcwd getwd getdirname \
- chown fchown \
+ chown fchown lchown \
ttyname ttyname_r isatty \
link symlink readlink \
unlink rmdir \
diff --git a/io/sys/poll.h b/io/sys/poll.h
index 48b9afac9e..09ee7f27de 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -1,21 +1,21 @@
/* Compatibility definitions for System V `poll' interface.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ Copyright (C) 1994, 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 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.
+ 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. */
+ 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_POLL_H
#define _SYS_POLL_H
@@ -37,6 +37,9 @@ struct pollfd
#define POLLPRI 02 /* There is urgent data to read. */
#define POLLOUT 04 /* Writing now will not block. */
+/* Some aliases. */
+#define POLLWRNORM POLLOUT
+
/* Event types always implicitly polled for. These bits need not be set in
`events', but they will appear in `revents' to indicate the status of
the file descriptor. */
@@ -62,4 +65,3 @@ extern int poll __P ((struct pollfd *__fds, unsigned long int __nfds,
__END_DECLS
#endif /* sys/poll.h */
-
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 2c23102d33..5bc497c671 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 5.6 File Characteristics <sys/stat.h>
@@ -127,7 +127,7 @@ extern int fstat __P ((int __fd, struct stat *__buf));
/* Get file attributes about FILE and put them in BUF.
If FILE is a symbolic link, do not follow it. */
extern int __lstat __P ((__const char *__file, struct stat *__buf));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
extern int lstat __P ((__const char *__file, struct stat *__buf));
#endif
@@ -139,7 +139,7 @@ extern int chmod __P ((__const char *__file, __mode_t __mode));
/* Set file access permissions of the file FD is open on to MODE. */
extern int __fchmod __P ((int __fd, __mode_t __mode));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
extern int fchmod __P ((int __fd, __mode_t __mode));
#endif
@@ -164,7 +164,7 @@ extern int mkdir __P ((__const char *__path, __mode_t __mode));
device numbers with the `makedev' macro above). */
extern int __mknod __P ((__const char *__path,
__mode_t __mode, __dev_t __dev));
-#if defined(__USE_MISC) || defined(__USE_BSD)
+#if defined(__USE_MISC) || defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
extern int mknod __P ((__const char *__path,
__mode_t __mode, __dev_t __dev));
#endif
diff --git a/libio/Makefile b/libio/Makefile
index 0c34125ac6..4266ad4e59 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -32,7 +32,7 @@ routines := \
\
clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar \
memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
- vdprintf vscanf vsnprintf \
+ vdprintf vscanf vsnprintf obprintf \
\
libc_fatal
diff --git a/libio/iolibio.h b/libio/iolibio.h
index e5de77ea85..92df6a6fd2 100644
--- a/libio/iolibio.h
+++ b/libio/iolibio.h
@@ -32,6 +32,11 @@ extern int _IO_sprintf __P((char *, const char*, ...));
extern int _IO_ungetc __P((int, _IO_FILE*));
extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list));
extern int _IO_vsprintf __P((char*, const char*, _IO_va_list));
+
+struct obstack;
+extern int _IO_obstack_vprintf __P ((struct obstack *, const char *,
+ _IO_va_list));
+extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
#ifndef _IO_pos_BAD
#define _IO_pos_BAD ((_IO_fpos_t)(-1))
#endif
diff --git a/libio/libio.h b/libio/libio.h
index 129c7312c2..0cd6b39c24 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -97,7 +97,7 @@ the executable file might be covered by the GNU General Public License. */
/* Magic numbers and bits for the _flags field.
The magic numbers use the high-order bits of _flags;
- the remaining bits are abailable for variable flags.
+ the remaining bits are available for variable flags.
Note: The magic numbers must all be negative if stdio
emulation is desired. */
diff --git a/libio/obprintf.c b/libio/obprintf.c
new file mode 100644
index 0000000000..bd629f1ee0
--- /dev/null
+++ b/libio/obprintf.c
@@ -0,0 +1,164 @@
+/* Print output of stream to given obstack.
+ 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. */
+
+
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include "libioP.h"
+#include <string.h>
+#include <errno.h>
+#include <obstack.h>
+#include <stdarg.h>
+
+
+struct _IO_obstack_file
+{
+ struct _IO_FILE file;
+ const void *vtable;
+ struct obstack *obstack;
+};
+
+
+static int
+_IO_obstack_overflow (_IO_FILE *fp, int c)
+{
+ struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+ /* Make room for another character. This might as well allocate a
+ new chunk a memory and moves the old contents over. */
+ if (c != EOF)
+ obstack_1grow (obstack, c);
+
+ /* Setup the buffer pointers again. */
+ fp->_IO_write_base = obstack_base (obstack);
+ fp->_IO_write_ptr = obstack_next_free (obstack);
+ fp->_IO_write_end = fp->_IO_write_base + obstack_room (obstack);
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+
+ return c;
+}
+
+
+static _IO_size_t
+_IO_obstack_xsputn (_IO_FILE *fp, const void *data, _IO_size_t n)
+{
+ struct obstack *obstack = ((struct _IO_obstack_file *) fp)->obstack;
+
+ if (fp->_IO_write_ptr + n > fp->_IO_write_end)
+ {
+ /* We need some more memory. First shrink the buffer to the
+ space we really currently need. */
+ obstack_blank (obstack, fp->_IO_write_ptr - fp->_IO_write_end);
+
+ /* Now grow for N bytes. */
+ obstack_blank (obstack, n);
+
+ /* Setup the buffer pointers again. */
+ fp->_IO_write_base = obstack_base (obstack);
+ fp->_IO_write_ptr = obstack_next_free (obstack);
+ fp->_IO_write_end = (fp->_IO_write_base + obstack_room (obstack));
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack, fp->_IO_write_end - fp->_IO_write_ptr);
+ }
+ else
+ {
+ memcpy (fp->_IO_write_ptr, data, n);
+ fp->_IO_write_ptr += n;
+ }
+
+ return n;
+}
+
+
+/* the jump table. */
+static struct _IO_jump_t _IO_obstack_jumps =
+{
+ JUMP_INIT_DUMMY,
+ JUMP_INIT(finish, NULL),
+ JUMP_INIT(overflow, _IO_obstack_overflow),
+ JUMP_INIT(underflow, NULL),
+ JUMP_INIT(uflow, NULL),
+ JUMP_INIT(pbackfail, NULL),
+ JUMP_INIT(xsputn, _IO_obstack_xsputn),
+ JUMP_INIT(xsgetn, NULL),
+ JUMP_INIT(seekoff, NULL),
+ JUMP_INIT(seekpos, NULL),
+ JUMP_INIT(setbuf, NULL),
+ JUMP_INIT(sync, NULL),
+ JUMP_INIT(doallocate, NULL),
+ JUMP_INIT(read, NULL),
+ JUMP_INIT(write, NULL),
+ JUMP_INIT(seek, NULL),
+ JUMP_INIT(close, NULL),
+ JUMP_INIT(stat, NULL)
+};
+
+
+int
+_IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+{
+ struct obstack_FILE
+ {
+ struct _IO_obstack_file ofile;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+#endif
+ } new_f;
+ int result;
+
+#ifdef _IO_MTSAFE_IO
+ new_f.ofile.file._lock = &new_f.lock;
+#endif
+
+ _IO_init ((_IO_FILE *) &new_f.ofile, 0);
+ _IO_JUMPS (&new_f.ofile.file) = &_IO_obstack_jumps;
+ _IO_str_init_static (&new_f.ofile.file, obstack_base (obstack),
+ (obstack_object_size (obstack) +
+ obstack_room (obstack)), obstack_next_free (obstack));
+ /* Now allocate the rest of the current chunk. */
+ obstack_blank_fast (obstack,
+ (new_f.ofile.file._IO_write_end
+ - new_f.ofile.file._IO_write_ptr));
+ new_f.ofile.obstack = obstack;
+
+ result = _IO_vfprintf ((_IO_FILE *) &new_f, format, args);
+
+ /* Shrink the buffer to the space we really currently need. */
+ obstack_blank (obstack, (new_f.ofile.file._IO_write_ptr
+ - new_f.ofile.file._IO_write_end));
+
+ return result;
+}
+weak_alias (_IO_obstack_vprintf, obstack_vprintf)
+
+
+int
+_IO_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+ int result;
+ va_list ap;
+ va_start (ap, format);
+ result = _IO_obstack_vprintf (obstack, format, ap);
+ va_end (ap);
+ return result;
+}
+weak_alias (_IO_obstack_printf, obstack_printf)
diff --git a/libio/stdio.h b/libio/stdio.h
index 7e09786215..75d22f94c0 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -138,7 +138,7 @@ extern char* tmpnam __P ((char*));
#ifdef __USE_REENTRANT
extern char* tmpnam_r __P ((char*));
#endif
-#ifdef __USE_SVID
+#if defined(__USE_SVID) || defined(__USE_XOPEN)
extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
#endif
extern char *__stdio_gen_tempname __P ((char *__buf, size_t bufsize,
@@ -162,6 +162,14 @@ extern int vsscanf __P ((__const char *, __const char *, _G_va_list));
extern int __vsscanf __P ((__const char *, __const char *, _G_va_list));
#endif
+#ifdef __USE_GNU
+struct obstack;
+extern int obstack_vprintf __P ((struct obstack *__obstack,
+ __const char *__fmt, _G_va_list));
+extern int obstack_printf __P ((struct obstack *__obstack, __const char *__fmt,
+ ...));
+#endif
+
#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
extern FILE *fdopen __P ((int, __const char *));
extern int fileno __P ((FILE*));
diff --git a/limits.h b/limits.h
index e0cb1986cd..c7b1278638 100644
--- a/limits.h
+++ b/limits.h
@@ -24,11 +24,15 @@
#ifdef __USE_POSIX
/* POSIX adds things to <limits.h>. */
-#include <posix1_lim.h>
+# include <posix1_lim.h>
#endif
#ifdef __USE_POSIX2
-#include <posix2_lim.h>
+# include <posix2_lim.h>
+#endif
+
+#ifdef __USE_XOPEN
+# include <xopen_lim.h>
#endif
@@ -47,8 +51,8 @@
/* We only protect from multiple inclusion here, because all the other
#include's protect themselves, and in GCC 2 we may #include_next through
multiple copies of this file before we get to GCC's. */
-#ifndef _LIMITS_H
-#define _LIMITS_H
+# ifndef _LIMITS_H
+# define _LIMITS_H 1
/* We don't have #include_next.
Define ANSI <limits.h> for standard 32-bit words. */
@@ -57,69 +61,63 @@
and 32-bit `int's and `long int's. */
/* Number of bits in a `char'. */
-#define CHAR_BIT 8
+# define CHAR_BIT 8
/* Maximum length of any multibyte character in any locale. */
-#define MB_LEN_MAX 6
+# define MB_LEN_MAX 6
/* Minimum and maximum values a `signed char' can hold. */
-#define SCHAR_MIN (-128)
-#define SCHAR_MAX 127
+# define SCHAR_MIN (-128)
+# define SCHAR_MAX 127
/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
-#ifdef __STDC__
-#define UCHAR_MAX 255U
-#else
-#define UCHAR_MAX 255
-#endif
+# define UCHAR_MAX 255
/* Minimum and maximum values a `char' can hold. */
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MIN 0
-#define CHAR_MAX UCHAR_MAX
-#else
-#define CHAR_MIN SCHAR_MIN
-#define CHAR_MAX SCHAR_MAX
-#endif
+# ifdef __CHAR_UNSIGNED__
+# define CHAR_MIN 0
+# define CHAR_MAX UCHAR_MAX
+# else
+# define CHAR_MIN SCHAR_MIN
+# define CHAR_MAX SCHAR_MAX
+# endif
/* Minimum and maximum values a `signed short int' can hold. */
-#define SHRT_MIN (-32768)
-#define SHRT_MAX 32767
+# define SHRT_MIN (-32768)
+# define SHRT_MAX 32767
/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
-#define USHRT_MAX 65535
+# define USHRT_MAX 65535
/* Minimum and maximum values a `signed int' can hold. */
-#define INT_MIN (- INT_MAX - 1)
-#define INT_MAX 2147483647
+# define INT_MIN (- INT_MAX - 1)
+# define INT_MAX 2147483647
/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
-#ifdef __STDC__
-#define UINT_MAX 4294967295U
-#else
-#define UINT_MAX 4294967295
-#endif
-
-#ifdef __alpha__
+# ifdef __STDC__
+# define UINT_MAX 4294967295U
+# else
+# define UINT_MAX 4294967295
+# endif
/* Minimum and maximum values a `signed long int' can hold. */
-#define LONG_MAX 9223372036854775807L
-#define LONG_MIN (- LONG_MAX - 1L)
+# ifdef __alpha__
+# define LONG_MAX 9223372036854775807L
+# else
+# define LONG_MAX 2147483647L
+# endif
+# define LONG_MIN (- LONG_MAX - 1L)
/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
-#define ULONG_MAX 18446744073709551615L
-
-#else
-
-/* Minimum and maximum values a `signed long int' can hold. */
-#define LONG_MAX INT_MAX
-#define LONG_MIN INT_MIN
-
-/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
-#define ULONG_MAX UINT_MAX
-
-#endif
-
-
-#endif /* limits.h */
+# ifdef __alpha__
+# define ULONG_MAX 18446744073709551615UL
+# else
+# ifdef __STDC__
+# define ULONG_MAX 4294967295UL
+# else
+# define ULONG_MAX 4294967295L
+# endif
+# endif
+
+# endif /* limits.h */
#endif /* GCC 2. */
diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c
index dd5ced7206..69ea7e0b3e 100644
--- a/locale/programs/ld-numeric.c
+++ b/locale/programs/ld-numeric.c
@@ -1,21 +1,21 @@
/* 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>.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
-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 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.
+ 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -126,7 +126,7 @@ numeric_output (struct localedef_t *locale, const char *output_path)
iov[cnt].iov_len = sizeof (idx);
++cnt;
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
+ idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
iov[cnt].iov_base = (void *) (numeric->decimal_point ?: "");
iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
++cnt;
diff --git a/manual/arith.texi b/manual/arith.texi
index b3f646a187..8ea9508e3e 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -469,7 +469,8 @@ syntax used for integer constants in C.
Otherwise @var{base} must have a value between @code{2} and @code{35}.
If @var{base} is @code{16}, the digits may optionally be preceded by
-@samp{0x} or @samp{0X}.
+@samp{0x} or @samp{0X}. If base has no legal value the value returned
+is @code{0l} and the global variable @code{errno} is set to @code{EINVAL}.
@item
Any remaining characters in the string. If @var{tailptr} is not a null
@@ -492,6 +493,11 @@ representable because of overflow, @code{strtol} returns either
appropriate for the sign of the value. It also sets @code{errno}
to @code{ERANGE} to indicate there was overflow.
+Because the value @code{0l} is a correct result for @code{strtol} the
+user who is interested in handling errors should set the global variable
+@code{errno} to @code{0} before calling this function. So it can be
+tested whether an error occured or not.
+
There is an example at the end of this section.
@end deftypefun
@@ -504,6 +510,51 @@ value with type @code{unsigned long int}. No @samp{+} or @samp{-} sign
may appear before the number, but the syntax is otherwise the same as
described above for @code{strtol}. The value returned in case of
overflow is @code{ULONG_MAX} (@pxref{Range of Type}).
+
+Like @code{strtol} this function sets @code{errno} and returns the value
+@code{0ul} in case the value for @var{base} is not in the legal range.
+For @code{strtoul} this can happen in another situation. In case the
+number to be converted is negative @code{strtoul} also sets @code{errno}
+to @code{EINVAL} and returns @code{0ul}.
+@end deftypefun
+
+@comment stdlib.h
+@comment BSD
+@deftypefun {long long int} strtoq (const char *@var{string}, char **@var{tailptr}, int @var{base})
+The @code{strtoq} (``string-to-quad-word'') function is like
+@code{strtol} except that is deals with extra long numbers and it
+returns its value with type @code{long long int}.
+
+If the string has valid syntax for an integer but the value is not
+representable because of overflow, @code{strtoq} returns either
+@code{LONG_LONG_MAX} or @code{LONG_LONG_MIN} (@pxref{Range of Type}), as
+appropriate for the sign of the value. It also sets @code{errno} to
+@code{ERANGE} to indicate there was overflow.
+@end deftypefun
+
+@comment stdlib.h
+@comment GNU
+@deftypefun {long long int} strtoll (const char *@var{string}, char **@var{tailptr}, int @var{base})
+@code{strtoll} is only an commonly used other name for the @code{strtoq}
+function. Everything said for @code{strtoq} applies to @code{strtoll}
+as well.
+@end deftypefun
+
+@comment stdlib.h
+@comment BSD
+@deftypefun {unsigned long long int} strtouq (const char *@var{string}, char **@var{tailptr}, int @var{base})
+The @code{strtouq} (``string-to-unsigned-quad-word'') function is like
+@code{strtoul} except that is deals with extra long numbers and it
+returns its value with type @code{unsigned long long int}. The value
+returned in case of overflow is @code{ULONG_LONG_MAX} (@pxref{Range of Type}).
+@end deftypefun
+
+@comment stdlib.h
+@comment GNU
+@deftypefun {unsigned long long int} strtoull (const char *@var{string}, char **@var{tailptr}, int @var{base})
+@code{strtoull} is only an commonly used other name for the @code{strtouq}
+function. Everything said for @code{strtouq} applies to @code{strtoull}
+as well.
@end deftypefun
@comment stdlib.h
@@ -523,6 +574,29 @@ value rather than @code{long int}. The @code{atoi} function is also
considered obsolete; use @code{strtol} instead.
@end deftypefun
+The POSIX locales contain some information about how to format numbers
+(@pxref{General Numeric}). This mainly deals with representing numbers
+for better readability for humans. The functions present so far in this
+section cannot handle numbers in this form.
+
+If this functionality is needed in a program one can use the functions
+from the @code{scanf} family which know about the flag @samp{'} for
+parsing numeric input (@pxref{Numeric Input Conversions}). Sometimes it
+is more desirable to have finer control.
+
+In these situation one could use the function
+@code{__strto@var{XXX}_internal}. @var{XXX} here stands for any of the
+above forms. All numeric conversion functions (including the functions
+to process floating-point numbers) have such a counterpart. The
+difference to the normal for is the extra argument at the end of the
+parameter list. If this value has an non-zero value the handling of
+number grouping is enabled. The advantage from using these functions is
+that the @var{tailptr} parameters allow to determine which part of the
+input is processed. The @code{scanf} functions don't provide this
+information. The drawback of using these functions is that they are not
+portable. They only exist in the GNU C library.
+
+
Here is a function which parses a string as a sequence of integers and
returns the sum of them:
@@ -604,8 +678,8 @@ number, no conversion is performed. In this case, @code{strtod} returns
a value of zero and the value returned in @code{*@var{tailptr}} is the
value of @var{string}.
-In a locale other than the standard @code{"C"} locale, this function may
-recognize additional locale-dependent syntax.
+In a locale other than the standard @code{"C"} or @code{"POSIX"} locale,
+this function may recognize additional locale-dependent syntax.
If the string has valid syntax for a floating-point number but the value
is not representable because of overflow, @code{strtod} returns either
@@ -613,9 +687,55 @@ positive or negative @code{HUGE_VAL} (@pxref{Mathematics}), depending on
the sign of the value. Similarly, if the value is not representable
because of underflow, @code{strtod} returns zero. It also sets @code{errno}
to @code{ERANGE} if there was overflow or underflow.
+
+Since the value zero which is returned in the error case is also a valid
+result the user should set the global variable @code{errno} to null
+before calling this function. So one can test for failures after the
+call since all failures set @code{errno} to a non-zero value.
@end deftypefun
@comment stdlib.h
+@comment GNU
+@deftypefun float strtof (const char *@var{string}, char **@var{tailptr})
+This function is similar to the @code{strtod} function but it returns a
+@code{float} value instead of a @code{double} value. If the precision
+of a @code{float} value is sufficent this function should be used since
+it is much faster than @code{strtod} on some architectures. The reasons
+are obvious: @w{IEEE 754} defines @code{float} to have a mantissa of 23
+bits while @code{double} has 53 bits and every additional bit of
+precision can require additional computation.
+
+If the string has valid syntax for a floating-point number but the value
+is not representable because of overflow, @code{strtof} returns either
+positive or negative @code{HUGE_VALf} (@pxref{Mathematics}), depending on
+the sign of the value.
+
+This function is a GNU extension.
+@end deftypefun
+
+@comment stdlib.h
+@comment GNU
+@deftypefun {long double} strtold (const char *@var{string}, char **@var{tailptr})
+This function is similar to the @code{strtod} function but it returns a
+@code{long double} value instead of a @code{double} value. It should be
+used when high presision is used. On systems which define a @code{long
+double} type (i.e., on which it is not the same as @code{double})
+running this function might take significently more time since more bits
+of precision are required.
+
+If the string has valid syntax for a floating-point number but the value
+is not representable because of overflow, @code{strtold} returns either
+positive or negative @code{HUGE_VALl} (@pxref{Mathematics}), depending on
+the sign of the value.
+
+This function is a GNU extension.
+@end deftypefun
+
+As for the integer parsing functions there are additional functions
+which will handle numbers represented using the grouping scheme of the
+current locale (@pxref{Parsing of Integers}).
+
+@comment stdlib.h
@comment ANSI
@deftypefun double atof (const char *@var{string})
This function is similar to the @code{strtod} function, except that it
diff --git a/manual/creature.texi b/manual/creature.texi
index 6b4d42fbe9..37dee54b56 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -67,15 +67,31 @@ the normal C library.
@comment GNU
@defvr Macro _SVID_SOURCE
If you define this macro, functionality derived from SVID is
-included as well as the ANSI C, POSIX.1, and POSIX.2 material.
+included as well as the ANSI C, POSIX.1, POSIX.2, and X/Open material.
+@end defvr
+
+@comment (none)
+@comment XOPEN
+@defvr Macro _XOPEN_SOURCE
+If you define these macro, functionality described in the X/Open
+Portability Guide is included. This is an superset of the POSIX.1 and
+POSIX.2 functionality and in fact @code{_POSIX_SOURCE} and
+@code{_POSIX_C_SOURCE} get automatically be defined.
+
+But as the great unifaction of all Unices there is also functionality
+only available in BSD and SVID is included.
+
+If the macro @code{_XOPEN_SOURCE_EXTENDED} is also defined, even more
+functionality is available. The extra functions will make all functions
+available which are necessary for the X/Open Unix brand.
@end defvr
@comment (none)
@comment GNU
@defvr Macro _GNU_SOURCE
If you define this macro, everything is included: ANSI C, POSIX.1,
-POSIX.2, BSD, SVID, and GNU extensions. In the cases where POSIX.1
-conflicts with BSD, the POSIX definitions take precedence.
+POSIX.2, BSD, SVID, X/Open, and GNU extensions. In the cases where
+POSIX.1 conflicts with BSD, the POSIX definitions take precedence.
If you want to get the full effect of @code{_GNU_SOURCE} but make the
BSD definitions take precedence over the POSIX definitions, use this
@@ -96,8 +112,8 @@ get very strange errors at run time.
@comment (none)
@comment GNU
@defvr Macro _REENTRANT,_THREAD_SAFE
-If you define this macro, reentrant versions of several functions get
-declared. Some of the functions is specified in POSIX.1c but many others
+If you define one this macro, reentrant versions of several functions get
+declared. Some of the functions are specified in POSIX.1c but many others
are only available on a few other systems or are unique to GNU libc.
The problem is that the standardization of the thread safe C library
interface still is behind.
diff --git a/manual/intro.texi b/manual/intro.texi
index 19f04a1474..382f35c039 100644
--- a/manual/intro.texi
+++ b/manual/intro.texi
@@ -78,11 +78,11 @@ standards each function or symbol comes from.
@menu
* ANSI C:: The American National Standard for the
- C programming language.
+ C programming language.
* POSIX:: The IEEE 1003 standards for operating
- systems.
+ systems.
* Berkeley Unix:: BSD and SunOS.
-* SVID:: The System V Interface Description.
+* SVID:: The System V Interface Description.
@end menu
@node ANSI C, POSIX, , Standards and Portability
@@ -152,7 +152,7 @@ pattern matching facilities (@pxref{Pattern Matching}).
@comment Roland sez:
@comment The GNU C library as it stands conforms to 1003.2 draft 11, which
@comment specifies:
-@comment
+@comment
@comment Several new macros in <limits.h>.
@comment popen, pclose
@comment <regex.h> (which is not yet fully implemented--wait on this)
@@ -210,7 +210,7 @@ the GNU C library.
@menu
* Header Files:: How to include the header files in your
- programs.
+ programs.
* Macro Definitions:: Some functions in the library may really
be implemented as macros.
* Reserved Names:: The C standard reserves some names for
@@ -332,7 +332,7 @@ function---perhaps to make your program easier to debug. There are
two ways you can do this:
@itemize @bullet
-@item
+@item
You can avoid a macro definition in a specific use by enclosing the name
of the function in parentheses. This works because the name of the
function doesn't appear in a syntactic context where it is recognizable
@@ -429,7 +429,7 @@ raise the possibility of conflict with future versions of the C
or POSIX standards, so you should avoid these names.
@itemize @bullet
-@item
+@item
Names beginning with a capital @samp{E} followed a digit or uppercase
letter may be used for additional error code names. @xref{Error
Reporting}.
@@ -526,11 +526,11 @@ Here is an overview of the contents of the remaining chapters of
this manual.
@itemize @bullet
-@item
+@item
@ref{Error Reporting}, describes how errors detected by the library
are reported.
-@item
+@item
@ref{Language Features}, contains information about library support for
standard parts of the C language, including things like the @code{sizeof}
operator and the symbolic constant @code{NULL}, how to write functions
@@ -539,18 +539,18 @@ ranges and other properties of the numerical types. There is also a simple
debugging mechanism which allows you to put assertions in your code, and
have diagnostic messages printed if the tests fail.
-@item
+@item
@ref{Memory Allocation}, describes the GNU library's facilities for
dynamic allocation of storage. If you do not know in advance how much
storage your program needs, you can allocate it dynamically instead,
and manipulate it via pointers.
-@item
+@item
@ref{Character Handling}, contains information about character
classification functions (such as @code{isspace}) and functions for
performing case conversion.
-@item
+@item
@ref{String and Array Utilities}, has descriptions of functions for
manipulating strings (null-terminated character arrays) and general
byte arrays, including operations such as copying and comparison.
@@ -595,7 +595,7 @@ Internet host addressing and how to use the system network databases.
attributes of a terminal device. If you want to disable echo of
characters typed by the user, for example, read this chapter.
-@item
+@item
@ref{Mathematics}, contains information about the math library
functions. These include things like random-number generators and
remainder functions on integers as well as the usual trigonometric and
@@ -606,7 +606,7 @@ exponential functions on floating-point numbers.
for simple arithmetic, analysis of floating-point values, and reading
numbers from strings.
-@item
+@item
@ref{Searching and Sorting}, contains information about functions
for searching and sorting arrays. You can use these functions on any
kind of array by providing an appropriate comparison function.
@@ -619,13 +619,13 @@ and shell file name patterns, and for expanding words as the shell does.
@ref{Date and Time}, describes functions for measuring both calendar time
and CPU time, as well as functions for setting alarms and timers.
-@item
+@item
@ref{Extended Characters}, contains information about manipulating
characters and strings using character sets larger than will fit in
-the usual @code{char} data type.
+the usual @code{char} data type.
-@item
-@ref{Locales}, describes how selecting a particular country
+@item
+@ref{Locales}, describes how selecting a particular country
or language affects the behavior of the library. For example, the locale
affects collation sequences for strings and how monetary values are
formatted.
@@ -645,7 +645,7 @@ critical sections of your program.
@ref{Process Startup}, tells how your programs can access their
command-line arguments and environment variables.
-@item
+@item
@ref{Processes}, contains information about how to start new processes
and run programs.
@@ -656,6 +656,12 @@ interest if you are writing a shell or other program which handles job
control specially.
@item
+@ref{Name Service Switch}, describes the services which are available
+for looking up names in the system databases, how to determine which
+service is used for which database, and how these services are
+implemented so that contributors can design their own services.
+
+@item
@ref{User Database}, and @ref{Group Database}, tell you how to access
the system user and group databases.
@@ -664,7 +670,7 @@ the system user and group databases.
about the hardware and software configuration your program is executing
under.
-@item
+@item
@ref{System Configuration}, tells you how you can get information about
various operating system limits. Most of these parameters are provided for
compatibility with POSIX.
diff --git a/manual/libc.texinfo b/manual/libc.texinfo
index 773859318d..80eb4965f7 100644
--- a/manual/libc.texinfo
+++ b/manual/libc.texinfo
@@ -13,7 +13,7 @@
@c sold 0.06/1.09, print run out 21may96
@set EDITION 0.07 DRAFT
@set VERSION 2.00 Beta
-@set UPDATED 16 Aug 1996
+@set UPDATED 4 Oct 1996
@set ISBN 1-882114-53-1
@ifinfo
@@ -988,12 +988,7 @@ Porting the GNU C Library
@node Concept Index, Type Index, Copying, Top
@unnumbered Concept Index
-@comment Could somebody with better texinfo knowledge look into this?
-@comment When I comment out the following line I get
-@comment Misplaced `{'.
-@comment Misplaced `}'.
-@comment This happens even if the libc.cp file is empty.
-@comment @printindex cp
+@printindex cp
@node Type Index, Function Index, Concept Index, Top
@unnumbered Type Index
diff --git a/manual/llio.texi b/manual/llio.texi
index 6a5a5d27e0..7891ee66e0 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -31,10 +31,10 @@ directly.)
@menu
* Opening and Closing Files:: How to open and close file
- descriptors.
+ descriptors.
* I/O Primitives:: Reading and writing data.
* File Position Primitive:: Setting a descriptor's file
- position.
+ position.
* Descriptors and Streams:: Converting descriptor to stream
or vice-versa.
* Stream/Descriptor Precautions:: Precautions needed if you use both
@@ -47,7 +47,7 @@ directly.)
file descriptors.
* Descriptor Flags:: Fcntl commands for manipulating
flags associated with file
- descriptors.
+ descriptors.
* File Status Flags:: Fcntl commands for manipulating
flags associated with open files.
* File Locks:: Fcntl commands for implementing
@@ -164,7 +164,7 @@ The function @code{close} closes the file descriptor @var{filedes}.
Closing a file has the following consequences:
@itemize @bullet
-@item
+@item
The file descriptor is deallocated.
@item
@@ -195,7 +195,7 @@ TEMP_FAILURE_RETRY (close (desc));
@item ENOSPC
@itemx EIO
@itemx EDQUOT
-When the file is accessed by NFS, these errors from @code{write} can sometimes
+When the file is accessed by NFS, these errors from @code{write} can sometimes
not be detected until @code{close}. @xref{I/O Primitives}, for details
on their meaning.
@end table
@@ -322,7 +322,7 @@ efficient for the system to batch up consecutive writes and do them all
at once when convenient. Normally they will always be written to disk
within a minute or less.)
@c !!! xref fsync
-You can use the @code{O_FSYNC} open mode to make @code{write} always
+You can use the @code{O_FSYNC} open mode to make @code{write} always
store the data to disk before returning; @pxref{Operating Modes}.
In the case of an error, @code{write} returns @code{-1}. The following
@@ -431,7 +431,7 @@ file position. This count may be positive or negative.
Specifies that @var{whence} is a count of characters from the end of
the file. A negative count specifies a position within the current
extent of the file; a positive count specifies a position past the
-current end. If you set the position past the current end, and
+current end. If you set the position past the current end, and
actually write data, you will extend the file with zeros up to that
position.@end table
@@ -482,10 +482,10 @@ streams instead of file descriptors.
@end deftypefun
You can have multiple descriptors for the same file if you open the file
-more than once, or if you duplicate a descriptor with @code{dup}.
+more than once, or if you duplicate a descriptor with @code{dup}.
Descriptors that come from separate calls to @code{open} have independent
file positions; using @code{lseek} on one descriptor has no effect on the
-other. For example,
+other. For example,
@smallexample
@group
@@ -656,7 +656,7 @@ the stream.
@menu
* Linked Channels:: Dealing with channels sharing a file position.
* Independent Channels:: Dealing with separately opened, unlinked channels.
-* Cleaning Streams:: Cleaning a stream makes it safe to use
+* Cleaning Streams:: Cleaning a stream makes it safe to use
another channel.
@end menu
@@ -914,7 +914,7 @@ the @code{select} with a newly calculated timeout based on the current
time. See the example below. See also @ref{Interrupted Primitives}.
If an error occurs, @code{select} returns @code{-1} and does not modify
-the argument file descriptor sets. The following @code{errno} error
+the argument file descriptor sets. The following @code{errno} error
conditions are defined for this function:
@table @code
@@ -1164,7 +1164,7 @@ The symbols in this section are defined in the header file
@deftypevr Macro int F_GETFD
This macro is used as the @var{command} argument to @code{fcntl}, to
specify that it should return the file descriptor flags associated
-with the @var{filedes} argument.
+with the @var{filedes} argument.
The normal return value from @code{fcntl} with this command is a
nonnegative number which can be interpreted as the bitwise OR of the
@@ -1223,7 +1223,7 @@ without altering any other flags:
@smallexample
/* @r{Set the @code{FD_CLOEXEC} flag of @var{desc} if @var{value} is nonzero,}
@r{or clear the flag if @var{value} is 0.}
- @r{Return 0 on success, or -1 on error with @code{errno} set.} */
+ @r{Return 0 on success, or -1 on error with @code{errno} set.} */
int
set_cloexec_flag (int desc, int value)
@@ -1523,7 +1523,7 @@ resulting in your data appearing someplace before the real end of file.
@comment fcntl.h
@comment POSIX.1
-@deftypevr O_NONBLOCK
+@deftypevr Macro int O_NONBLOCK
The bit that enables nonblocking mode for the file. If this bit is set,
@code{read} requests on the file can return immediately with a failure
status if there is no input immediately available, instead of blocking.
@@ -1638,7 +1638,7 @@ altering any other flags:
@group
/* @r{Set the @code{O_NONBLOCK} flag of @var{desc} if @var{value} is nonzero,}
@r{or clear the flag if @var{value} is 0.}
- @r{Return 0 on success, or -1 on error with @code{errno} set.} */
+ @r{Return 0 on success, or -1 on error with @code{errno} set.} */
int
set_nonblock_flag (int desc, int value)
@@ -1891,7 +1891,7 @@ for billing purposes.
Having multiple copies of the program simultaneously writing to the
file could cause the contents of the file to become mixed up. But
you can prevent this kind of problem by setting a write lock on the
-file before actually writing to the file.
+file before actually writing to the file.
If the program also needs to read the file and wants to make sure that
the contents of the file are in a consistent state, then it can also use
@@ -1920,7 +1920,7 @@ where @code{select} would report the socket as having an ``exceptional
condition''. @xref{Waiting for I/O}.)
If the file descriptor corresponds to a terminal device, then @code{SIGIO}
-signals are sent to the foreground process group of the terminal.
+signals are sent to the foreground process group of the terminal.
@xref{Job Control}.
@pindex fcntl.h
diff --git a/manual/math.texi b/manual/math.texi
index a97d76c2a1..7de6d169ac 100644
--- a/manual/math.texi
+++ b/manual/math.texi
@@ -36,8 +36,8 @@ over a domain that is only a subset of real numbers. For example, the
@code{1}. If you pass an argument to one of these functions that is
outside the domain over which it is defined, the function sets
@code{errno} to @code{EDOM} to indicate a @dfn{domain error}. On
-machines that support IEEE floating point, functions reporting error
-@code{EDOM} also return a NaN.
+machines that support @w{IEEE 754} floating point, functions reporting
+error @code{EDOM} also return a NaN.
Some of these functions are defined mathematically to result in a
complex value over parts of their domains. The most familiar example of
@@ -59,8 +59,8 @@ instead. In this case, @code{errno} might or might not be
set to @code{ERANGE}.
The only completely reliable way to check for domain and range errors is
-to set @code{errno} to @code{0} before you call the mathematical function
-and test @code{errno} afterward. As a consequence of this use of
+to set @code{errno} to @code{0} before you call the mathematical function
+and test @code{errno} afterward. As a consequence of this use of
@code{errno}, use of the mathematical functions is not reentrant if you
check for errors.
@@ -74,14 +74,37 @@ Handling}, for more information about signals.)
@comment ANSI
@deftypevr Macro double HUGE_VAL
An expression representing a particular very large number. On machines
-that use IEEE floating point format, the value is ``infinity''. On
-other machines, it's typically the largest positive number that can be
-represented.
+that use @w{IEEE 754} floating point format, the value is ``infinity''.
+On other machines, it's typically the largest positive number that can
+be represented.
-The value of this macro is used as the return value from various
-mathematical functions in overflow situations.
+The value of this macro is used as the return value from various
+mathematical @code{double} returning functions in overflow situations.
@end deftypevr
+@comment math.h
+@comment GNU
+@deftypevr Macro float HUGE_VALf
+This macro is similar to the @code{HUGE_VAL} macro except that it is
+used by functions returning @code{float} values.
+
+This macro is a GNU extension.
+@end deftypevr
+
+@comment math.h
+@comment GNU
+@deftypevr Macro {long double} HUGE_VALl
+This macro is similar to the @code{HUGE_VAL} macro except that it is
+used by functions returning @code{long double} values. The value is
+only different from @code{HUGE_VAL} if the architecture really supports
+@code{long double} values.
+
+This macro is a GNU extension.
+@end deftypevr
+
+
+@comment
+
For more information about floating-point representations and limits,
see @ref{Floating Point Parameters}. In particular, the macro
@code{DBL_MAX} might be more appropriate than @code{HUGE_VAL} for many
@@ -343,7 +366,7 @@ of @var{x} is too large; that is, if overflow occurs.
@comment math.h
@comment ANSI
@deftypefun double tanh (double @var{x})
-This function returns the hyperbolic tangent of @var{x}, whose
+This function returns the hyperbolic tangent of @var{x}, whose
mathematical definition is @w{@code{sinh (@var{x}) / cosh (@var{x})}}.
@end deftypefun
@@ -497,7 +520,7 @@ restore that state.
@deftypefun {void *} setstate (void *@var{state})
The @code{setstate} function restores the random number state
information @var{state}. The argument must have been the result of
-a previous call to @var{initstate} or @var{setstate}.
+a previous call to @var{initstate} or @var{setstate}.
The return value is the previous value of the state information array.
You can use thise value later as an argument to @code{setstate} to
diff --git a/manual/memory.texi b/manual/memory.texi
index 343da0bb7e..6cbe77ff0e 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1093,6 +1093,22 @@ It adds a single byte containing @var{c} to the growing object.
@comment obstack.h
@comment GNU
+@deftypefun void obstack_ptr_grow (struct obstack *@var{obstack-ptr}, void *@var{data})
+Adding the value of a pointer one can use the function
+@code{obstack_ptr_grow}. It adds @code{sizeof (void *)} bytes
+containing the value of @var{data}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_int_grow (struct obstack *@var{obstack-ptr}, int @var{data})
+A single value of type @code{int} can be added by using the
+@code{obstack_int_grow} function. It adds @code{sizeof (int)} bytes to
+the growing object and initializes them with the value of @var{data}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
@deftypefun {void *} obstack_finish (struct obstack *@var{obstack-ptr})
When you are finished growing the object, use the function
@code{obstack_finish} to close it off and return its final address.
@@ -1173,6 +1189,22 @@ character @var{c} to the growing object in obstack @var{obstack-ptr}.
@comment obstack.h
@comment GNU
+@deftypefun void obstack_ptr_grow_fast (struct obstack *@var{obstack-ptr}, void *@var{data})
+The function @code{obstack_ptr_grow_fast} adds @code{sizeof (void *)}
+bytes containing the value of @var{data} to the growing object in
+obstack @var{obstack-ptr}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_int_grow_fast (struct obstack *@var{obstack-ptr}, int @var{data})
+The function @code{obstack_int_grow_fast} adds @code{sizeof (int)} bytes
+containing the value of @var{data} to the growing object in obstack
+@var{obstack-ptr}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
@deftypefun void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size})
The function @code{obstack_blank_fast} adds @var{size} bytes to the
growing object in obstack @var{obstack-ptr} without initializing them.
diff --git a/manual/nss.texi b/manual/nss.texi
index 6d9d831a18..6773fc4f16 100644
--- a/manual/nss.texi
+++ b/manual/nss.texi
@@ -3,6 +3,9 @@
@node Name Service Switch
@chapter System Databases and Name Service Switch
+@cindex Name Service Switch
+@cindex NSS
+@cindex databses
Various functions in the C Library need to be configured to work
correctly in the local environment. Traditionally, this was done by
using files (e.g., @file{/etc/passwd}), but other nameservices (line the
@@ -395,10 +398,10 @@ change of the return value. While the user-level function returns a
pointer to the result the reentrant function return an @code{enum
nss_status} value:
-@cindex NSS_STATUS_TRYAGAIN
-@cindex NSS_STATUS_UNAVAIL
-@cindex NSS_STATUS_NOTFOUND
-@cindex NSS_STATUS_SUCCESS
+@vindex NSS_STATUS_TRYAGAIN
+@vindex NSS_STATUS_UNAVAIL
+@vindex NSS_STATUS_NOTFOUND
+@vindex NSS_STATUS_SUCCESS
@ftable @code
@item NSS_STATUS_TRYAGAIN
numeric value @code{-2}
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 5ebc5c1781..c666f5e7db 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2438,6 +2438,17 @@ Specifies that the argument is of type @code{double *}.
Specifies that the argument is of type @code{long double *}.
@end table
+For all the above number parsing formats there is an additional optional
+flag @samp{'}. When this flag is given the @code{scanf} function
+expects the number represented in the input string to be formatted
+according to the grouping rules of the currently selected locale
+(@pxref{General Numeric}).
+
+If the @code{"C"} or @code{"POSIX"} locale is selected there is no
+difference. But for a locale which specifies values for the appropriate
+fields in the locale the input must have the correct form in the input.
+Otherwise the longest prefix with a correct form is processed.
+
@node String Input Conversions
@subsection String Input Conversions
diff --git a/manual/time.texi b/manual/time.texi
index 18224a5520..6bbb15e4d6 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1024,7 +1024,7 @@ community of volunteers and put in the public domain.
@comment time.h
@comment POSIX.1
-@deftypevar char * tzname [2]
+@deftypevar {char *} tzname [2]
The array @code{tzname} contains two strings, which are the standard
names of the pair of time zones (standard and daylight
saving) that the user has selected. @code{tzname[0]} is the name of
diff --git a/manual/users.texi b/manual/users.texi
index e20c90ddaa..ce6d526b4a 100644
--- a/manual/users.texi
+++ b/manual/users.texi
@@ -685,6 +685,9 @@ at least @code{L_cuserid} characters; the string is returned in this
array. Otherwise, a pointer to a string in a static area is returned.
This string is statically allocated and might be overwritten on
subsequent calls to this function or to @code{getlogin}.
+
+The use of this function is deprecated since it is marked to be
+withdrawn in XPG4.2 and it is already removed in POSIX.1.
@end deftypefun
@comment stdio.h
@@ -1158,7 +1161,7 @@ This function closes the internal stream used by @code{getgrent} or
@node Netgroup Data, Lookup Netgroup, Netgroup Database, Netgroup Database
@subsection Netgroup Data
-@cindex{Netgroup}
+@cindex Netgroup
Sometimes it is useful group users according to other criterias like the
ones used in the @xref{Group Database}. E.g., it is useful to associate
a certain group of users with a certain machine. On the other hand
diff --git a/math/mathcalls.h b/math/mathcalls.h
index 656352ec2c..13c33e8ebe 100644
--- a/math/mathcalls.h
+++ b/math/mathcalls.h
@@ -1,21 +1,21 @@
/* Prototype declarations for math functions; helper file for <math.h>.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/* NOTE: Because of the special way this file is used by <math.h>, this
file must NOT be protected from multiple inclusion as header files
@@ -73,7 +73,7 @@ __MATHCALL (sinh,, (_Mdouble_ __x));
/* Hyperbolic tangent of X. */
__MATHCALL (tanh,, (_Mdouble_ __x));
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
/* Hyperbolic arc cosine of X. */
__MATHCALL (acosh,, (_Mdouble_ __x));
/* Hyperbolic arc sine of X. */
@@ -99,12 +99,15 @@ __MATHCALL (log,, (_Mdouble_ __x));
/* Base-ten logarithm of X. */
__MATHCALL (log10,, (_Mdouble_ __x));
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
/* Return exp(X) - 1. */
__MATHCALL (expm1,, (_Mdouble_ __x));
/* Return log(1 + X). */
__MATHCALL (log1p,, (_Mdouble_ __x));
+
+/* Return the base 2 signed integral exponent of X. */
+__MATHCALL (logb,, (_Mdouble_ __x));
#endif
/* Break VALUE into integral and fractional parts. */
@@ -119,7 +122,7 @@ __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
/* Return the square root of X. */
__MATHCALL (sqrt,, (_Mdouble_ __x));
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
/* Return the cube root of X. */
__MATHCALL (cbrt,, (_Mdouble_ __x));
#endif
@@ -146,9 +149,6 @@ __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
is +Infinity, -1 if it is -Infinity. */
__MATHDECL (int, isinf,, (_Mdouble_ __value));
-/* Return nonzero if VALUE is not a number. */
-__MATHDECL (int, isnan,, (_Mdouble_ __value));
-
/* Return nonzero if VALUE is finite and not NaN. */
__MATHDECL (int, finite,, (_Mdouble_ __value));
@@ -164,24 +164,11 @@ __MATHCALL (infnan,, (int __error));
__MATHCALL (copysign,, (_Mdouble_ __x, _Mdouble_ __y));
/* Return X times (2 to the Nth power). */
-__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
-
-/* Return X times (2 to the Nth power). */
__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
/* Return the remainder of X/Y. */
__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
-/* Return the base 2 signed integral exponent of X. */
-__MATHCALL (logb,, (_Mdouble_ __x));
-
-/* Return the integer nearest X in the direction of the
- prevailing rounding mode. */
-__MATHCALL (rint,, (_Mdouble_ __x));
-
-/* Return `sqrt(X*X + Y*Y)'. */
-__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
-
struct __MATH_PRECNAME(__cabs_complex,)
{
_Mdouble_ x, y;
@@ -191,18 +178,21 @@ struct __MATH_PRECNAME(__cabs_complex,)
__MATHCALL (cabs,, (struct __MATH_PRECNAME(__cabs_complex,)));
-/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
-__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
+/* Return the fractional part of X after dividing out `ilogb (X)'. */
+__MATHCALL (significand,, (_Mdouble_ __x));
+#endif /* Use misc. */
-/* Return the remainder of integer divison X / Y with infinite precision. */
-__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+
+#if defined(__USE_MISC) || defined(__USE_XOPEN)
+
+/* Return nonzero if VALUE is not a number. */
+__MATHDECL (int, isnan,, (_Mdouble_ __value));
/* Return the binary exponent of X, which must be nonzero. */
__MATHDECL (int, ilogb,, (_Mdouble_ __x));
-/* Return the fractional part of X after dividing out `ilogb (X)'. */
-__MATHCALL (significand,, (_Mdouble_ __x));
-
+/* Return `sqrt(X*X + Y*Y)'. */
+__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
/* Error, gamma, and Bessel functions. */
@@ -229,4 +219,21 @@ __MATHCALL (gamma,_r, (_Mdouble_, int *));
__MATHCALL (lgamma,_r, (_Mdouble_, int *));
#endif
+
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
+
+/* Return the integer nearest X in the direction of the
+ prevailing rounding mode. */
+__MATHCALL (rint,, (_Mdouble_ __x));
+
+/* Return X times (2 to the Nth power). */
+__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+
+/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
+__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
+
+/* Return the remainder of integer divison X / Y with infinite precision. */
+__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+#endif
+
#endif /* Use misc. */
diff --git a/misc/Makefile b/misc/Makefile
index 43b6bbda43..46b078c081 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -24,7 +24,7 @@ subdir := misc
headers := sys/uio.h iovec.h sys/ioctl.h ioctls.h ioctl-types.h \
sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \
- ar.h a.out.h stab.h stab.def sgtty.h \
+ ar.h a.out.h libgen.h stab.h stab.def sgtty.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 \
@@ -55,7 +55,7 @@ routines := brk sbrk sstk ioctl \
efgcvt efgcvt_r qefgcvt qefgcvt_r \
hsearch hsearch_r tsearch lsearch \
err error ustat \
- getsysstats
+ getsysstats dirname
aux := init-misc
distribute := bsd-compat.c
extra-objs := bsd-compat.o
@@ -63,6 +63,7 @@ install-lib := libbsd-compat.a libg.a
non-lib.a := libbsd-compat.a
gpl2lgpl := error.c error.h
+tests := tst-dirname
include ../Rules
diff --git a/misc/dirname.c b/misc/dirname.c
new file mode 100644
index 0000000000..26c5a8b1ee
--- /dev/null
+++ b/misc/dirname.c
@@ -0,0 +1,52 @@
+/* dirname - return directory part of PATH.
+ 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 <libgen.h>
+#include <string.h>
+
+
+char *
+dirname (char *path)
+{
+ static const char dot[] = ".";
+ char *last_slash;
+
+ /* Find last '/'. */
+ last_slash = path != NULL ? strrchr (path, '/') : NULL;
+
+ if (last_slash == path)
+ /* The last slash is the first character in the string. We have to
+ return "/". */
+ ++last_slash;
+ else if (last_slash != NULL && last_slash[1] == '\0')
+ /* The '/' is the last character, we have to look further. */
+ last_slash = memchr (path, last_slash - path, '/');
+
+ if (last_slash != NULL)
+ /* Terminate the path. */
+ last_slash[0] = '\0';
+ else
+ /* This assignment is ill-designed but the XPG specs require to
+ return a string containing "." in any case no directory part is
+ found and so a static and constant string is required. */
+ path = (char *) dot;
+
+ return path;
+}
diff --git a/misc/hsearch.c b/misc/hsearch.c
index e0b2e3e0ff..f2739b8801 100644
--- a/misc/hsearch.c
+++ b/misc/hsearch.c
@@ -1,21 +1,21 @@
/* 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.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+ 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 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.
+ 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. */
+ 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 <search.h>
@@ -39,7 +39,7 @@ hsearch (item, action)
int
hcreate (nel)
- unsigned int nel;
+ size_t nel;
{
return hcreate_r (nel, &htab);
}
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index d0fb3e183f..bf7cadc536 100644
--- a/misc/hsearch_r.c
+++ b/misc/hsearch_r.c
@@ -1,21 +1,21 @@
/* 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.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+ 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 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.
+ 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. */
+ 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 <malloc.h>
@@ -64,7 +64,7 @@ isprime (unsigned int number)
becomes zero. */
int
hcreate_r (nel, htab)
- unsigned int nel;
+ size_t nel;
struct hsearch_data *htab;
{
/* Test for correct arguments. */
diff --git a/misc/insremque.c b/misc/insremque.c
index 2658397294..d71ed04265 100644
--- a/misc/insremque.c
+++ b/misc/insremque.c
@@ -1,49 +1,46 @@
-/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992, 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 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.
+ 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. */
+ 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 <ansidecl.h>
#include <stddef.h>
#include <search.h>
/* Insert ELEM into a doubly-linked list, after PREV. */
void
-DEFUN(insque, (elem, prev) ,
- struct qelem *elem AND struct qelem *prev)
+insque (void *elem, void *prev)
{
- struct qelem *next = prev->q_forw;
- prev->q_forw = elem;
+ struct qelem *next = ((struct qelem *) prev)->q_forw;
+ ((struct qelem *) prev)->q_forw = (struct qelem *) elem;
if (next != NULL)
- next->q_back = elem;
- elem->q_forw = next;
- elem->q_back = prev;
+ next->q_back = (struct qelem *) elem;
+ ((struct qelem *) elem)->q_forw = next;
+ ((struct qelem *) elem)->q_back = (struct qelem *) prev;
}
/* Unlink ELEM from the doubly-linked list that it is in. */
void
-DEFUN(remque, (elem),
- struct qelem *elem)
+remque (void *elem)
{
- struct qelem *next = elem->q_forw;
- struct qelem *prev = elem->q_back;
+ struct qelem *next = ((struct qelem *) elem)->q_forw;
+ struct qelem *prev = ((struct qelem *) elem)->q_back;
if (next != NULL)
next->q_back = prev;
if (prev != NULL)
- prev->q_forw = next;
+ prev->q_forw = (struct qelem *) next;
}
diff --git a/misc/libgen.h b/misc/libgen.h
new file mode 100644
index 0000000000..be8258e72a
--- /dev/null
+++ b/misc/libgen.h
@@ -0,0 +1,30 @@
+/* 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 _LIBGEN_H
+
+#define _LIBGEN_H 1
+#include <sys/cdefs.h>
+
+/* Return directory part of PATH or "." if none is available. */
+extern char *dirname __P ((char *__path));
+
+/* Return filename part of PATH. */
+extern char *basename __P ((__const char *__path));
+
+#endif /* libgen.h */
diff --git a/misc/search.h b/misc/search.h
index 158332cd61..2103d66cbe 100644
--- a/misc/search.h
+++ b/misc/search.h
@@ -1,21 +1,21 @@
/* search.h -- declarations for System V style searching functions.
-Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 _SEARCH_H
#define _SEARCH_H 1
@@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA. */
__BEGIN_DECLS
+#if defined(__USE_SVID) || defined(__USE_XOPEN_EXTENDED)
/* Prototype structure for a linked-list data structure.
This is the type used by the `insque' and `remque' functions. */
@@ -40,10 +41,11 @@ struct qelem
/* Insert ELEM into a doubly-linked list, after PREV. */
-extern void insque __P ((struct qelem *__elem, struct qelem *__prev));
+extern void insque __P ((void *__elem, void *__prev));
/* Unlink ELEM from the doubly-linked list that it is in. */
-extern void remque __P ((struct qelem *__elem));
+extern void remque __P ((void *__elem));
+#endif
/* For use with hsearch(3). */
@@ -81,7 +83,7 @@ struct hsearch_data
/* Family of hash table handling functions. The functions also have
reentrant counterparts ending with _r. */
extern ENTRY *hsearch __P ((ENTRY __item, ACTION __action));
-extern int hcreate __P ((unsigned int __nel));
+extern int hcreate __P ((size_t __nel));
extern void hdestroy __P ((void));
extern int hsearch_r __P ((ENTRY __item, ACTION __action, ENTRY **__retval,
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 42c3e3e363..6a7e0213fb 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -1,21 +1,21 @@
/* `fd_set' type and related macros, and `select'/`pselect' declarations.
-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. */
+ 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. */
/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
diff --git a/misc/sys/uio.h b/misc/sys/uio.h
index 8a577bdb75..0127efba14 100644
--- a/misc/sys/uio.h
+++ b/misc/sys/uio.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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_UIO_H
@@ -23,8 +23,7 @@ Cambridge, MA 02139, USA. */
__BEGIN_DECLS
-#define __need_size_t
-#include <stddef.h>
+#include <sys/types.h>
/* This file defines `struct iovec'. */
#include <iovec.h>
@@ -35,14 +34,16 @@ __BEGIN_DECLS
The buffers are filled in the order specified.
Operates just like `read' (see <unistd.h>) except that data are
put in VECTOR instead of a contiguous buffer. */
-int readv __P ((int __fd, __const struct iovec * __vector, size_t __count));
+extern ssize_t readv __P ((int __fd, __const struct iovec * __vector,
+ int __count));
/* Write data pointed by the buffers described by VECTOR, which
is a vector of COUNT `struct iovec's, to file descriptor FD.
The data is written in the order specified.
Operates just like `write' (see <unistd.h>) except that the data
are taken from VECTOR instead of a contiguous buffer. */
-int writev __P ((int __fd, __const struct iovec * __vector, size_t __count));
+extern ssize_t writev __P ((int __fd, __const struct iovec * __vector,
+ int __count));
__END_DECLS
diff --git a/misc/tst-dirname.c b/misc/tst-dirname.c
new file mode 100644
index 0000000000..78eb1b5db0
--- /dev/null
+++ b/misc/tst-dirname.c
@@ -0,0 +1,59 @@
+/* Test program for dirname function a la XPG.
+ 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. */
+
+#define _GNU_SOURCE 1
+#include <libgen.h>
+#include <stdio.h>
+#include <string.h>
+
+
+extern int test __P ((const char *input, const char *result));
+
+int
+test (input, result)
+ const char *input;
+ const char *result;
+{
+ int retval;
+ char *cp;
+ cp = strdupa (input);
+ cp = dirname (cp);
+ retval = strcmp (cp, result);
+ if (retval)
+ printf ("dirname(\"%s\") should be \"%s\", but is \"%s\"\n",
+ input, result, cp);
+ return retval;
+}
+
+int
+main ()
+{
+ int result = 0;
+
+ /* These are the examples given in XPG4.2. */
+ result |= test ("/usr/lib", "/usr");
+ result |= test ("/usr", "/");
+ result |= test ("usr", ".");
+ result |= test ("/", "/");
+ result |= test (".", ".");
+ result |= test ("..", ".");
+
+ return result != 0;
+}
diff --git a/posix/Makefile b/posix/Makefile
index b9cd739325..a2b7e57cda 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -25,7 +25,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
glob.h regex.h wordexp.h fnmatch.h gnu/types.h getopt.h \
posix1_lim.h posix2_lim.h posix_opt.h local_lim.h tar.h \
utsnamelen.h confname.h waitflags.h waitstatus.h sys/unistd.h \
- sched.h schedbits.h
+ sched.h schedbits.h re_comp.h
distribute := confstr.h
diff --git a/posix/getconf.c b/posix/getconf.c
index 5a7b9b1de0..f4f47650b7 100644
--- a/posix/getconf.c
+++ b/posix/getconf.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <unistd.h>
#include <errno.h>
@@ -34,97 +34,159 @@ struct conf
static struct conf vars[] =
{
{ "LINK_MAX", _PC_LINK_MAX, PATHCONF },
+ { "_POSIX_LINK_MAX", _PC_LINK_MAX, PATHCONF },
{ "MAX_CANON", _PC_MAX_CANON, PATHCONF },
+ { "_POSIX_MAX_CANON", _PC_MAX_CANON, PATHCONF },
{ "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
+ { "_POSIX_MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
{ "NAME_MAX", _PC_NAME_MAX, PATHCONF },
+ { "_POSIX_NAME_MAX", _PC_NAME_MAX, PATHCONF },
{ "PATH_MAX", _PC_PATH_MAX, PATHCONF },
+ { "_POSIX_PATH_MAX", _PC_PATH_MAX, PATHCONF },
{ "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
+ { "_POSIX_PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
{ "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF },
+ { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
{ "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
{ "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
- { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
- { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
- { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
{ "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF },
+ { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
+ { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
{ "ARG_MAX", _SC_ARG_MAX, SYSCONF },
+ { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF },
+ { "CHAR_BIT", _SC_CHAR_BIT, SYSCONF },
+ { "CHAR_MAX", _SC_CHAR_MAX, SYSCONF },
+ { "CHAR_MIN", _SC_CHAR_MIN, SYSCONF },
{ "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
{ "CLK_TCK", _SC_CLK_TCK, SYSCONF },
+ { "INT_MAX", _SC_INT_MAX, SYSCONF },
+ { "INT_MIN", _SC_INT_MIN, SYSCONF },
+ { "IOV_MAX", _SC_UIO_MAXIOV, SYSCONF },
+ { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
+ { "LONG_BIT", _SC_LONG_BIT, SYSCONF },
+ { "MB_LEN_MAX", _SC_MB_LEN_MAX, SYSCONF },
{ "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+ { "NL_ARGMAX", _SC_NL_ARGMAX, SYSCONF },
+ { "NL_LANGMAX", _SC_NL_LANGMAX, SYSCONF },
+ { "NL_MSGMAX", _SC_NL_MSGMAX, SYSCONF },
+ { "NL_NMAX", _SC_NL_NMAX, SYSCONF },
+ { "NL_SETMAX", _SC_NL_SETMAX, SYSCONF },
+ { "NL_TEXTMAX", _SC_NL_TEXTMAX, SYSCONF },
+ { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
+ { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
+ { "NZERO", _SC_NZERO, SYSCONF },
{ "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
- { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
- { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
- { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
- { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
- { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
+ { "PAGESIZE", _SC_PAGESIZE, SYSCONF },
+ { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF },
+ { "PASS_MAX", _SC_PASS_MAX, SYSCONF },
+ { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
+ { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
+ { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
+ { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
+ { "SCHAR_MAX", _SC_SCHAR_MAX, SYSCONF },
+ { "SCHAR_MIN", _SC_SCHAR_MIN, SYSCONF },
+ { "SHRT_MAX", _SC_SHRT_MAX, SYSCONF },
+ { "SHRT_MIN", _SC_SHRT_MIN, SYSCONF },
+ { "SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+ { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
+ { "TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+ { "UCHAR_MAX", _SC_UCHAR_MAX, SYSCONF },
+ { "UINT_MAX", _SC_UINT_MAX, SYSCONF },
+ { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
+ { "ULONG_MAX", _SC_ULONG_MAX, SYSCONF },
+ { "USHRT_MAX", _SC_USHRT_MAX, SYSCONF },
+ { "WORD_BIT", _SC_WORD_BIT, SYSCONF },
+ { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF },
+ { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF },
+ { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF },
+ { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF },
+ { "_POSIX_ARG_MAX", _SC_ARG_MAX, SYSCONF },
{ "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO, SYSCONF },
- { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
- { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
+ { "_POSIX_CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
{ "_POSIX_FSYNC", _SC_FSYNC, SYSCONF },
+ { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
{ "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES, SYSCONF },
{ "_POSIX_MEMLOCK", _SC_MEMLOCK, SYSCONF },
{ "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE, SYSCONF },
{ "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION, SYSCONF },
{ "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING, SYSCONF },
- { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
- { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
- { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
+ { "_POSIX_NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+ { "_POSIX_OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
{ "_POSIX_PII", _SC_PII, SYSCONF },
- { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
- { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
{ "_POSIX_PII_INTERNET", _SC_PII_INTERNET, SYSCONF },
- { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
- { "_POSIX_POLL", _SC_POLL, SYSCONF },
- { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
- { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
- { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
{ "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM, SYSCONF },
- { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
+ { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
+ { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
{ "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF },
+ { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
{ "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF },
- { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
+ { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
+ { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
+ { "_POSIX_POLL", _SC_POLL, SYSCONF },
+ { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
+ { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
+ { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
+ { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
+ { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
+ { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
+ { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
+ { "_POSIX_SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+ { "_POSIX_STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
+ { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
{ "_POSIX_THREADS", _SC_THREADS, SYSCONF },
- { "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
- { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
- { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
- { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
- { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
- { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
- { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
- { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
- { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
{ "_POSIX_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR, SYSCONF },
{ "_POSIX_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE, SYSCONF },
{ "_POSIX_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING, SYSCONF },
{ "_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_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
+ { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
+ { "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+ { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
+ { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
+ { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF },
+ { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF },
+ { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF },
+ { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF },
+ { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF },
+ { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF },
+ { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF },
+ { "_XOPEN_XPG3", _SC_XOPEN_XPG3, SYSCONF },
+ { "_XOPEN_XPG4", _SC_XOPEN_XPG4, SYSCONF },
/* POSIX.2 */
{ "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
{ "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
{ "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
{ "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+ { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX },
{ "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
{ "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF },
{ "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
{ "LINE_MAX", _SC_LINE_MAX, SYSCONF },
- { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
- { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX },
+ { "POSIX2_BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
+ { "POSIX2_BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
+ { "POSIX2_BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
+ { "POSIX2_BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+ { "POSIX2_CHAR_TERM", _SC_2_CHAR_TERM, SYSCONF },
+ { "POSIX2_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
{ "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF },
{ "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF },
+ { "POSIX2_C_VERSION", _SC_2_C_VERSION, SYSCONF },
+ { "POSIX2_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
{ "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF },
{ "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF },
+ { "POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
{ "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF },
+ { "POSIX2_RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
{ "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF },
+ { "POSIX2_UPE", _SC_2_UPE, SYSCONF },
+ { "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
+ { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
{ "PATH", _CS_PATH, CONFSTR },
+ { "CS_PATH", _CS_PATH, CONFSTR },
{ NULL, 0, SYSCONF }
};
diff --git a/posix/posix1_lim.h b/posix/posix1_lim.h
index 445907ccec..82af9635ac 100644
--- a/posix/posix1_lim.h
+++ b/posix/posix1_lim.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 2.9.2 Minimum Values Added to <limits.h>
@@ -31,7 +31,7 @@ Cambridge, MA 02139, USA. */
#define _POSIX_ARG_MAX 4096
/* Maximum simultaneous processes per real user ID. */
-#define _POSIX_CHILD_MAX 6
+#define _POSIX_CHILD_MAX 25
/* Maximum link count of a file. */
#define _POSIX_LINK_MAX 8
@@ -47,7 +47,7 @@ Cambridge, MA 02139, USA. */
#define _POSIX_NGROUPS_MAX 0
/* Number of files one process can have open at once. */
-#define _POSIX_OPEN_MAX 16
+#define _POSIX_OPEN_MAX 20
/* Number of descriptors that a process may examine with `pselect' or
`select'. */
diff --git a/posix/re_comp.h b/posix/re_comp.h
new file mode 100644
index 0000000000..a25fa5cb71
--- /dev/null
+++ b/posix/re_comp.h
@@ -0,0 +1,26 @@
+/* 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 _RE_COMP_H
+#define _RE_COMP_H 1
+
+/* This is only a wrapper around the <regex.h> file. XPG4.2 mentions
+ this name. */
+#include <regex.h>
+
+#endif /* re_comp.h */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index dd6183cc92..a13b825638 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h>
@@ -123,7 +123,8 @@ extern __pid_t __waitpid __P ((__pid_t __pid, int *__stat_loc,
int __options));
extern __pid_t waitpid __P ((__pid_t __pid, int *__stat_loc,
int __options));
-#ifdef __USE_BSD
+
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* This being here makes the prototypes valid whether or not
we have already included <sys/resource.h> to define `struct rusage'. */
struct rusage;
@@ -137,6 +138,12 @@ extern __pid_t __wait3 __P ((__WAIT_STATUS __stat_loc,
int __options, struct rusage * __usage));
extern __pid_t wait3 __P ((__WAIT_STATUS __stat_loc,
int __options, struct rusage * __usage));
+#endif
+
+#ifdef __USE_BSD
+/* This being here makes the prototypes valid whether or not
+ we have already included <sys/resource.h> to define `struct rusage'. */
+struct rusage;
/* PID is like waitpid. Other args are like wait3. */
extern __pid_t __wait4 __P ((__pid_t __pid, __WAIT_STATUS __stat_loc,
diff --git a/posix/unistd.h b/posix/unistd.h
index e9754e1208..2b967bf706 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 2.10 Symbolic Constants <unistd.h>
@@ -28,7 +28,7 @@ Cambridge, MA 02139, USA. */
__BEGIN_DECLS
/* These may be used to determine what facilities are present at compile time.
- Their values can be obtained at run time from sysconf. */
+ Their values can be obtained at run time from `sysconf'. */
/* POSIX Standard approved as IEEE Std 1003.1 as of August, 1988 and
extended by P1003.1b (aka POSIX.4). */
@@ -58,6 +58,24 @@ __BEGIN_DECLS
/* Library is conformant to X/Open version 4. */
#define _XOPEN_VERSION 4
+/* Commands and utilities from XPG4 are available. */
+#define _XOPEN_XCU_VERSION 4
+
+/* We are compatible with the old published standards as well. */
+#define _XOPEN_XPG2 1
+#define _XOPEN_XPG3 1
+#define _XOPEN_XPG4 1
+
+/* The X/Open Unix extensions are available. */
+#define _XOPEN_UNIX 1
+
+/* Encryption is present. */
+#define _XOPEN_CRYPT 1
+
+/* The enchanced internationalization capabilities accoring to XPG4.2
+ are present. */
+#define _XOPEN_ENH_I18N 1
+
/* Get values of POSIX options:
@@ -94,6 +112,8 @@ __BEGIN_DECLS
_POSIX_POLL Implementation supports `poll' function.
_POSIX_SELECT Implementation supports `select' and `pselect'.
+ _XOPEN_SHM Shared memory interface according to XPG4.2.
+
If any of these symbols is defined as -1, the corresponding option is not
true for any file. If any is defined as other than -1, the corresponding
option is true for all files. If a symbol is not defined at all, the value
@@ -217,7 +237,14 @@ extern unsigned int alarm __P ((unsigned int __seconds));
error, but if `sleep' returns SECONDS, it probably didn't work. */
extern unsigned int sleep __P ((unsigned int __seconds));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
+/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
+ microseconds. If INTERVAL is nonzero, when the alarm goes off, the
+ timer is reset to go off every INTERVAL microseconds thereafter.
+ Returns the number of microseconds remaining before the alarm. */
+extern unsigned int ualarm __P ((unsigned int __value,
+ unsigned int __interval));
+
/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
or ignored. Return value is not necessarily useful. */
extern unsigned int usleep __P ((unsigned int __useconds));
@@ -235,19 +262,28 @@ extern int __chown __P ((__const char *__file,
extern int chown __P ((__const char *__file,
__uid_t __owner, __gid_t __group));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Change the owner and group of the file that FD is open on. */
extern int __fchown __P ((int __fd,
__uid_t __owner, __gid_t __group));
extern int fchown __P ((int __fd,
__uid_t __owner, __gid_t __group));
-#endif /* Use BSD. */
+
+
+/* Change owner and group of FILE, if it is a symbolic
+ link the ownership of the symbolic link is changed. */
+extern int __lchown __P ((__const char *__file, __uid_t __owner,
+ __gid_t __group));
+extern int lchown __P ((__const char *__file, __uid_t __owner,
+ __gid_t __group));
+
+#endif /* Use BSD || X/Open Unix. */
/* Change the process's working directory to PATH. */
extern int __chdir __P ((__const char *__path));
extern int chdir __P ((__const char *__path));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Change the process's working directory to the one FD is open on. */
extern int fchdir __P ((int __fd));
#endif
@@ -279,7 +315,7 @@ char *__canonicalize_directory_name_internal __P ((__const char *__thisdir,
size_t __size));
#endif
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Put the absolute pathname of the current working directory in BUF.
If successful, return BUF. If not, put an error message in
BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
@@ -337,7 +373,7 @@ extern int execvp __P ((__const char *__file, char *__const __argv[]));
extern int execlp __P ((__const char *__file, __const char *__arg, ...));
-#ifdef __USE_MISC
+#if defined(__USE_MISC) || defined(__USE_XOPEN)
/* Add INC to priority of the current process. */
extern int nice __P ((int __inc));
#endif
@@ -388,11 +424,11 @@ extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
/* Get the process group ID of process PID. */
extern __pid_t __getpgid __P ((__pid_t __pid));
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN_EXTENDED
extern __pid_t getpgid __P ((__pid_t __pid));
#endif
-#if defined (__USE_SVID) || defined (__USE_BSD)
+#if defined(__USE_SVID) || defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Both System V and BSD have `setpgrp' functions, but with different
calling conventions. The BSD function is the same as POSIX.1 `setpgid'
(above). The System V function takes no arguments and puts the calling
@@ -423,7 +459,7 @@ extern int setpgrp __P ((__pid_t __pid, __pid_t __pgrp));
extern __pid_t __setsid __P ((void));
extern __pid_t setsid __P ((void));
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN_EXTENDED
/* Return the session ID of the given process. */
extern __pid_t getsid __P ((__pid_t __pid));
#endif
@@ -463,12 +499,14 @@ extern int group_member __P ((__gid_t __gid));
extern int __setuid __P ((__uid_t __uid));
extern int setuid __P ((__uid_t __uid));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Set the real user ID of the calling process to RUID,
and the effective user ID of the calling process to EUID. */
extern int __setreuid __P ((__uid_t __ruid, __uid_t __euid));
extern int setreuid __P ((__uid_t __ruid, __uid_t __euid));
+#endif
+#ifdef __USE_BSD
/* Set the effective user ID of the calling process to UID. */
extern int seteuid __P ((__uid_t __uid));
#endif /* Use BSD. */
@@ -480,12 +518,14 @@ extern int seteuid __P ((__uid_t __uid));
extern int __setgid __P ((__gid_t __gid));
extern int setgid __P ((__gid_t __gid));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Set the real group ID of the calling process to RGID,
and the effective group ID of the calling process to EGID. */
extern int __setregid __P ((__gid_t __rgid, __gid_t __egid));
extern int setregid __P ((__gid_t __rgid, __gid_t __egid));
+#endif
+#ifdef __USE_BSD
/* Set the effective group ID of the calling process to GID. */
extern int setegid __P ((__gid_t __gid));
#endif /* Use BSD. */
@@ -497,7 +537,7 @@ extern int setegid __P ((__gid_t __gid));
extern __pid_t __fork __P ((void));
extern __pid_t fork __P ((void));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Clone the calling process, but without copying the whole address space.
The the calling process is suspended until the the new process exits or is
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
@@ -522,7 +562,7 @@ extern int ttyname_r __P ((int __fd, char *__buf, size_t __buflen));
extern int __isatty __P ((int __fd));
extern int isatty __P ((int __fd));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Return the index into the active-logins file (utmp) for
the controlling terminal. */
extern int ttyslot __P ((void));
@@ -533,7 +573,7 @@ extern int ttyslot __P ((void));
extern int __link __P ((__const char *__from, __const char *__to));
extern int link __P ((__const char *__from, __const char *__to));
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Make a symbolic link to FROM named TO. */
extern int __symlink __P ((__const char *__from, __const char *__to));
extern int symlink __P ((__const char *__from, __const char *__to));
@@ -611,7 +651,7 @@ extern char *optarg;
#endif
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined (__USE_XOPEN)
/* Put the name of the current host in no more than LEN bytes of NAME.
The result is null-terminated if LEN is large enough for the full
@@ -623,9 +663,6 @@ extern int gethostname __P ((char *__name, size_t __len));
This call is restricted to the super-user. */
extern int sethostname __P ((__const char *__name, size_t __len));
-/* Return the current machine's Internet number. */
-extern long int gethostid __P ((void));
-
/* Set the current machine's Internet number to ID.
This call is restricted to the super-user. */
extern int sethostid __P ((long int __id));
@@ -638,31 +675,9 @@ extern int getdomainname __P ((char *__name, size_t __len));
extern int setdomainname __P ((__const char *__name, size_t __len));
-/* Return the number of bytes in a page. This is the system's page size,
- which is not necessarily the same as the hardware page size. */
-extern size_t __getpagesize __P ((void));
-extern size_t getpagesize __P ((void));
-
-
-/* Return the maximum number of file descriptors
- the current process could possibly have. */
-extern int __getdtablesize __P ((void));
-extern int getdtablesize __P ((void));
-
-
-/* Truncate FILE to LENGTH bytes. */
-extern int truncate __P ((__const char *__file, __off_t __length));
-
-/* Truncate the file FD is open on to LENGTH bytes. */
-extern int ftruncate __P ((int __fd, __off_t __length));
-
-
/* Make all changes done to FD actually appear on disk. */
extern int fsync __P ((int __fd));
-/* Make all changes done to all files actually appear on disk. */
-extern int sync __P ((void));
-
/* Revoke access permissions to all processes currently communicating
with the control terminal, and then send a SIGHUP signal to the process
@@ -707,24 +722,40 @@ extern char *getpass __P ((__const char *__prompt));
redirects stdin, stdout, and stderr to /dev/null. */
extern int daemon __P ((int __nochdir, int __noclose));
-#endif /* Use BSD. */
+#endif /* Use BSD || X/Open. */
-#ifdef __USE_MISC
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
+
+/* Return the current machine's Internet number. */
+extern long int gethostid __P ((void));
-/* Generate a unique temporary file name from TEMPLATE.
- The last six characters of TEMPLATE must be "XXXXXX";
- they are replaced with a string that makes the file name unique.
- Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
-extern char *mktemp __P ((char *__template));
+/* Make all changes done to all files actually appear on disk. */
+extern int sync __P ((void));
-/* Generate a unique temporary file name from TEMPLATE.
- The last six characters of TEMPLATE must be "XXXXXX";
- they are replaced with a string that makes the filename unique.
- Returns a file descriptor open on the file for reading and writing,
- or -1 if it cannot create a uniquely-named file. */
-extern int mkstemp __P ((char *__template));
+/* Return the number of bytes in a page. This is the system's page size,
+ which is not necessarily the same as the hardware page size. */
+extern int __getpagesize __P ((void));
+extern int getpagesize __P ((void));
+
+
+/* Truncate FILE to LENGTH bytes. */
+extern int truncate __P ((__const char *__file, __off_t __length));
+
+/* Truncate the file FD is open on to LENGTH bytes. */
+extern int ftruncate __P ((int __fd, __off_t __length));
+
+
+/* Return the maximum number of file descriptors
+ the current process could possibly have. */
+extern int __getdtablesize __P ((void));
+extern int getdtablesize __P ((void));
+
+#endif /* Use BSD || X/Open Unix. */
+
+
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
/* Set the end of accessible data space (aka "the break") to ADDR.
Returns zero on success and -1 for errors (with errno set). */
@@ -740,8 +771,10 @@ extern int brk __P ((__ptr_t __addr));
returns (void *) -1 for errors (with errno set). */
extern __ptr_t __sbrk __P ((ptrdiff_t __delta));
extern __ptr_t sbrk __P ((ptrdiff_t __delta));
+#endif
+#ifdef __USE_MISC
/* Invoke `system call' number SYSNO, passing it the remaining arguments.
This is completely system-dependent, and not often useful.
@@ -757,7 +790,8 @@ extern long int syscall __P ((long int __sysno, ...));
#endif /* Use misc. */
-#if defined (__USE_MISC) && !defined (F_LOCK)
+#if (defined (__USE_MISC) || defined (__USE_XOPEN_EXTENDED)) \
+ && !defined (F_LOCK)
/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
files consistent. Some systems have them there and some here, and some
software depends on the macros being defined without including both. */
@@ -792,7 +826,6 @@ extern int lockf __P ((int __fd, int __cmd, __off_t __len));
differ from its real IDs, or it is otherwise indicated that extra
security should be used. When this is set the dynamic linker ignores
the various environment variables that normally affect it. */
-
extern int __libc_enable_secure;
#endif
@@ -803,6 +836,28 @@ extern int __libc_enable_secure;
extern int fdatasync __P ((int __fildes));
#endif /* Use POSIX */
+
+/* XPG4.2 specifies that prototypes for the encryption functions must
+ be defined here. */
+#ifdef __USE_XOPEN
+/* Encrypt at most 8 characters from KEY using salt to perturb DES. */
+extern char *crypt __P ((__const char *__key, __const char *__salt));
+
+/* Setup DES tables according KEY. */
+extern void setkey __P ((__const char *__key));
+
+/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
+ block in place. */
+extern void encrypt __P ((char *__block, int __edflag));
+
+
+/* Swab pairs bytes in the first N bytes of the area pointed to by
+ FROM and copy the result to TO. The value of TO must not be in the
+ range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
+ is without partner. */
+extern void swab __P ((__const char *__from, char *__to, ssize_t __n));
+#endif
+
__END_DECLS
#endif /* unistd.h */
diff --git a/pwd/pwd.h b/pwd/pwd.h
index f5b6ddb51e..3d6d2a1977 100644
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
* POSIX Standard: 9.2.2 User Database Access <pwd.h>
@@ -69,7 +69,7 @@ extern struct passwd *__pwdscan __P ((__ptr_t *__p,
#endif
-#if defined(__USE_SVID) || defined(__USE_MISC)
+#if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
/* Rewind the password-file stream. */
extern void setpwent __P ((void));
@@ -104,7 +104,7 @@ extern struct passwd *getpwnam __P ((__const char *__name));
PLEASE NOTE: these functions are not yet standardized. The interface
may change in later versions of this library. */
-#if defined(__USE_SVID) || defined(__USE_MISC)
+#if defined(__USE_SVID) || defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
extern int __getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
size_t __buflen, struct passwd **__result));
extern int getpwent_r __P ((struct passwd *__resultbuf, char *__buffer,
diff --git a/shadow/shadow.h b/shadow/shadow.h
index c65afc3efb..2a4749e592 100644
--- a/shadow/shadow.h
+++ b/shadow/shadow.h
@@ -1,20 +1,20 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/* Declaration of types and functions for shadow password suite. */
@@ -23,14 +23,15 @@ Boston, MA 02111-1307, USA. */
#define _SHADOW_H 1
#include <features.h>
+#include <paths.h>
+
#define __need_FILE
#include <stdio.h>
-
#define __need_size_t
#include <stddef.h>
-/* Paths to the userd files. */
-#define SHADOW "/etc/shadow"
+/* Paths to the user database files. */
+#define SHADOW _PATH_SHADOW
__BEGIN_DECLS
diff --git a/signal/signal.h b/signal/signal.h
index f7b2d131ad..c4cdbcae42 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -1,23 +1,23 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/*
- * ANSI Standard: 4.7 SIGNAL HANDLING <signal.h>
+ * ISO C Standard: 4.7 SIGNAL HANDLING <signal.h>
*/
#ifndef _SIGNAL_H
@@ -62,12 +62,12 @@ extern int __kill __P ((__pid_t __pid, int __sig));
extern int kill __P ((__pid_t __pid, int __sig));
#endif /* Use POSIX. */
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Send SIG to all processes in process group PGRP.
If PGRP is zero, send SIG to all processes in
the current process's process group. */
extern int killpg __P ((__pid_t __pgrp, int __sig));
-#endif /* Use BSD. */
+#endif /* Use BSD || X/Open Unix. */
/* Raise signal SIG, i.e., send SIG to yourself. */
extern int raise __P ((int __sig));
@@ -220,6 +220,18 @@ extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
struct sigvec *__ovec));
+/* Get machine-dependent `struct sigcontext' and signal subcodes. */
+#include <sigcontext.h>
+
+/* Restore the state saved in SCP. */
+extern int __sigreturn __P ((struct sigcontext *__scp));
+extern int sigreturn __P ((struct sigcontext *__scp));
+
+#endif /* signal.h included and use BSD. */
+
+
+#if defined(_SIGNAL_H) && (defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED))
+
/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
(causing them to fail with EINTR); if INTERRUPT is zero, make system
calls be restarted after signal SIG. */
@@ -249,14 +261,7 @@ struct sigaltstack
extern int sigaltstack __P ((__const struct sigaltstack *__ss,
struct sigaltstack *__oss));
-/* Get machine-dependent `struct sigcontext' and signal subcodes. */
-#include <sigcontext.h>
-
-/* Restore the state saved in SCP. */
-extern int __sigreturn __P ((struct sigcontext *__scp));
-extern int sigreturn __P ((struct sigcontext *__scp));
-
-#endif /* signal.h included and use BSD. */
+#endif /* signal.h included and use BSD or X/Open Unix. */
__END_DECLS
diff --git a/stdio-common/printf-parse.h b/stdio-common/printf-parse.h
index 9a5cfbac7e..86a9821b1f 100644
--- a/stdio-common/printf-parse.h
+++ b/stdio-common/printf-parse.h
@@ -1,21 +1,21 @@
/* Internal header for parsing printf format strings.
-Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of th GNU C Library.
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ This file is part of th 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 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.
+ 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. */
+ 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 <ctype.h>
#include <printf.h>
@@ -54,6 +54,7 @@ struct printf_spec
union printf_arg
{
unsigned char pa_char;
+ wchar_t pa_wchar;
short int pa_short_int;
int pa_int;
long int pa_long_int;
@@ -66,6 +67,7 @@ union printf_arg
double pa_double;
long double pa_long_double;
const char *pa_string;
+ const wchar_t *pa_wstring;
void *pa_pointer;
};
@@ -300,11 +302,7 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
}
/* Get the format specification. */
-#ifdef THIS_IS_INCOMPATIBLE_WITH_LINUX_LIBC
spec->info.spec = (wchar_t) *format++;
-#else
- spec->info.spec = (char) *format++;
-#endif
if (__printf_arginfo_table != NULL &&
__printf_arginfo_table[spec->info.spec] != NULL)
/* We don't try to get the types for all arguments if the format
@@ -346,9 +344,15 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
case L'c':
spec->data_arg_type = PA_CHAR;
break;
+ case L'C':
+ spec->data_arg_type = PA_WCHAR;
+ break;
case L's':
spec->data_arg_type = PA_STRING;
break;
+ case L'S':
+ spec->data_arg_type = PA_WSTRING;
+ break;
case L'p':
spec->data_arg_type = PA_POINTER;
break;
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index c84978cfc9..71e2d27058 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -105,7 +105,9 @@ enum
{ /* C type: */
PA_INT, /* int */
PA_CHAR, /* int, cast to char */
+ PA_WCHAR, /* wide char */
PA_STRING, /* const char *, a '\0'-terminated string */
+ PA_WSTRING, /* const wchar_t *, wide character string */
PA_POINTER, /* void * */
PA_FLOAT, /* float */
PA_DOUBLE, /* double */
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 50b4f02580..c2324d09a8 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <ctype.h>
#include <limits.h>
@@ -222,11 +222,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
/* '4' */ 8, /* '5' */ 8, /* '6' */ 8, /* '7' */ 8,
/* '8' */ 8, /* '9' */ 8, 0, 0,
0, 0, 0, 0,
- 0, 0, 0, 0,
+ 0, 0, 0, /* 'C' */ 25,
0, /* 'E' */ 19, 0, /* 'G' */ 19,
0, 0, 0, 0,
/* 'L' */ 12, 0, 0, 0,
- 0, 0, 0, 0,
+ 0, 0, 0, /* 'S' */ 21,
0, 0, 0, 0,
/* 'X' */ 18, 0, /* 'Z' */ 13, 0,
0, 0, 0, 0,
@@ -254,7 +254,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
#define STEP0_3_TABLE \
/* Step 0: at the beginning. */ \
- static const void *step0_jumps[25] = \
+ static const void *step0_jumps[26] = \
{ \
REF (form_unknown), \
REF (flag_space), /* for ' ' */ \
@@ -277,13 +277,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_hexa), /* for 'X', 'x' */ \
REF (form_float), /* for 'E', 'e', 'f', 'G', 'g' */ \
REF (form_character), /* for 'c' */ \
- REF (form_string), /* for 's' */ \
+ REF (form_string), /* for 's', 'S' */ \
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
- REF (form_strerror) /* for 'm' */ \
+ REF (form_strerror), /* for 'm' */ \
+ REF (form_wcharacter) /* for 'C' */ \
}; \
/* Step 1: after processing width. */ \
- static const void *step1_jumps[25] = \
+ static const void *step1_jumps[26] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -306,13 +307,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_hexa), /* for 'X', 'x' */ \
REF (form_float), /* for 'E', 'e', 'f', 'G', 'g' */ \
REF (form_character), /* for 'c' */ \
- REF (form_string), /* for 's' */ \
+ REF (form_string), /* for 's', 'S' */ \
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
- REF (form_strerror) /* for 'm' */ \
+ REF (form_strerror), /* for 'm' */ \
+ REF (form_wcharacter) /* for 'C' */ \
}; \
/* Step 2: after processing precision. */ \
- static const void *step2_jumps[25] = \
+ static const void *step2_jumps[26] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -335,13 +337,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_hexa), /* for 'X', 'x' */ \
REF (form_float), /* for 'E', 'e', 'f', 'G', 'g' */ \
REF (form_character), /* for 'c' */ \
- REF (form_string), /* for 's' */ \
+ REF (form_string), /* for 's', 'S' */ \
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
- REF (form_strerror) /* for 'm' */ \
+ REF (form_strerror), /* for 'm' */ \
+ REF (form_wcharacter) /* for 'C' */ \
}; \
/* Step 3: after processing first 'l' modifier. */ \
- static const void *step3_jumps[25] = \
+ static const void *step3_jumps[26] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -364,15 +367,16 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_hexa), /* for 'X', 'x' */ \
REF (form_float), /* for 'E', 'e', 'f', 'G', 'g' */ \
REF (form_character), /* for 'c' */ \
- REF (form_string), /* for 's' */ \
+ REF (form_string), /* for 's', 'S' */ \
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
- REF (form_strerror) /* for 'm' */ \
+ REF (form_strerror), /* for 'm' */ \
+ REF (form_wcharacter) /* for 'C' */ \
}
#define STEP4_TABLE \
/* Step 4: processing format specifier. */ \
- static const void *step4_jumps[25] = \
+ static const void *step4_jumps[26] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -395,10 +399,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_hexa), /* for 'X', 'x' */ \
REF (form_float), /* for 'E', 'e', 'f', 'G', 'g' */ \
REF (form_character), /* for 'c' */ \
- REF (form_string), /* for 's' */ \
+ REF (form_string), /* for 's', 'S' */ \
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
- REF (form_strerror) /* for 'm' */ \
+ REF (form_strerror), /* for 'm' */ \
+ REF (form_wcharacter) /* for 'C' */ \
}
@@ -683,17 +688,38 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
\
LABEL (form_character): \
/* Character. */ \
+ if (is_long) \
+ goto LABEL (form_wcharacter); \
--width; /* Account for the character itself. */ \
if (!left) \
PAD (' '); \
if (fspec == NULL) \
- outchar ((unsigned char) va_arg (ap, int)); /* Promoted. */ \
+ outchar ((unsigned char) va_arg (ap, int)); /* Promoted. */ \
else \
outchar ((unsigned char) args_value[fspec->data_arg].pa_char); \
if (left) \
PAD (' '); \
break; \
\
+ LABEL (form_wcharacter): \
+ { \
+ /* Wide character. */ \
+ char buf[MB_CUR_MAX]; \
+ mbstate_t mbstate; \
+ size_t len; \
+ \
+ len = __wcrtomb (buf, (fspec == NULL ? va_arg (ap, wint_t) \
+ : args_value[fspec->data_arg].pa_wchar), \
+ &mbstate); \
+ width -= len; \
+ if (!left) \
+ PAD (' '); \
+ outstring (buf, len); \
+ if (left) \
+ PAD (' '); \
+ } \
+ break; \
+ \
LABEL (form_string): \
{ \
size_t len; \
@@ -722,18 +748,12 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
len = 0; \
} \
} \
- else if (!is_long) \
+ else if (!is_long && spec != L_('S')) \
{ \
if (prec != -1) \
- { \
- /* Search for the end of the string, but don't search past \
- the length specified by the precision. */ \
- const char *end = memchr (string, '\0', prec); \
- if (end) \
- len = end - string; \
- else \
- len = prec; \
- } \
+ /* Search for the end of the string, but don't search past \
+ the length specified by the precision. */ \
+ len = strnlen (string, prec); \
else \
len = strlen (string); \
} \
@@ -1176,6 +1196,7 @@ do_positional:
break
T (PA_CHAR, pa_char, int); /* Promoted. */
+ T (PA_WCHAR, pa_wchar, wint_t);
T (PA_INT|PA_FLAG_SHORT, pa_short_int, int); /* Promoted. */
T (PA_INT, pa_int, int);
T (PA_INT|PA_FLAG_LONG, pa_long_int, long int);
@@ -1184,6 +1205,7 @@ do_positional:
T (PA_DOUBLE, pa_double, double);
T (PA_DOUBLE|PA_FLAG_LONG_DOUBLE, pa_long_double, long double);
T (PA_STRING, pa_string, const char *);
+ T (PA_WSTRING, pa_wstring, const wchar_t *);
T (PA_POINTER, pa_pointer, void *);
#undef T
default:
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 28f8ceb820..70d8bf0b18 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 "../locale/localeinfo.h"
#include <errno.h>
@@ -24,6 +24,7 @@ Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <wctype.h>
#include <libc-lock.h>
#ifdef __GNUC__
@@ -55,6 +56,12 @@ Cambridge, MA 02139, USA. */
# define va_list _IO_va_list
# define ungetc(c, s) (--read_in, _IO_ungetc (c, s))
# define inchar() ((c = _IO_getc_unlocked (s)), (void) ++read_in, c)
+# define encode_error() do { \
+ if (errp != NULL) *errp |= 4; \
+ _IO_funlockfile (s); \
+ __set_errno (EILSEQ); \
+ return done; \
+ } while (0)
# define conv_error() do { \
if (errp != NULL) *errp |= 2; \
_IO_funlockfile (s); \
@@ -88,6 +95,11 @@ Cambridge, MA 02139, USA. */
#else
# define ungetc(c, s) (--read_in, ungetc (c, s))
# define inchar() ((c = getc (s)), (void) ++read_in, c)
+# define encode_error() do { \
+ _IO_funlockfile (s); \
+ __set_errno (EILSEQ); \
+ return done; \
+ } while (0)
# define conv_error() do { \
funlockfile (s); \
return done; \
@@ -173,6 +185,7 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
} num;
/* Character-buffer pointer. */
char *str = NULL;
+ wchar_t *wstr = NULL;
char **strptr = NULL;
size_t strsize = 0;
/* We must not react on white spaces immediately because they can
@@ -435,40 +448,138 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
break;
case 'c': /* Match characters. */
- if (!(flags & SUPPRESS))
+ if ((flags & LONG) == 0)
{
- str = ARG (char *);
- if (str == NULL)
- conv_error ();
- }
+ if (!(flags & SUPPRESS))
+ {
+ str = ARG (char *);
+ if (str == NULL)
+ conv_error ();
+ }
- c = inchar ();
- if (c == EOF)
- input_error ();
+ c = inchar ();
+ if (c == EOF)
+ input_error ();
- if (width == -1)
- width = 1;
+ if (width == -1)
+ width = 1;
- if (!(flags & SUPPRESS))
- {
- do
- *str++ = c;
- while (--width > 0 && inchar () != EOF);
+ if (!(flags & SUPPRESS))
+ {
+ do
+ *str++ = c;
+ while (--width > 0 && inchar () != EOF);
+ }
+ else
+ while (--width > 0 && inchar () != EOF);
+
+ if (width > 0)
+ /* I.e., EOF was read. */
+ --read_in;
+
+ if (!(flags & SUPPRESS))
+ ++done;
+
+ break;
}
- else
- while (--width > 0 && inchar () != EOF);
+ /* FALLTHROUGH */
+ case 'C':
+ /* Get UTF-8 encoded wide character. Here we assume (as in
+ other parts of the libc) that we only have to handle
+ UTF-8. */
+ {
+ wint_t val;
+ size_t cnt = 0;
+ int first = 1;
- if (width > 0)
- /* I.e., EOF was read. */
- --read_in;
+ if (!(flags & SUPPRESS))
+ {
+ wstr = ARG (wchar_t *);
+ if (str == NULL)
+ conv_error ();
+ }
- if (!(flags & SUPPRESS))
- ++done;
+ do
+ {
+#define NEXT_WIDE_CHAR(First) \
+ c = inchar (); \
+ if (c == EOF) \
+ /* EOF is only an error for the first character. */ \
+ if (First) \
+ input_error (); \
+ else \
+ break; \
+ val = c; \
+ if (val >= 0x80) \
+ { \
+ if ((c & 0xc0) == 0x80 || (c & 0xfe) == 0xfe) \
+ encode_error (); \
+ if ((c & 0xe0) == 0xc0) \
+ { \
+ /* We expect two bytes. */ \
+ cnt = 1; \
+ val &= 0x1f; \
+ } \
+ else if ((c & 0xf0) == 0xe0) \
+ { \
+ /* We expect three bytes. */ \
+ cnt = 2; \
+ val &= 0x0f; \
+ } \
+ else if ((c & 0xf8) == 0xf0) \
+ { \
+ /* We expect four bytes. */ \
+ cnt = 3; \
+ val &= 0x07; \
+ } \
+ else if ((c & 0xfc) == 0xf8) \
+ { \
+ /* We expect five bytes. */ \
+ cnt = 4; \
+ val &= 0x03; \
+ } \
+ else \
+ { \
+ /* We expect six bytes. */ \
+ cnt = 5; \
+ val &= 0x01; \
+ } \
+ \
+ do \
+ { \
+ c = inchar (); \
+ if (c == EOF \
+ || (c & 0xc0) == 0x80 || (c & 0xfe) == 0xfe) \
+ encode_error (); \
+ val <<= 6; \
+ val |= c & 0x3f; \
+ } \
+ while (--cnt > 0); \
+ } \
+ \
+ if (!(flags & SUPPRESS)) \
+ *wstr++ = val; \
+ first = 0
+
+ NEXT_WIDE_CHAR (first);
+ }
+ while (--width > 0);
+ if (width > 0)
+ /* I.e., EOF was read. */
+ --read_in;
+
+ if (!(flags & SUPPRESS))
+ ++done;
+ }
break;
case 's': /* Read a string. */
-#define STRING_ARG \
+ if (flags & LONG)
+ /* We have to process a wide character string. */
+ goto wide_char_string;
+
+#define STRING_ARG(Str, Type) \
if (!(flags & SUPPRESS)) \
{ \
if (flags & MALLOC) \
@@ -479,14 +590,15 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
conv_error (); \
/* Allocate an initial buffer. */ \
strsize = 100; \
- *strptr = str = malloc (strsize); \
+ *strptr = malloc (strsize * sizeof (Type)); \
+ Str = (Type *) *strptr; \
} \
else \
- str = ARG (char *); \
- if (str == NULL) \
+ Str = ARG (Type *); \
+ if (Str == NULL) \
conv_error (); \
}
- STRING_ARG;
+ STRING_ARG (str, char);
c = inchar ();
if (c == EOF)
@@ -499,43 +611,44 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
ungetc (c, s);
break;
}
-#define STRING_ADD_CHAR(c) \
+#define STRING_ADD_CHAR(Str, c, Type) \
if (!(flags & SUPPRESS)) \
{ \
- *str++ = c; \
- if ((flags & MALLOC) && str == *strptr + strsize) \
+ *Str++ = c; \
+ if ((flags & MALLOC) && (char *) Str == *strptr + strsize) \
{ \
/* Enlarge the buffer. */ \
- str = realloc (*strptr, strsize * 2); \
- if (str == NULL) \
+ Str = realloc (*strptr, strsize * 2 * sizeof (Type)); \
+ if (Str == NULL) \
{ \
/* Can't allocate that much. Last-ditch effort. */\
- str = realloc (*strptr, strsize + 1); \
- if (str == NULL) \
+ Str = realloc (*strptr, \
+ (strsize + 1) * sizeof (Type)); \
+ if (Str == NULL) \
{ \
/* We lose. Oh well. \
Terminate the string and stop converting, \
so at least we don't skip any input. */ \
- (*strptr)[strsize] = '\0'; \
+ ((Type *) (*strptr))[strsize] = '\0'; \
++done; \
conv_error (); \
} \
else \
{ \
- *strptr = str; \
- str += strsize; \
+ *strptr = (char *) Str; \
+ Str = ((Type *) *strptr) + strsize; \
++strsize; \
} \
} \
else \
{ \
- *strptr = str; \
- str += strsize; \
+ *strptr = (char *) Str; \
+ Str = ((Type *) *strptr) + strsize; \
strsize *= 2; \
} \
} \
}
- STRING_ADD_CHAR (c);
+ STRING_ADD_CHAR (str, c, char);
} while ((width <= 0 || --width > 0) && inchar () != EOF);
if (!(flags & SUPPRESS))
@@ -545,6 +658,43 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
break;
+ case 'S':
+ /* Wide character string. */
+ wide_char_string:
+ {
+ wint_t val;
+ int first = 1;
+ STRING_ARG (wstr, wchar_t);
+
+ do
+ {
+ size_t cnt = 0;
+ NEXT_WIDE_CHAR (first);
+
+ if (iswspace (val))
+ {
+ /* XXX We would have to push back the whole wide char
+ with possibly many bytes. But since scanf does
+ not make a difference for white space characters
+ we can simply push back a simple <SP> which is
+ guaranteed to be in the [:space:] class. */
+ ungetc (' ', s);
+ break;
+ }
+
+ STRING_ADD_CHAR (wstr, val, wchar_t);
+ first = 0;
+ }
+ while (width <= 0 || --width > 0);
+
+ if (!(flags & SUPPRESS))
+ {
+ *wstr = L'\0';
+ ++done;
+ }
+ }
+ break;
+
case 'x': /* Hexadecimal integer. */
case 'X': /* Ditto. */
base = 16;
@@ -765,11 +915,19 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
break;
case '[': /* Character class. */
- STRING_ARG;
+ if (flags & LONG)
+ {
+ STRING_ARG (wstr, wchar_t);
+ c = '\0'; /* This is to keep gcc quiet. */
+ }
+ else
+ {
+ STRING_ARG (str, char);
- c = inchar ();
- if (c == EOF)
- input_error ();
+ c = inchar ();
+ if (c == EOF)
+ input_error ();
+ }
if (*f == '^')
{
@@ -814,31 +972,72 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
}
if (fc == '\0')
{
- ungetc (c, s);
+ if (!(flags & LONG))
+ ungetc (c, s);
conv_error();
}
- num.ul = read_in - 1; /* -1 because we already read one char. */
- do
+ if (flags & LONG)
{
- if (wp[c] == not_in)
+ wint_t val;
+ int first = 1;
+
+ do
{
- ungetc (c, s);
- break;
+ size_t cnt = 0;
+ NEXT_WIDE_CHAR (first);
+ if (val > 255 || wp[val] == not_in)
+ {
+ /* XXX We have a problem here. We read a wide
+ character and this possibly took several
+ bytes. But we can only push back one single
+ character. To be sure we don't create wrong
+ input we push it back only in case it is
+ representable within one byte. */
+ if (val < 0x80)
+ ungetc (val, s);
+ break;
+ }
+ STRING_ADD_CHAR (wstr, val, wchar_t);
+ if (width > 0)
+ --width;
+ first = 0;
}
- STRING_ADD_CHAR (c);
- if (width > 0)
- --width;
- }
- while (width != 0 && inchar () != EOF);
+ while (width != 0);
- if (read_in == num.ul)
- conv_error ();
+ if (first)
+ conv_error ();
- if (!(flags & SUPPRESS))
+ if (!(flags & SUPPRESS))
+ {
+ *wstr = L'\0';
+ ++done;
+ }
+ }
+ else
{
- *str = '\0';
- ++done;
+ num.ul = read_in - 1; /* -1 because we already read one char. */
+ do
+ {
+ if (wp[c] == not_in)
+ {
+ ungetc (c, s);
+ break;
+ }
+ STRING_ADD_CHAR (str, c, char);
+ if (width > 0)
+ --width;
+ }
+ while (width != 0 && inchar () != EOF);
+
+ if (read_in == num.ul)
+ conv_error ();
+
+ if (!(flags & SUPPRESS))
+ {
+ *str = '\0';
+ ++done;
+ }
}
break;
diff --git a/stdio/obstream.c b/stdio/obstream.c
index 32f7220b59..08adf4eaa9 100644
--- a/stdio/obstream.c
+++ b/stdio/obstream.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992, 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 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.
+ 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. */
+ 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 <ansidecl.h>
#include <stdio.h>
@@ -30,7 +30,7 @@ DEFUN(grow, (stream, c), FILE *stream AND int c)
struct obstack *const obstack = (struct obstack *) stream->__cookie;
/* Move the end of the object back to include only the portion
- of the buffer which the user has already written into. */
+ of the buffer which the user has already written into. */
obstack_blank_fast (obstack, - (stream->__put_limit - stream->__bufp));
if (stream->__target > obstack_object_size (obstack))
@@ -71,7 +71,7 @@ DEFUN(grow, (stream, c), FILE *stream AND int c)
else
{
/* Extend the buffer (and the object) to include
- the rest of the obstack chunk (which is unitialized).
+ the rest of the obstack chunk (which is uninitialized).
Data past bufp is undefined. */
stream->__put_limit = stream->__buffer + stream->__bufsize;
obstack_blank_fast (obstack, stream->__put_limit - stream->__bufp);
diff --git a/stdio/stdio.h b/stdio/stdio.h
index 12996b8607..083caa405e 100644
--- a/stdio/stdio.h
+++ b/stdio/stdio.h
@@ -302,7 +302,7 @@ extern char *tmpnam_r __P ((char *__s));
#endif
-#ifdef __USE_SVID
+#if def(__USE_SVID) || defined(__USE_XOPEN)
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
as follows: First the environment variable "TMPDIR" is checked.
diff --git a/stdlib/atexit.c b/stdlib/atexit.c
index bf7f91a22b..a49f219158 100644
--- a/stdlib/atexit.c
+++ b/stdlib/atexit.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 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. */
+ 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 <libc-lock.h>
#include <stdlib.h>
diff --git a/stdlib/l64a.c b/stdlib/l64a.c
index 914f0b5ded..1559b5b43a 100644
--- a/stdlib/l64a.c
+++ b/stdlib/l64a.c
@@ -1,21 +1,21 @@
/* 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.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
-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 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.
+ 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. */
+ 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 <stdlib.h>
@@ -34,18 +34,24 @@ static const char conv_table[64] =
char *
l64a (n)
- long n;
+ long int n;
{
static char result[7];
int cnt;
+ if (n <= 0l)
+ /* The value for N == 0 is defined to be the empty string. When a
+ negative value is given the result is undefined. We will
+ return the empty string. */
+ return (char *) "";
+
result[6] = '\0';
- for (cnt = 5; cnt >= 0; --cnt)
+ for (cnt = 5; n > 0; --cnt)
{
result[cnt] = conv_table[n & 0x3f];
n >>= 6;
}
- return result;
+ return &result[n + 1];
}
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index b43c170951..8f94f3b168 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -188,7 +188,7 @@ extern __inline long int atol (__const char *__nptr)
#endif /* Optimizing GCC >=2. */
-#ifdef __USE_SVID
+#if defined(__USE_SVID) || defined(__USE_XOPEN_EXTENDED)
/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
digit first. Returns a pointer to static storage overwritten by the
next call. */
@@ -196,15 +196,7 @@ extern char *l64a __P ((long int __n));
/* Read a number from a string S in base 64 as above. */
extern long int a64l __P ((__const char *__s));
-#endif
-
-
-/* Return a random integer between 0 and RAND_MAX inclusive. */
-extern int rand __P ((void));
-/* Seed the random number generator with the given number. */
-extern void srand __P ((unsigned int __seed));
-#ifdef __USE_BSD
#include <sys/types.h> /* we need int32_t... */
@@ -262,13 +254,36 @@ extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
size_t __statelen, struct random_data *__buf));
extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
-#endif /* __USE_REENTRANT. */
+#endif /* Use reentrant. */
#endif /* Use BSD. */
-#ifdef __USE_SVID
+/* Return a random integer between 0 and RAND_MAX inclusive. */
+extern int rand __P ((void));
+/* Seed the random number generator with the given number. */
+extern void srand __P ((unsigned int __seed));
+
+
+#if defined(__USE_SVID) || defined(__USE_XOPEN)
/* System V style 48-bit random number generator functions. */
+/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
+extern double drand48 __P ((void));
+extern double erand48 __P ((unsigned short int __xsubi[3]));
+
+/* Return non-negative, long integer in [0,2^31). */
+extern long lrand48 __P ((void));
+extern long nrand48 __P ((unsigned short int __xsubi[3]));
+
+/* Return signed, long integers in [-2^31,2^31). */
+extern long mrand48 __P ((void));
+extern long jrand48 __P ((unsigned short int __xsubi[3]));
+
+/* Seed random number generator. */
+extern void srand48 __P ((long __seedval));
+extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
+extern void lcong48 __P ((unsigned short int __param[7]));
+
/* Data structure for communication with thread safe versions. */
struct drand48_data
{
@@ -279,38 +294,34 @@ struct drand48_data
int init; /* Flag for initializing. */
};
+#ifdef __USE_REENTRANT
/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
-extern double drand48 __P ((void));
extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
-extern double erand48 __P ((unsigned short int __xsubi[3]));
extern int erand48_r __P ((unsigned short int __xsubi[3],
struct drand48_data *__buffer, double *__result));
+
/* Return non-negative, long integer in [0,2^31). */
-extern long lrand48 __P ((void));
extern int lrand48_r __P ((struct drand48_data *__buffer, long *__result));
-extern long nrand48 __P ((unsigned short int __xsubi[3]));
extern int nrand48_r __P ((unsigned short int __xsubi[3],
struct drand48_data *__buffer, long *__result));
+
/* Return signed, long integers in [-2^31,2^31). */
-extern long mrand48 __P ((void));
extern int mrand48_r __P ((struct drand48_data *__buffer, long *__result));
-extern long jrand48 __P ((unsigned short int __xsubi[3]));
extern int jrand48_r __P ((unsigned short int __xsubi[3],
struct drand48_data *__buffer, long *__result));
+
/* Seed random number generator. */
-extern void srand48 __P ((long __seedval));
extern int srand48_r __P ((long __seedval, struct drand48_data *__buffer));
-extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
extern int seed48_r __P ((unsigned short int __seed16v[3],
struct drand48_data *__buffer));
-extern void lcong48 __P ((unsigned short int __param[7]));
extern int lcong48_r __P ((unsigned short int __param[7],
struct drand48_data *__buffer));
+#endif /* Use reentrant. */
/* Internal function to compute next state of the generator. */
extern int __drand48_iterate __P ((unsigned short int __xsubi[3],
struct drand48_data *__buffer));
-#endif /* __USE_SVID. */
+#endif /* Use SVID or X/Open. */
/* Allocate SIZE bytes of memory. */
@@ -332,7 +343,7 @@ extern void cfree __P ((__ptr_t __ptr));
#include <alloca.h>
#endif /* Use GNU, BSD, or misc. */
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
extern __ptr_t valloc __P ((size_t __size));
#endif
@@ -365,7 +376,7 @@ extern char *getenv __P ((__const char *__name));
programs is running with SUID or SGID enabled. */
extern char *__secure_getenv __P ((__const char *__name));
-#ifdef __USE_SVID
+#if defined(__USE_SVID) || defined(__USE_XOPEN)
/* The SVID says this is in <stdio.h>, but this seems a better place. */
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
If there is no `=', remove NAME from the environment. */
@@ -389,6 +400,23 @@ extern void unsetenv __P ((__const char *__name));
extern int clearenv __P ((void));
#endif
+
+#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
+extern char *mktemp __P ((char *__template));
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Returns a file descriptor open on the file for reading and writing,
+ or -1 if it cannot create a uniquely-named file. */
+extern int mkstemp __P ((char *__template));
+#endif
+
+
/* Execute the given line as a shell command. */
extern int system __P ((__const char *__command));
@@ -400,7 +428,7 @@ extern int system __P ((__const char *__command));
extern char *canonicalize_file_name __P ((__const char *__name));
#endif
-#ifdef __USE_BSD
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Return the canonical absolute name of file NAME. The last file name
component need not exist, and may be a symlink to a nonexistent file.
If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
@@ -451,47 +479,49 @@ extern lldiv_t lldiv __P ((long long int __numer, long long int __denom)) __attr
#endif
-#ifdef __USE_SVID
+#if defined(__USE_SVID) || defined(__USE_XOPEN_EXTENDED)
/* Convert floating point numbers to strings. The returned values are
valid only until another call to the same function. */
/* Convert VALUE to a string with NDIGIT digits and return a pointer to
this. Set *DECPT with the position of the decimal character and *SIGN
with the sign of the number. */
-char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *__sign));
+extern char *ecvt __P ((double __value, int __ndigit, int *__decpt,
+ int *__sign));
/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
with the position of the decimal character and *SIGN with the sign of
the number. */
-char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *__sign));
+extern char *fcvt __P ((double __value, int __ndigit, int *__decpt,
+ int *__sign));
/* If possible convert VALUE to a string with NDIGIT significant digits.
Otherwise use exponential representation. The resulting string will
be written to BUF. */
-char *gcvt __P ((double __value, int __ndigit, char *__buf));
+extern char *gcvt __P ((double __value, int __ndigit, char *__buf));
/* Long double versions of above functions. */
-char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
- int *__sign));
-char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
- int *__sign));
-char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
+extern char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
+ int *__sign));
+extern char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
+ int *__sign));
+extern char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
#ifdef __USE_REENTRANT
/* Reentrant version of the functions above which provide their own
buffers. */
-int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign,
- char *__buf, size_t __len));
-int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign,
- char *__buf, size_t __len));
-
-int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
- int *__sign, char *__buf, size_t __len));
-int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
- int *__sign, char *__buf, size_t __len));
-#endif
-#endif
+extern int ecvt_r __P ((double __value, int __ndigit, int *__decpt,
+ int *__sign, char *__buf, size_t __len));
+extern int fcvt_r __P ((double __value, int __ndigit, int *__decpt,
+ int *__sign, char *__buf, size_t __len));
+
+extern int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
+ int *__sign, char *__buf, size_t __len));
+extern int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
+ int *__sign, char *__buf, size_t __len));
+#endif /* reentrant */
+#endif /* use MISC || use X/Open Unix */
/* Return the length of the multibyte character
@@ -525,7 +555,7 @@ extern int rpmatch __P ((__const char *__response));
#endif
-#ifdef __USE_MISC
+#ifdef __USE_XOPEN_EXTENDED
/* Parse comma separated suboption from *OPTIONP and match against
strings in TOKENS. If found return index and set *VALUEP to
optional value introduced by an equal sign. If the suboption is
@@ -537,6 +567,13 @@ extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens,
#endif
+#ifdef __USE_XOPEN
+
+/* Setup DES tables according KEY. */
+extern void setkey __P ((__const char *__key));
+#endif
+
+
__END_DECLS
#endif /* stdlib.h */
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index c38f61c52f..5a097b40a4 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -201,7 +201,10 @@ INTERNAL (strtol) (nptr, endptr, base, group)
#endif
if (base < 0 || base == 1 || base > 36)
- base = 10;
+ {
+ __set_errno (EINVAL);
+ return 0;
+ }
save = s = nptr;
@@ -214,8 +217,13 @@ INTERNAL (strtol) (nptr, endptr, base, group)
/* Check for a sign. */
if (*s == L_('-'))
{
+#if UNSIGNED
+ __set_errno (EINVAL);
+ return 0;
+#else
negative = 1;
++s;
+#endif
}
else if (*s == L_('+'))
{
diff --git a/stdlib/tst-strtol.c b/stdlib/tst-strtol.c
index 5c3e2cbb08..af7d41a5d3 100644
--- a/stdlib/tst-strtol.c
+++ b/stdlib/tst-strtol.c
@@ -1,7 +1,6 @@
/* My bet is this was written by Chris Torek.
I reformatted and ansidecl-ized it, and tweaked it a little. */
-#include <ansidecl.h>
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
@@ -10,13 +9,13 @@
struct ltest
{
- CONST char *str; /* Convert this. */
+ const char *str; /* Convert this. */
unsigned long int expect; /* To get this. */
int base; /* Use this base. */
char left; /* With this left over. */
int err; /* And this in errno. */
};
-static CONST struct ltest tests[] =
+static const struct ltest tests[] =
{
#if ~0UL == 0xffffffff
/* First, signed numbers. */
@@ -38,8 +37,8 @@ static CONST struct ltest tests[] =
{ " 0", 0, 0, 0, 0 },
{ "0xffffffffg", 0xffffffff, 0, 'g', 0 },
{ "0xf1f2f3f4f5", 0xffffffff, 0, 0, ERANGE },
- { "-0x123456789", 0xffffffff, 0, 0, ERANGE },
- { "-0xfedcba98", -0xfedcba98, 0, 0, 0 },
+ { "-0x123456789", 0, 0, 0, EINVAL },
+ { "-0xfedcba98", 0, 0, 0, EINVAL },
{ NULL, 0, 0, 0, 0 },
#else
/* assume 64 bit long... */
@@ -66,18 +65,18 @@ static CONST struct ltest tests[] =
{ "0xffffffffg", 0xffffffff, 0, 'g', 0 },
{ "0xffffffffffffffffg", 0xffffffffffffffff, 0, 'g', 0 },
{ "0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffff, 0, 0, ERANGE },
- { "-0x123456789abcdef01", 0xffffffffffffffff, 0, 0, ERANGE },
- { "-0xfedcba987654321", -0xfedcba987654321, 0, 0, 0 },
+ { "-0x123456789abcdef01", 0, 0, 0, EINVA{ },
+ { "-0xfedcba987654321", 0, 0, 0, EINVAL },
{ NULL, 0, 0, 0, 0 },
#endif
};
-static void EXFUN(expand, (char *dst, int c));
+static void expand __P ((char *dst, int c));
int
-DEFUN_VOID(main)
+main ()
{
- register CONST struct ltest *lt;
+ register const struct ltest *lt;
char *ep;
int status = 0;
@@ -145,7 +144,9 @@ DEFUN_VOID(main)
}
static void
-DEFUN(expand, (dst, c), register char *dst AND register int c)
+expand (dst, c)
+ char *dst;
+ int c;
{
if (isprint(c))
{
diff --git a/string/argz.h b/string/argz.h
index d7814fdd2e..8d81853c10 100644
--- a/string/argz.h
+++ b/string/argz.h
@@ -27,8 +27,6 @@
__BEGIN_DECLS
-#ifdef __USE_GNU
-
/* Make a '\0' separated arg vector from a unix argv vector, returning it in
ARGZ, and the total length in LEN. If a memory allocation error occurs,
ENOMEM is returned, otherwise 0. The result can be destroyed using free. */
@@ -129,6 +127,4 @@ argz_next (char *__argz, size_t __argz_len, __const char *__entry)
}
#endif /* optimizing GCC2 */
-#endif /* use GNU */
-
-#endif /* __ARGZ_H__ */
+#endif /* argz.h */
diff --git a/string/stratcliff.c b/string/stratcliff.c
index 10c1f1f6b7..a994e569be 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -1,3 +1,23 @@
+/* Test for string function add boundaries of usable memory.
+ 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. */
+
#define _GNU_SOURCE 1
#include <errno.h>
#include <stdio.h>
@@ -13,7 +33,7 @@
int
main (int argc, char *argv[])
{
- size_t size = sysconf (_SC_PAGESIZE);
+ int size = sysconf (_SC_PAGESIZE);
char *adr, *dest;
int result = 0;
@@ -52,7 +72,7 @@ main (int argc, char *argv[])
{
adr[inner] = '\0';
- if (strlen (&adr[outer]) != inner - outer)
+ if (strlen (&adr[outer]) != (size_t) (inner - outer))
{
printf ("strlen flunked for outer = %d, inner = %d\n",
outer, inner);
@@ -127,7 +147,7 @@ main (int argc, char *argv[])
adr[inner] = '\0';
if (strcpy (dest, &adr[outer]) != dest
- || strlen (dest) != inner - outer)
+ || strlen (dest) != (size_t) (inner - outer))
{
printf ("strcpy flunked for outer = %d, inner = %d\n",
outer, inner);
diff --git a/string/string.h b/string/string.h
index 414f2cb22a..ff6d3df21e 100644
--- a/string/string.h
+++ b/string/string.h
@@ -46,7 +46,7 @@ extern __ptr_t memmove __P ((__ptr_t __dest, __const __ptr_t __src,
or NULL if C was not found in the first N bytes of SRC. */
extern __ptr_t __memccpy __P ((__ptr_t __dest, __const __ptr_t __src,
int __c, size_t __n));
-#if defined (__USE_SVID) || defined (__USE_BSD)
+#if defined (__USE_SVID) || defined (__USE_BSD) || defined (__USE_XOPEN)
extern __ptr_t memccpy __P ((__ptr_t __dest, __const __ptr_t __src,
int __c, size_t __n));
#endif /* SVID. */
@@ -83,7 +83,7 @@ extern int strcoll __P ((__const char *__s1, __const char *__s2));
/* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t strxfrm __P ((char *__dest, __const char *__src, size_t __n));
-#if defined (__USE_SVID) || defined (__USE_BSD)
+#if defined(__USE_SVID) || defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Duplicate S, returning an identical malloc'd string. */
extern char *__strdup __P ((__const char *__s));
extern char *strdup __P ((__const char *__s));
@@ -177,13 +177,7 @@ extern char *strerror __P ((int __errnum));
extern char *strerror_r __P ((int __errnum, char *__buf, size_t __buflen));
#endif
-#ifdef __USE_BSD
-/* Find the first occurrence of C in S (same as strchr). */
-extern char *index __P ((__const char *__s, int __c));
-
-/* Find the last occurrence of C in S (same as strrchr). */
-extern char *rindex __P ((__const char *__s, int __c));
-
+#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
extern void bcopy __P ((__const __ptr_t __src, __ptr_t __dest, size_t __n));
@@ -193,6 +187,12 @@ extern void bzero __P ((__ptr_t __s, size_t __n));
/* Compare N bytes of S1 and S2 (same as memcmp). */
extern int bcmp __P ((__const __ptr_t __s1, __const __ptr_t __s2, size_t __n));
+/* Find the first occurrence of C in S (same as strchr). */
+extern char *index __P ((__const char *__s, int __c));
+
+/* Find the last occurrence of C in S (same as strrchr). */
+extern char *rindex __P ((__const char *__s, int __c));
+
/* Return the position of the first bit set in I, or 0 if none are set.
The least-significant bit is position 1, the most-significant 32. */
extern int ffs __P ((int __i));
@@ -206,7 +206,9 @@ extern int __strncasecmp __P ((__const char *__s1, __const char *__s2,
size_t __n));
extern int strncasecmp __P ((__const char *__s1, __const char *__s2,
size_t __n));
+#endif /* Use BSD or X/Open Unix. */
+#ifdef __USE_BSD
/* Return the next DELIM-delimited token from *STRINGP,
terminating it with a '\0', and update *STRINGP to point past it. */
extern char *__strsep __P ((char **__stringp, __const char *__delim));
@@ -238,14 +240,6 @@ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n));
extern char *basename __P ((__const char *__filename));
#endif
-#ifdef __USE_SVID
-/* Swab pairs bytes in the first N bytes of the area pointed to by
- FROM and copy the result to TO. The value of TO must not be in the
- range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
- is without partner. */
-extern void swab __P ((__const char *__from, __const char *__to, size_t __n));
-#endif
-
__END_DECLS
#endif /* string.h */
diff --git a/string/swab.c b/string/swab.c
index 350d9a3303..9d7858cf96 100644
--- a/string/swab.c
+++ b/string/swab.c
@@ -1,31 +1,29 @@
-/* Copyright (C) 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992, 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 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.
+ 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. */
+ 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 <ansidecl.h>
-#include <stddef.h>
+#include <unistd.h>
void
-DEFUN(swab, (from, to, n),
- CONST char *from AND char *to AND size_t n)
+swab (const char *from, char *to, ssize_t n)
{
while (n > 1)
{
- CONST char b0 = from[--n], b1 = from[--n];
+ const char b0 = from[--n], b1 = from[--n];
to[n] = b0;
to[n + 1] = b1;
}
diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile
index 45babb6c1c..6d4fbbb18b 100644
--- a/sysdeps/alpha/Makefile
+++ b/sysdeps/alpha/Makefile
@@ -42,4 +42,4 @@ ifeq ($(subdir),elf)
sysdep-CFLAGS += -mno-fp-regs
endif
-divrem := divl divlu divq divqu reml remlu remq remqu
+divrem := divl divq reml remq
diff --git a/sysdeps/alpha/bsd-_setjmp.S b/sysdeps/alpha/bsd-_setjmp.S
index a7bdbb5a61..be7f6dd05f 100644
--- a/sysdeps/alpha/bsd-_setjmp.S
+++ b/sysdeps/alpha/bsd-_setjmp.S
@@ -25,6 +25,10 @@ Cambridge, MA 02139, USA. */
ENTRY(_setjmp)
ldgp $29,0($27)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
bis $31, $31, $17 /* Pass a second argument of zero. */
jmp $31, __sigsetjmp /* Call __sigsetjmp. */
diff --git a/sysdeps/alpha/bsd-setjmp.S b/sysdeps/alpha/bsd-setjmp.S
index c0ed691f40..2b799613d7 100644
--- a/sysdeps/alpha/bsd-setjmp.S
+++ b/sysdeps/alpha/bsd-setjmp.S
@@ -25,6 +25,10 @@ Cambridge, MA 02139, USA. */
ENTRY(setjmp)
ldgp $29, 0($27)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
bis $31, 1, $17 /* Pass a second argument of one. */
jmp $31, __sigsetjmp /* Call __sigsetjmp. */
diff --git a/sysdeps/alpha/bzero.S b/sysdeps/alpha/bzero.S
index fffa53d7f1..c614fc1a6e 100644
--- a/sysdeps/alpha/bzero.S
+++ b/sysdeps/alpha/bzero.S
@@ -80,7 +80,14 @@ $tail: bne t4, 1f # is there a tail to do?
.end bzero_loop
ENTRY(bzero)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
mov a0, v0 # e0 : move return value in place
beq a1, $done # .. e1 : early exit for zero-length store
diff --git a/sysdeps/alpha/div.S b/sysdeps/alpha/div.S
new file mode 100644
index 0000000000..6c461c40d4
--- /dev/null
+++ b/sysdeps/alpha/div.S
@@ -0,0 +1,110 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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 <sysdep.h>
+
+#ifdef __linux__
+# include <asm/gentrap.h>
+# include <asm/pal.h>
+#else
+# include <machine/pal.h>
+#endif
+
+ .set noat
+
+ .align 4
+ .globl div
+ .ent div
+div:
+ .frame sp, 0, ra
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+#define dividend t0
+#define divisor t1
+#define mask t2
+#define quotient t3
+#define modulus t4
+#define tmp1 t5
+#define tmp2 t6
+#define compare t7
+
+ /* find correct sign for input to unsigned divide loop. */
+ sextl a1, a1 # e0 :
+ sextl a2, a2 # .. e1 :
+ negl a1, dividend # e0 :
+ negl a2, divisor # .. e1 :
+ cmovge a1, a1, dividend # e0 :
+ cmovge a2, a2, divisor # .. e1 :
+ beq a2, $divbyzero # e1 :
+ unop # :
+
+ /* shift divisor left, using 3-bit shifts for 32-bit divides as we
+ can't overflow. Three-bit shifts will result in looping three
+ times less here, but can result in two loops more later. Thus
+ using a large shift isn't worth it (and s8addq pairs better than
+ a shift). */
+
+1: cmpult divisor, modulus, compare # e0 :
+ s8addq divisor, zero, divisor # .. e1 :
+ s8addq mask, zero, mask # e0 :
+ bne compare, 1b # .. e1 :
+
+ /* start to go right again. */
+2: addq quotient, mask, tmp2 # e1 :
+ srl mask, 1, mask # .. e0 :
+ cmpule divisor, modulus, compare # e0 :
+ subq modulus, divisor, tmp1 # .. e1 :
+ cmovne compare, tmp2, quotient # e1 :
+ srl divisor, 1, divisor # .. e0 :
+ cmovne compare, tmp1, modulus # e0 :
+ bne mask, 2b # .. e1 :
+
+ /* find correct sign for result. */
+ xor a1, a2, compare # e0 :
+ negl quotient, tmp1 # .. e1 :
+ negl modulus, tmp2 # e0 :
+ cmovlt compare, tmp1, quotient # .. e1 :
+ cmovlt a1, tmp2, modulus # e1 :
+
+ /* and store it away in the structure. */
+ stl quotient, 0(a0) # .. e0 :
+ mov a0, v0 # e1 :
+ stl modulus, 4(a0) # .. e0 :
+ ret # e1 :
+
+$divbyzero:
+ mov a0, v0
+ ldiq a0, GEN_INTDIV
+ call_pal PAL_gentrap
+
+ /* if trap returns, return zero. */
+ stl zero, 0(v0)
+ stl zero, 4(v0)
+ ret
+
+ .end div
diff --git a/sysdeps/alpha/divl.S b/sysdeps/alpha/divl.S
index 6990665937..fdf053fc25 100644
--- a/sysdeps/alpha/divl.S
+++ b/sysdeps/alpha/divl.S
@@ -1,6 +1,6 @@
#define IS_REM 0
#define SIZE 4
-#define SIGNED 1
-#define FUNC_NAME __divl
+#define UFUNC_NAME __divlu
+#define SFUNC_NAME __divl
#include "divrem.h"
diff --git a/sysdeps/alpha/divlu.S b/sysdeps/alpha/divlu.S
deleted file mode 100644
index ee96c95008..0000000000
--- a/sysdeps/alpha/divlu.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define IS_REM 0
-#define SIZE 4
-#define SIGNED 0
-#define FUNC_NAME __divlu
-
-#include "divrem.h"
diff --git a/sysdeps/alpha/divq.S b/sysdeps/alpha/divq.S
index bde3425f37..8c88af9736 100644
--- a/sysdeps/alpha/divq.S
+++ b/sysdeps/alpha/divq.S
@@ -1,6 +1,6 @@
#define IS_REM 0
#define SIZE 8
-#define SIGNED 1
-#define FUNC_NAME __divq
+#define UFUNC_NAME __divqu
+#define SFUNC_NAME __divq
#include "divrem.h"
diff --git a/sysdeps/alpha/divqu.S b/sysdeps/alpha/divqu.S
deleted file mode 100644
index 72dcf971dd..0000000000
--- a/sysdeps/alpha/divqu.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define IS_REM 0
-#define SIZE 8
-#define SIGNED 0
-#define FUNC_NAME __divqu
-
-#include "divrem.h"
diff --git a/sysdeps/alpha/divrem.h b/sysdeps/alpha/divrem.h
index eaf892b3c6..b83908dc9f 100644
--- a/sysdeps/alpha/divrem.h
+++ b/sysdeps/alpha/divrem.h
@@ -1,25 +1,25 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
Contributed by David Mosberger (davidm@cs.arizona.edu).
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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. */
/* The current Alpha chips don't provide hardware for integer
-division. The C compiler expects the functions
+ division. The C compiler expects the functions
__divqu: 64-bit unsigned long divide
__remqu: 64-bit unsigned long remainder
@@ -27,10 +27,10 @@ division. The C compiler expects the functions
__divlu/__remlu: unsigned 32-bit
__divls/__remls: signed 32-bit
-These are not normal C functions: instead of the normal calling
-sequence, these expect their arguments in registers t10 and t11, and
-return the result in t12 (aka pv). Register AT may be clobbered
-(assembly temporary), anything else must be saved. */
+ These are not normal C functions: instead of the normal calling
+ sequence, these expect their arguments in registers t10 and t11, and
+ return the result in t12 (aka pv). Register AT may be clobbered
+ (assembly temporary), anything else must be saved. */
#include <sysdep.h>
@@ -41,147 +41,185 @@ return the result in t12 (aka pv). Register AT may be clobbered
# include <machine/pal.h>
#endif
-#ifdef DEBUG
-# define arg1 a0
-# define arg2 a1
-# define result v0
-# define mask t0
-# define tmp0 t1
-# define tmp1 t2
-# define sign t3
-# define retaddr ra
-#else
-# define arg1 t10
-# define arg2 t11
-# define result t12
-# define mask v0
-# define tmp0 t0
-# define tmp1 t1
-# define sign t2
-# define retaddr t9
-#endif
+#define mask v0
+#define divisor t0
+#define compare AT
+#define tmp1 t2
+#define tmp2 t3
+#define retaddr t9
+#define arg1 t10
+#define arg2 t11
+#define result t12
-# define divisor arg2
#if IS_REM
-# define dividend result
-# define quotient arg1
-# define GETDIVIDEND bis arg1,zero,dividend
+# define DIV_ONLY(x,y...)
+# define REM_ONLY(x,y...) x,##y
+# define modulus result
+# define quotient t1
+# define GETSIGN(x) mov arg1, x
+# define STACK 32
#else
-# define dividend arg1
-# define quotient result
-# define GETDIVIDEND
+# define DIV_ONLY(x,y...) x,##y
+# define REM_ONLY(x,y...)
+# define modulus t1
+# define quotient result
+# define GETSIGN(x) xor arg1, arg2, x
+# define STACK 48
#endif
#if SIZE == 8
-# define LONGIFYarg1 GETDIVIDEND
-# define LONGIFYarg2
-#else
-# if SIGNED
-# define LONGIFYarg1 addl arg1,zero,dividend
-# define LONGIFYarg2 addl arg2,zero,divisor
-# else
-# define LONGIFYarg1 zapnot arg1,0x0f,dividend
-# define LONGIFYarg2 zapnot arg2,0x0f,divisor
-# endif
-#endif
-
-#if SIGNED
-# define SETSIGN(sign,reg,tmp) subq zero,reg,tmp; cmovlt sign,tmp,reg
-# if IS_REM
-# define GETSIGN(x,y,s) bis x,zero,s
-# else
-# define GETSIGN(x,y,s) xor x,y,s
-# endif
+# define LONGIFY(x,y) mov x,y
+# define SLONGIFY(x,y) mov x,y
+# define _SLONGIFY(x)
+# define NEG(x,y) negq x,y
#else
-# define SETSIGN(sign,reg,tmp)
-# define GETSIGN(x,y,s)
+# define LONGIFY(x,y) zapnot x,15,y
+# define SLONGIFY(x,y) sextl x,y
+# define _SLONGIFY(x) sextl x,x
+# define NEG(x,y) negl x,y
#endif
.set noreorder
.set noat
- .ent FUNC_NAME
- .globl FUNC_NAME
-
-#define FRAME_SIZE 0x30
+ .ent UFUNC_NAME
+ .globl UFUNC_NAME
- .align 5
-FUNC_NAME:
+ .align 3
+UFUNC_NAME:
+ lda sp, -STACK(sp)
+ .frame sp, STACK, retaddr, 0
#ifdef PROF
- lda sp, -0x18(sp)
- stq ra, 0x00(sp)
- stq pv, 0x08(sp)
- stq gp, 0x10(sp)
+ stq ra, 0(sp)
+ stq pv, 8(sp)
+ stq gp, 16(sp)
br AT, 1f
1: ldgp gp, 0(AT)
mov retaddr, ra
- jsr AT, _mcount
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
- ldq ra, 0x00(sp)
- ldq pv, 0x08(sp)
- ldq gp, 0x10(sp)
- lda sp, 0x18(sp)
+ ldq ra, 0(sp)
+ ldq pv, 8(sp)
+ ldq gp, 16(sp)
#endif
- .frame sp, FRAME_SIZE, retaddr, 0
- lda sp,-FRAME_SIZE(sp)
- .prologue 1
- stq arg1,0x00(sp)
- LONGIFYarg1
- stq arg2,0x08(sp)
- LONGIFYarg2
- stq mask,0x10(sp)
- bis zero,1,mask
- stq tmp0,0x18(sp)
- bis zero,zero,quotient
- stq tmp1,0x20(sp)
- beq divisor,$divbyzero
- stq sign,0x28(sp)
- GETSIGN(dividend,divisor,sign)
-#if SIGNED
- subq zero,dividend,tmp0
- subq zero,divisor,tmp1
- cmovlt dividend,tmp0,dividend
- cmovlt divisor,tmp1,divisor
+ .prologue 0
+
+$udiv:
+ stq t0, 0(sp)
+ LONGIFY (arg2, divisor)
+ stq t1, 8(sp)
+ LONGIFY (arg1, modulus)
+ stq v0, 16(sp)
+ clr quotient
+ stq tmp1, 24(sp)
+ ldiq mask, 1
+ DIV_ONLY(stq tmp2,32(sp))
+
+ beq divisor, $divbyzero
+
+ .align 3
+#if SIZE == 8
+ /* Shift divisor left. */
+1: cmpult divisor, modulus, compare
+ blt divisor, 2f
+ addq divisor, divisor, divisor
+ addq mask, mask, mask
+ bne compare, 1b
+ unop
+2:
+#else
+ /* Shift divisor left using 3-bit shifts as we can't overflow.
+ This results in looping three times less here, but up to
+ two more times later. Thus using a large shift isn't worth it. */
+1: cmpult divisor, modulus, compare
+ s8addq divisor, zero, divisor
+ s8addq mask, zero, mask
+ bne compare, 1b
#endif
- /*
- * Shift divisor left until either bit 63 is set or until it
- * is at least as big as the dividend:
- */
- .align 3
-1: cmpule dividend,divisor,AT
- blt divisor,2f
- blbs AT,2f
- addq mask,mask,mask
- addq divisor,divisor,divisor
- br 1b
-
- .align 3
-2: addq mask,quotient,tmp0
- cmpule divisor,dividend,AT
- subq dividend,divisor,tmp1
- srl divisor,1,divisor
- srl mask,1,mask
- cmovlbs AT,tmp0,quotient
- cmovlbs AT,tmp1,dividend
- bne mask,2b
-
- ldq arg1,0x00(sp)
- SETSIGN(sign,result,tmp0)
-$done: ldq arg2,0x08(sp)
- ldq mask,0x10(sp)
- ldq tmp0,0x18(sp)
- ldq tmp1,0x20(sp)
- ldq sign,0x28(sp)
- lda sp,FRAME_SIZE(sp)
- ret zero,(retaddr),0
+
+ /* Now go back to the right. */
+3: DIV_ONLY(addq quotient, mask, tmp2)
+ srl mask, 1, mask
+ cmpule divisor, modulus, compare
+ subq modulus, divisor, tmp1
+ DIV_ONLY(cmovne compare, tmp2, quotient)
+ srl divisor, 1, divisor
+ cmovne compare, tmp1, modulus
+ bne mask, 3b
+
+$done: ldq t0, 0(sp)
+ ldq t1, 8(sp)
+ ldq v0, 16(sp)
+ ldq tmp1, 24(sp)
+ DIV_ONLY(ldq tmp2, 32(sp))
+ lda sp, STACK(sp)
+ ret zero, (retaddr), 1
$divbyzero:
- lda a0,GEN_INTDIV(zero)
+ mov a0, tmp1
+ ldiq a0, GEN_INTDIV
call_pal PAL_gentrap
- bis zero,zero,result /* if trap returns, return 0 */
- ldq arg1,0x00(sp)
+ mov tmp1, a0
+ clr result /* If trap returns, return zero. */
br $done
- END(FUNC_NAME)
+ .end UFUNC_NAME
+
+ .ent SFUNC_NAME
+ .globl SFUNC_NAME
+
+ .align 3
+SFUNC_NAME:
+ lda sp, -STACK(sp)
+ .frame sp, STACK, retaddr, 0
+#ifdef PROF
+ stq ra, 0(sp)
+ stq pv, 8(sp)
+ stq gp, 16(sp)
+
+ br AT, 1f
+1: ldgp gp, 0(AT)
+
+ mov retaddr, ra
+ jsr AT, _mcount
+
+ ldq ra, 0(sp)
+ ldq pv, 8(sp)
+ ldq gp, 16(sp)
+#endif
+ .prologue 0
+
+ or arg1, arg2, AT
+ _SLONGIFY(AT)
+ bge AT, $udiv /* don't need to mess with signs */
+
+ /* Save originals and find absolute values. */
+ stq arg1, 0(sp)
+ NEG (arg1, AT)
+ stq arg2, 8(sp)
+ cmovge AT, AT, arg1
+ stq retaddr, 16(sp)
+ NEG (arg2, AT)
+ stq tmp1, 24(sp)
+ cmovge AT, AT, arg2
+
+ /* Do the unsigned division. */
+ bsr retaddr, UFUNC_NAME
+
+ /* Restore originals and adjust the sign of the result. */
+ ldq arg1, 0(sp)
+ ldq arg2, 8(sp)
+ GETSIGN (AT)
+ NEG (result, tmp1)
+ _SLONGIFY(AT)
+ ldq retaddr, 16(sp)
+ cmovlt AT, tmp1, result
+ ldq tmp1, 24(sp)
+
+ lda sp, STACK(sp)
+ ret zero, (retaddr), 1
+
+ .end SFUNC_NAME
diff --git a/sysdeps/alpha/ffs.S b/sysdeps/alpha/ffs.S
index b84a51d326..959d1046d4 100644
--- a/sysdeps/alpha/ffs.S
+++ b/sysdeps/alpha/ffs.S
@@ -27,7 +27,14 @@ architecture. */
.set noat
ENTRY(ffs)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
ldq_u zero, 0(sp) # on the 21064, this helps dual-issuing
addl a0, zero, a0 # the last insn and reduces the stall
diff --git a/sysdeps/alpha/htonl.S b/sysdeps/alpha/htonl.S
index 9777e461cc..55d4f62bc7 100644
--- a/sysdeps/alpha/htonl.S
+++ b/sysdeps/alpha/htonl.S
@@ -19,7 +19,15 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
ENTRY(__htonl)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
+
extlh a0, 5, t1 # t1 = dd000000
zap a0, 0xfd, t2 # t2 = 0000cc00
sll t2, 5, t2 # t2 = 00198000
diff --git a/sysdeps/alpha/htons.S b/sysdeps/alpha/htons.S
index 7717636782..743d3e2474 100644
--- a/sysdeps/alpha/htons.S
+++ b/sysdeps/alpha/htons.S
@@ -19,7 +19,15 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
ENTRY(__htons)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
+
extwh a0, 7, t1 # t1 = bb00
extbl a0, 1, v0 # v0 = 00aa
bis v0, t1, v0 # v0 = bbaa
diff --git a/sysdeps/alpha/ldiv.S b/sysdeps/alpha/ldiv.S
new file mode 100644
index 0000000000..ebbe055870
--- /dev/null
+++ b/sysdeps/alpha/ldiv.S
@@ -0,0 +1,109 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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 <sysdep.h>
+
+#ifdef __linux__
+# include <asm/gentrap.h>
+# include <asm/pal.h>
+#else
+# include <machine/pal.h>
+#endif
+
+ .set noat
+
+ .align 4
+ .globl ldiv
+ .ent ldiv
+ldiv:
+ .frame sp, 0, ra
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+#define dividend t0
+#define divisor t1
+#define mask t2
+#define quotient t3
+#define modulus t4
+#define tmp1 t5
+#define tmp2 t6
+#define compare t7
+
+ /* find correct sign for input to unsigned divide loop. */
+ mov a1, dividend # e0 :
+ mov a2, divisor # .. e1 :
+ negq a1, tmp1 # e0 :
+ negq a2, tmp2 # .. e1 :
+ cmovlt a1, tmp1, dividend # e0 :
+ cmovlt a2, tmp2, divisor # .. e1 :
+ beq a2, $divbyzero # e1 :
+ unop # :
+
+ /* shift divisor left. */
+1: cmpult divisor, modulus, compare # e0 :
+ blt divisor, 2f # .. e1 :
+ addq divisor, divisor, divisor # e0 :
+ addq mask, mask, mask # .. e1 :
+ bne compare, 1b # e1 :
+ unop # :
+
+ /* start to go right again. */
+2: addq quotient, mask, tmp2 # e1 :
+ srl mask, 1, mask # .. e0 :
+ cmpule divisor, modulus, compare # e0 :
+ subq modulus, divisor, tmp1 # .. e1 :
+ cmovne compare, tmp2, quotient # e1 :
+ srl divisor, 1, divisor # .. e0 :
+ cmovne compare, tmp1, modulus # e0 :
+ bne mask, 2b # .. e1 :
+
+ /* find correct sign for result. */
+ xor a1, a2, compare # e0 :
+ negq quotient, tmp1 # .. e1 :
+ negq modulus, tmp2 # e0 :
+ cmovlt compare, tmp1, quotient # .. e1 :
+ cmovlt a1, tmp2, modulus # e1 :
+
+ /* and store it away in the structure. */
+9: stq quotient, 0(a0) # .. e0 :
+ mov a0, v0 # e1 :
+ stq modulus, 8(a0) # .. e0 :
+ ret # e1 :
+
+$divbyzero:
+ mov a0, v0
+ lda a0, GEN_INTDIV
+ call_pal PAL_gentrap
+
+ /* if trap returns, return zero. */
+ stq zero, 0(v0)
+ stq zero, 8(v0)
+ ret
+
+ .end ldiv
+
+weak_alias(ldiv, lldiv)
diff --git a/sysdeps/alpha/lldiv.S b/sysdeps/alpha/lldiv.S
new file mode 100644
index 0000000000..80c450a3fc
--- /dev/null
+++ b/sysdeps/alpha/lldiv.S
@@ -0,0 +1 @@
+/* lldiv is the same as ldiv on the Alpha. */
diff --git a/sysdeps/alpha/memchr.S b/sysdeps/alpha/memchr.S
index a47ac96e01..ecd26e8d6f 100644
--- a/sysdeps/alpha/memchr.S
+++ b/sysdeps/alpha/memchr.S
@@ -40,7 +40,14 @@ For correctness consider that:
.set noat
ENTRY(memchr)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
beq a2, $not_found
ldq_u t0, 0(a0) # load first quadword (a0 may be misaligned)
diff --git a/sysdeps/alpha/memcpy.S b/sysdeps/alpha/memcpy.S
new file mode 100644
index 0000000000..4ee9c115db
--- /dev/null
+++ b/sysdeps/alpha/memcpy.S
@@ -0,0 +1,276 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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. */
+
+
+/* This is the child of the C-with-inline-assembly memcpy posted by
+ Martin Ostermann (ost@comnets.rwth-aachen.de).
+
+ This is generally scheduled for the EV5, but whenever necessary and
+ possible, the autoswap slotting feature of the EV5 is used so that the
+ code lays out nicely for the EV4 as well. */
+
+#include <alpha/regdef.h>
+
+ .set noreorder
+
+ .text
+
+ .ent copy_fwd_aligned
+copy_fwd_aligned:
+ .frame sp, 0, ra, 0
+ .prologue 0
+
+ /* Aligned forward copy main loop. On entry to this basic block:
+ t0 == source word waiting to be stored
+ t2 == loop counter
+ a0 == destination pointer
+ a1 == source pointer
+ a2 mod 8 == byte count in final word */
+ .align 4
+$fa_loop:
+ and t2, 7, t1 # e0 :
+ beq t1, 1f # .. e1 :
+
+0: stq_u t0, 0(a0) # e0 :
+ subq t1, 1, t1 # .. e1 :
+ ldq_u t0, 8(a1) # e0 : copy up to seven words
+ addq a0, 8, a0 # .. e1 :
+ addq a1, 8, a1 # e0 :
+ bne t1, 0b # .. e1 :
+
+1: bic t2, 7, t2 # e0 :
+ beq t2, $fa_tail # .. e1 :
+
+2: stq_u t0, 0(a0) # e0 :
+ addq a0, 64, a0 # .. e1 :
+ ldq_u t3, 8(a1) # e0 : copy eight words as fast as we can
+ ldq_u t4, 16(a1) # .. e1 :
+ ldq_u t5, 24(a1) # e0 :
+ ldq_u t6, 32(a1) # .. e1 :
+ ldq_u t7, 40(a1) # e0 :
+ ldq_u t8, 48(a1) # .. e1 :
+ ldq_u t9, 56(a1) # e0 :
+ ldq_u t0, 64(a1) # .. e1 :
+ stq_u t3, -56(a0) # e0 :
+ subq t2, 8, t2 # .. e1 :
+ stq_u t4, -48(a0) # e0 :
+ addq a1, 64, a1 # .. e1 :
+ stq_u t5, -40(a0) # e0 :
+ stq_u t6, -32(a0) # e0 :
+ stq_u t7, -24(a0) # e0 :
+ stq_u t8, -16(a0) # e0 :
+ stq_u t9, -8(a0) # e0 :
+ bne t2, 2b # .. e1 :
+
+ /* Take care of a partial word tail. */
+$fa_tail:
+ and a2, 7, t3 # e0 :
+ bne t3, 1f # .. e1 (zdb)
+
+ /* Aligned copy, aligned tail, final store. */
+ stq_u t0, 0(a0)
+ ret
+
+1: ldq_u t1, 0(a0) # e1 :
+ mskql t0, a2, t0 # .. e1 :
+ mskqh t1, a2, t1 # e0 (stall)
+ bis t0, t1, t0 # e1 :
+ stq_u t0, 0(a0) # e0 :
+ ret # .. e1 :
+
+ /* This is the actual entry point to this function. */
+ .align 3
+$fwd_aligned:
+ ldq_u t0, 0(a1) # e0 :
+ and a0, 7, t3 # .. e1 :
+ addq a2, t3, a2 # e0 :
+ subq a2, 1, t2 # e1 :
+ sra t2, 3, t2 # e0 :
+ beq t3, $fa_loop # .. e1 :
+
+ ldq_u t1, 0(a0) # e0 :
+ beq t2, $fa_small # .. e1 :
+ mskqh t0, a0, t0 # e0 :
+ mskql t1, a0, t3 # e0 :
+ bis t0, t3, t0 # e0 :
+ br $fa_loop # .. e1 :
+
+ /* The move affects exactly one destination word. */
+$fa_small:
+ mskqh t0, a0, t0 # e0 :
+ and a2, 7, t4 # .. e1 :
+ mskql t1, a0, t3 # e0 :
+ bne t4, 1f # .. e1 :
+
+ or t0, t3, t0 # e0 :
+ unop # :
+ stq_u t0, 0(a0) # e0 :
+ ret # .. e1 :
+
+1: mskql t0, a2, t0 # e0 :
+ mskqh t1, a2, t1 # e0 :
+ or t0, t3, t0 # e0 :
+ or t0, t1, t0 # e1 :
+ stq_u t0, 0(a0) # e0 :
+ ret # .. e1 :
+
+ .end copy_fwd_aligned
+
+ .ent memcpy
+ .globl memcpy
+ .align 3
+memcpy:
+ .frame sp, 0, ra, 0
+#ifdef PROF
+ ldgp gp, 0(ra)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+ mov a0, v0
+ beq a2, $zero_length
+
+ /* Are source and destination co-aligned? */
+ xor a0, a1, t0
+ unop
+ and t0, 7, t0
+ beq t0, $fwd_aligned
+ br $fwd_unaligned
+
+ .end memcpy
+
+ .ent copy_fwd_unaligned
+copy_fwd_unaligned:
+ .frame sp, 0, ra, 0
+ .prologue 0
+
+ /* Unaligned forward copy main loop. On entry to this basic block:
+ t0 == source low word, unshifted
+ t2 == loop counter
+ t7 == last source byte + 1
+ a0 == destination pointer
+ a1 == source pointer
+ a2 mod 8 == byte count in final word */
+ .align 4
+$fu_loop:
+ beq t2, $fu_tail # e1 :
+ blbc t2, 0f # e1 :
+
+ ldq_u t1, 8(a1) # e1 : copy one unaligned word
+ extql t0, a1, t3 # .. e0 :
+ addq a1, 8, a1 # e0 :
+ addq a0, 8, a0 # .. e1 :
+ extqh t1, a1, t4 # e0 :
+ subq t2, 1, t2 # .. e1 :
+ mov t1, t0 # e0 :
+ or t3, t4, t3 # .. e1 :
+ stq_u t3, -8(a0) # e0 :
+ beq t2, $fu_tail # .. e1 :
+
+0: ldq_u t1, 8(a1) # e1 : copy two unaligned words
+ extql t0, a1, t3 # .. e0 :
+ ldq_u t0, 16(a1) # e0 :
+ subq t2, 2, t2 # .. e1 :
+ extqh t1, a1, t4 # e0 :
+ addq a0, 16, a0 # .. e1 :
+ extql t1, a1, t5 # e0 :
+ or t3, t4, t3 # .. e1 :
+ extqh t0, a1, t6 # e0 :
+ addq a1, 16, a1 # .. e1 :
+ stq_u t3, -16(a0) # e0 :
+ or t5, t6, t5 # .. e1 :
+ stq_u t5, -8(a0) # e0 :
+ bne t2, 0b # .. e1 :
+
+ /* Take care of a partial words tail. */
+$fu_tail:
+ ldq_u t4, -1(t7) # e1 :
+ extql t0, a1, t3 # .. e0 :
+ extqh t4, a1, t4 # e0 (stall)
+ and a2, 7, t5 # .. e1 :
+ or t3, t4, t3 # e0 :
+ beq t5, 1f # .. e1 :
+
+ ldq_u t1, 0(a0) # e1 :
+ mskql t3, a2, t3 # .. e0 :
+ mskqh t1, a2, t1 # e0 (stall)
+ or t1, t3, t3 # e1 :
+
+1: stq_u t3, 0(a0) # e0 :
+ ret # .. e1 :
+
+ /* The entry point to the unaligned forward copy. */
+ .align 3
+$fwd_unaligned:
+ ldq_u t0, 0(a1) # e0 : load initial bits of src
+ addq a1, a2, t7 # .. e1 : record last byte + 1 of src
+ and a0, 7, t3 # e0 : find dst misalignment
+ addq a2, t3, a2 # e1 : find number of words affected
+ subq a2, 1, t2 # e0 :
+ cmple a2, 8, t4 # .. e1 : are we dealing with a small block?
+ subq a1, t3, a1 # e0 :
+ bne t4, $fu_small # .. e1 :
+ srl t2, 3, t2 # e0 :
+ beq t3, $fu_loop # .. e1 :
+
+ /* Take care of an unaligned dst head. */
+ ldq_u t5, 0(a0) # e0 :
+ ldq_u t1, 8(a1) # .. e1 :
+ extql t0, a1, t3 # e0 :
+ addq a0, 8, a0 # .. e1 :
+ extqh t1, a1, t4 # e0 :
+ addq a1, 8, a1 # .. e1 :
+ mskql t5, a0, t5 # e0 :
+ or t3, t4, t3 # .. e1 :
+ mskqh t3, a0, t3 # e0 :
+ subq t2, 1, t2 # .. e1 :
+ or t3, t5, t3 # e0 :
+ mov t1, t0 # .. e1 :
+ stq_u t3, -8(a0) # e0 :
+ br $fu_loop # .. e1 :
+
+ /* The move affects exactly one destination word. */
+ .align 3
+$fu_small:
+ ldq_u t2, 0(a0) # e1 :
+ extql t0, a1, t3 # .. e0 :
+ ldq_u t1, -1(t7) # e0 :
+ and a2, 7, t8 # .. e1 :
+ mskqh t2, a2, t6 # e0 :
+ mskql t2, a0, t5 # e0 :
+ extqh t1, a1, t4 # e0 :
+ cmovne t8, t6, t8 # .. e1 :
+ or t3, t4, t3 # e0 :
+ or t5, t8, t5 # .. e1 :
+ mskqh t3, a0, t3 # e0 :
+ and a2, 7, t8 # .. e1 :
+ mskql t3, a2, t6 # e0 :
+ cmovne t8, t6, t8 # e1 :
+ or t3, t5, t3 # e0 :
+ unop # :
+ stq_u t3, 0(a0) # e0 :
+
+$zero_length:
+ ret # .. e1 :
+
+ .end copy_fwd_unaligned
diff --git a/sysdeps/alpha/memset.S b/sysdeps/alpha/memset.S
index 55271f00ea..2b29357c6e 100644
--- a/sysdeps/alpha/memset.S
+++ b/sysdeps/alpha/memset.S
@@ -85,7 +85,14 @@ $tail: bne t4, 1f # is there a tail to do?
.end memset_loop
ENTRY(memset)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
zapnot a1, 1, a1 # e0 : zero extend input character
mov a0, v0 # .. e1 : move return value in place
diff --git a/sysdeps/alpha/reml.S b/sysdeps/alpha/reml.S
index b631a02c31..8c00365ee3 100644
--- a/sysdeps/alpha/reml.S
+++ b/sysdeps/alpha/reml.S
@@ -1,6 +1,6 @@
#define IS_REM 1
#define SIZE 4
-#define SIGNED 1
-#define FUNC_NAME __reml
+#define UFUNC_NAME __remlu
+#define SFUNC_NAME __reml
#include "divrem.h"
diff --git a/sysdeps/alpha/remlu.S b/sysdeps/alpha/remlu.S
deleted file mode 100644
index 8d527e4678..0000000000
--- a/sysdeps/alpha/remlu.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define IS_REM 1
-#define SIZE 4
-#define SIGNED 0
-#define FUNC_NAME __remlu
-
-#include "divrem.h"
diff --git a/sysdeps/alpha/remq.S b/sysdeps/alpha/remq.S
index 8bd9f334f4..cd1064af4e 100644
--- a/sysdeps/alpha/remq.S
+++ b/sysdeps/alpha/remq.S
@@ -1,6 +1,6 @@
#define IS_REM 1
#define SIZE 8
-#define SIGNED 1
-#define FUNC_NAME __remq
+#define UFUNC_NAME __remqu
+#define SFUNC_NAME __remq
#include "divrem.h"
diff --git a/sysdeps/alpha/remqu.S b/sysdeps/alpha/remqu.S
deleted file mode 100644
index 14a7486148..0000000000
--- a/sysdeps/alpha/remqu.S
+++ /dev/null
@@ -1,6 +0,0 @@
-#define IS_REM 1
-#define SIZE 8
-#define SIGNED 0
-#define FUNC_NAME __remqu
-
-#include "divrem.h"
diff --git a/sysdeps/alpha/s_copysign.S b/sysdeps/alpha/s_copysign.S
index 95eb608666..739d3deb79 100644
--- a/sysdeps/alpha/s_copysign.S
+++ b/sysdeps/alpha/s_copysign.S
@@ -20,7 +20,15 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
ENTRY(__copysign)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
+
cpys $f17,$f16,$f0
ret
diff --git a/sysdeps/alpha/s_fabs.S b/sysdeps/alpha/s_fabs.S
index 12c0abdf75..75976333f9 100644
--- a/sysdeps/alpha/s_fabs.S
+++ b/sysdeps/alpha/s_fabs.S
@@ -20,7 +20,15 @@ Cambridge, MA 02139, USA. */
#include <sysdep.h>
ENTRY(__fabs)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
+
cpys $f31,$f16,$f0
ret
diff --git a/sysdeps/alpha/setjmp.S b/sysdeps/alpha/setjmp.S
index 59929a0234..f57d49017e 100644
--- a/sysdeps/alpha/setjmp.S
+++ b/sysdeps/alpha/setjmp.S
@@ -23,6 +23,10 @@ Cambridge, MA 02139, USA. */
extra arguments. */
ENTRY (__sigsetjmp)
ldgp $29, 0($27)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
bis $30, $30, $18 /* Pass SP as 3rd arg. */
diff --git a/sysdeps/alpha/stpcpy.S b/sysdeps/alpha/stpcpy.S
index 0dc44d353a..9c2668b535 100644
--- a/sysdeps/alpha/stpcpy.S
+++ b/sysdeps/alpha/stpcpy.S
@@ -27,6 +27,10 @@ Cambridge, MA 02139, USA. */
ENTRY(__stpcpy)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
jsr t9, __stxcpy # do the work of the copy
diff --git a/sysdeps/alpha/stpncpy.S b/sysdeps/alpha/stpncpy.S
index 50cda2672e..90470cf95c 100644
--- a/sysdeps/alpha/stpncpy.S
+++ b/sysdeps/alpha/stpncpy.S
@@ -1,24 +1,23 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
Contributed by Richard Henderson (rth@tamu.edu)
-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 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.
-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. */
-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. */
-
-/* Copy no more than COUNT bytes of the null-terminated string from
+/* Copy no more than COUNT bytes of the null-terminated string from
SRC to DST. If SRC does not cover all of COUNT, the balance is
zeroed. Return the address of the terminating null in DEST, if
any, else DEST + COUNT. */
@@ -32,8 +31,12 @@ Cambridge, MA 02139, USA. */
ENTRY(__stpncpy)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
-
+
beq a2, $zerocount
jsr t9, __stxncpy # do the work of the copy
diff --git a/sysdeps/alpha/strcat.S b/sysdeps/alpha/strcat.S
index d3afff3c5f..e57259f51d 100644
--- a/sysdeps/alpha/strcat.S
+++ b/sysdeps/alpha/strcat.S
@@ -1,22 +1,21 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
Contributed by Richard Henderson (rth@tamu.edu)
-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 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.
-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. */
+ 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. */
/* Append a null-terminated string from SRC to DST. */
@@ -26,6 +25,10 @@ Cambridge, MA 02139, USA. */
ENTRY(strcat)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
mov a0, v0 # set up return value
@@ -59,7 +62,7 @@ $found: negq t1, t2 # clear all but least set bit
addq a0, t2, a0
/* Now do the append. */
-
+
jsr t9, __stxcpy
ret
diff --git a/sysdeps/alpha/strchr.S b/sysdeps/alpha/strchr.S
index c26a8431d2..e35b44ad6c 100644
--- a/sysdeps/alpha/strchr.S
+++ b/sysdeps/alpha/strchr.S
@@ -1,25 +1,24 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
Contributed by Richard Henderson (rth@tamu.edu)
-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 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.
-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. */
+ 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. */
/* Return the address of a given character within a null-terminated
- string, or null if it is not found.
+ string, or null if it is not found.
This is generally scheduled for the EV5 (got to look out for my own
interests :-), but with EV4 needs in mind. There *should* be no more
@@ -32,7 +31,14 @@ Cambridge, MA 02139, USA. */
.set noat
ENTRY(strchr)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
zapnot a1, 1, a1 # e0 : zero extend the search character
ldq_u t0, 0(a0) # .. e1 : load first quadword
diff --git a/sysdeps/alpha/strcmp.S b/sysdeps/alpha/strcmp.S
new file mode 100644
index 0000000000..7dcae04ea4
--- /dev/null
+++ b/sysdeps/alpha/strcmp.S
@@ -0,0 +1,195 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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. */
+
+/* Bytewise compare two null-terminated strings. */
+
+#include <sysdep.h>
+
+ .set noat
+ .set noreorder
+
+ .text
+
+ENTRY(strcmp)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jmp AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+ ldq_u t0, 0(a0) # e0 : give cache time to catch up
+ xor a0, a1, t2 # .. e1 : are s1 and s2 co-aligned?
+ ldq_u t1, 0(a1) # e0 :
+ and t2, 7, t2 # .. e1 :
+ lda t3, -1 # e0 :
+ bne t2, $unaligned # .. e1 :
+
+ /* On entry to this basic block:
+ t0 == the first destination word for masking back in
+ t1 == the first source word.
+ t3 == -1. */
+
+$aligned:
+ mskqh t3, a0, t3 # e0 :
+ nop # .. e1 :
+ ornot t1, t3, t1 # e0 :
+ ornot t0, t3, t0 # .. e1 :
+ cmpbge zero, t1, t7 # e0 : bits set iff null found
+ bne t7, $eos # e1 (zdb)
+
+ /* Aligned compare main loop.
+ On entry to this basic block:
+ t0 == an s1 word.
+ t1 == an s2 word not containing a null. */
+
+$a_loop:
+ xor t0, t1, t2 # e0 :
+ bne t2, $wordcmp # .. e1 (zdb)
+ ldq_u t1, 8(a1) # e0 :
+ ldq_u t0, 8(a0) # .. e1 :
+ addq a1, 8, a1 # e0 :
+ addq a0, 8, a0 # .. e1 :
+ cmpbge zero, t1, t7 # e0 :
+ beq t7, $a_loop # .. e1 (zdb)
+ br $eos # e1 :
+
+ /* The two strings are not co-aligned. Align s1 and cope. */
+
+$unaligned:
+ and a0, 7, t4 # e0 : find s1 misalignment
+ and a1, 7, t5 # .. e1 : find s2 misalignment
+ subq a1, t4, a1 # e0 :
+
+ /* If s2 misalignment is larger than s2 misalignment, we need
+ extra startup checks to avoid SEGV. */
+
+ cmplt t4, t5, t8 # .. e1 :
+ beq t8, $u_head # e1 :
+
+ mskqh t3, t5, t3 # e0 :
+ ornot t1, t3, t3 # e0 :
+ cmpbge zero, t3, t7 # e1 : is there a zero?
+ beq t7, $u_head # e1 :
+
+ /* We've found a zero in the first partial word of s2. Align
+ our current s1 and s2 words and compare what we've got. */
+
+ extql t1, t5, t1 # e0 :
+ extql t0, a0, t0 # e0 :
+ cmpbge zero, t1, t7 # .. e1 : find that zero again
+ br $eos # e1 : and finish up
+
+ .align 3
+$u_head:
+ /* We know just enough now to be able to assemble the first
+ full word of s2. We can still find a zero at the end of it.
+
+ On entry to this basic block:
+ t0 == first word of s1
+ t1 == first partial word of s2. */
+
+ ldq_u t2, 8(a1) # e0 : load second partial s2 word
+ lda t3, -1 # .. e1 : create leading garbage mask
+ extql t1, a1, t1 # e0 : create first s2 word
+ mskqh t3, a0, t3 # e0 :
+ extqh t2, a1, t4 # e0 :
+ ornot t0, t3, t0 # .. e1 : kill s1 garbage
+ or t1, t4, t1 # e0 : s2 word now complete
+ cmpbge zero, t0, t7 # .. e1 : find zero in first s1 word
+ ornot t1, t3, t1 # e0 : kill s2 garbage
+ lda t3, -1 # .. e1 :
+ mskql t3, a1, t3 # e0 : mask for s2[1] bits we have seen
+ bne t7, $eos # .. e1 :
+ xor t0, t1, t4 # e0 : compare aligned words
+ bne t4, $wordcmp # .. e1 (zdb)
+ or t2, t3, t3 # e0 :
+ cmpbge zero, t3, t7 # e1 :
+ bne t7, $u_final # e1 :
+
+ /* Unaligned copy main loop. In order to avoid reading too much,
+ the loop is structured to detect zeros in aligned words from s2.
+ This has, unfortunately, effectively pulled half of a loop
+ iteration out into the head and half into the tail, but it does
+ prevent nastiness from accumulating in the very thing we want
+ to run as fast as possible.
+
+ On entry to this basic block:
+ t2 == the unshifted low-bits from the next s2 word. */
+
+ .align 3
+$u_loop:
+ extql t2, a1, t3 # e0 :
+ ldq_u t2, 16(a1) # .. e1 : load next s2 high bits
+ ldq_u t0, 8(a0) # e0 : load next s1 word
+ addq a1, 8, a1 # .. e1 :
+ addq a0, 8, a0 # e0 :
+ nop # .. e1 :
+ extqh t2, a1, t1 # e0 :
+ cmpbge zero, t0, t7 # .. e1 : find zero in current s1 word
+ or t1, t3, t1 # e0 :
+ bne t7, $eos # .. e1 :
+ xor t0, t1, t4 # e0 : compare the words
+ bne t4, $wordcmp # .. e1 (zdb)
+ cmpbge zero, t2, t4 # e0 : find zero in next low bits
+ beq t4, $u_loop # .. e1 (zdb)
+
+ /* We've found a zero in the low bits of the last s2 word. Get
+ the next s1 word and align them. */
+$u_final:
+ ldq_u t0, 8(a0) # e1 :
+ extql t2, a1, t1 # .. e0 :
+ cmpbge zero, t1, t7 # e0 :
+
+ /* We've found a zero somewhere in a word we just read.
+ On entry to this basic block:
+ t0 == s1 word
+ t1 == s2 word
+ t7 == cmpbge mask containing the zero. */
+
+ .align 3
+$eos:
+ negq t7, t6 # e0 : create bytemask of valid data
+ and t6, t7, t8 # e1 :
+ subq t8, 1, t6 # e0 :
+ or t6, t8, t7 # e1 :
+ zapnot t0, t7, t0 # e0 : kill the garbage
+ zapnot t1, t7, t1 # .. e1 :
+ xor t0, t1, v0 # e0 : and compare
+ beq v0, $done # .. e1 :
+
+ /* Here we have two differing co-aligned words in t0 & t1.
+ Bytewise compare them and return (t0 > t1 ? 1 : -1). */
+$wordcmp:
+ cmpbge t0, t1, t2 # e0 : comparison yields bit mask of ge
+ cmpbge t1, t0, t3 # .. e1 :
+ xor t2, t3, t0 # e0 : bits set iff t0/t1 bytes differ
+ negq t0, t1 # e1 : clear all but least bit
+ and t0, t1, t0 # e0 :
+ lda v0, -1 # .. e1 :
+ and t0, t2, t1 # e0 : was bit set in t0 > t1?
+ cmovne t1, 1, v0 # .. e1 (zdb)
+
+$done:
+ ret # e1 :
+
+ END(strcmp)
diff --git a/sysdeps/alpha/strcpy.S b/sysdeps/alpha/strcpy.S
index 2975181919..823476f750 100644
--- a/sysdeps/alpha/strcpy.S
+++ b/sysdeps/alpha/strcpy.S
@@ -27,6 +27,10 @@ Cambridge, MA 02139, USA. */
ENTRY(strcpy)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
mov a0, v0 # set up return value
diff --git a/sysdeps/alpha/strlen.S b/sysdeps/alpha/strlen.S
index 9eab707388..026c8addc2 100644
--- a/sysdeps/alpha/strlen.S
+++ b/sysdeps/alpha/strlen.S
@@ -34,6 +34,15 @@ Cambridge, MA 02139, USA. */
.set noat
ENTRY(strlen)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
ldq_u t0, 0(a0) # load first quadword (a0 may be misaligned)
lda t1, -1(zero)
insqh t1, a0, t1
diff --git a/sysdeps/alpha/strncat.S b/sysdeps/alpha/strncat.S
index d502037ace..089fba34d9 100644
--- a/sysdeps/alpha/strncat.S
+++ b/sysdeps/alpha/strncat.S
@@ -27,6 +27,10 @@ Cambridge, MA 02139, USA. */
ENTRY(strncat)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
mov a0, v0 # set up return value
diff --git a/sysdeps/alpha/strncmp.S b/sysdeps/alpha/strncmp.S
new file mode 100644
index 0000000000..682759042f
--- /dev/null
+++ b/sysdeps/alpha/strncmp.S
@@ -0,0 +1,224 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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. */
+
+/* Bytewise compare two null-terminated strings of length no longer than N. */
+
+#include <sysdep.h>
+
+ .set noat
+ .set noreorder
+
+ .text
+
+ENTRY(strncmp)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+ xor a0, a1, t2 # e0 : are s1 and s2 co-aligned?
+ beq a2, $zerolength # .. e1 :
+ ldq_u t0, 0(a0) # e0 : give cache time to catch up
+ ldq_u t1, 0(a1) # .. e1 :
+ and t2, 7, t2 # e0 :
+ and a0, 7, t4 # .. e1 : find s1 misalignment
+ lda t3, -1 # e0 :
+ addq a2, t4, a2 # .. e1 : bias count by s1 misalignment
+ and a2, 7, t10 # e1 : ofs of last byte in last word
+ srl a2, 3, a2 # .. e0 : remaining full words in count
+ and a1, 7, t5 # e0 : find s2 misalignment
+ bne t2, $unaligned # .. e1 :
+
+ /* On entry to this basic block:
+ t0 == the first word of s1.
+ t1 == the first word of s2.
+ t3 == -1. */
+
+$aligned:
+ mskqh t3, a1, t3 # e0 : mask off leading garbage
+ nop # .. e1 :
+ ornot t1, t3, t1 # e0 :
+ ornot t0, t3, t0 # .. e1 :
+ cmpbge zero, t1, t7 # e0 : bits set iff null found
+ beq a2, $eoc # .. e1 : check end of count
+ unop # :
+ bne t7, $eos # e1 :
+
+ /* Aligned compare main loop.
+ On entry to this basic block:
+ t0 == an s1 word.
+ t1 == an s2 word not containing a null. */
+
+$a_loop:
+ xor t0, t1, t2 # e0 :
+ bne t2, $wordcmp # .. e1 (zdb)
+ ldq_u t1, 0(a1) # e0 :
+ ldq_u t0, 0(a0) # .. e1 :
+ addq a1, 8, a1 # e0 :
+ addq a0, 8, a0 # .. e1 :
+ cmpbge zero, t1, t7 # e0 :
+ beq a2, $eoc # .. e1 :
+ subq a2, 1, a2 # e0 :
+ beq t7, $a_loop # .. e1 :
+ br $eos # e1 :
+
+ /* The two strings are not co-aligned. Align s1 and cope. */
+$unaligned:
+ subq a1, t4, a1 # e0 :
+ unop # :
+
+ /* If s2 misalignment is larger than s2 misalignment, we need
+ extra startup checks to avoid SEGV. */
+
+ cmplt t4, t5, t8 # .. e1 :
+ beq t8, $u_head # e1 :
+
+ mskqh t3, t5, t3 # e0 :
+ ornot t1, t3, t3 # e0 :
+ cmpbge zero, t3, t7 # e1 : is there a zero?
+ beq t7, $u_head # e1 :
+
+ /* We've found a zero in the first partial word of s2. Align
+ our current s1 and s2 words and compare what we've got. */
+
+ extql t1, t5, t1 # e0 :
+ lda t3, -1 # .. e1 :
+ insql t1, a0, t1 # e0 :
+ mskqh t3, a0, t3 # e0 :
+ ornot t1, t3, t1 # e0 :
+ ornot t0, t3, t0 # .. e1 :
+ cmpbge zero, t1, t7 # e0 : find that zero again
+ beq a2, $eoc # .. e1 : and finish up
+ br $eos # e1 :
+
+ .align 3
+$u_head:
+ /* We know just enough now to be able to assemble the first
+ full word of s2. We can still find a zero at the end of it.
+
+ On entry to this basic block:
+ t0 == first word of s1
+ t1 == first partial word of s2. */
+
+ ldq_u t2, 8(a1) # e0 : load second partial s2 word
+ lda t3, -1 # .. e1 : create leading garbage mask
+ extql t1, a1, t1 # e0 : create first s2 word
+ mskqh t3, a0, t3 # e0 :
+ extqh t2, a1, t4 # e0 :
+ ornot t0, t3, t0 # .. e1 : kill s1 garbage
+ or t1, t4, t1 # e0 : s2 word now complete
+ ornot t1, t3, t1 # e1 : kill s2 garbage
+ cmpbge zero, t0, t7 # e0 : find zero in first s1 word
+ beq a2, $eoc # .. e1 :
+ lda t3, -1 # e0 :
+ bne t7, $eos # .. e1 :
+ subq a2, 1, a2 # e0 :
+ xor t0, t1, t4 # .. e1 : compare aligned words
+ mskql t3, a1, t3 # e0 : mask out s2[1] bits we have seen
+ bne t4, $wordcmp # .. e1 :
+ or t2, t3, t3 # e0 :
+ cmpbge zero, t3, t7 # e1 : find zero in high bits of s2[1]
+ bne t7, $u_final # e1 :
+
+ /* Unaligned copy main loop. In order to avoid reading too much,
+ the loop is structured to detect zeros in aligned words from s2.
+ This has, unfortunately, effectively pulled half of a loop
+ iteration out into the head and half into the tail, but it does
+ prevent nastiness from accumulating in the very thing we want
+ to run as fast as possible.
+
+ On entry to this basic block:
+ t2 == the unshifted low-bits from the next s2 word. */
+
+ .align 3
+$u_loop:
+ extql t2, a1, t3 # e0 :
+ ldq_u t2, 16(a1) # .. e1 : load next s2 high bits
+ ldq_u t0, 8(a0) # e0 : load next s1 word
+ addq a1, 8, a1 # .. e1 :
+ addq a0, 8, a0 # e0 :
+ nop # .. e1 :
+ extqh t2, a1, t1 # e0 :
+ cmpbge zero, t0, t7 # .. e1 : find zero in current s1 word
+ or t1, t3, t1 # e0 :
+ beq a2, $eoc # .. e1 : check for end of count
+ subq a2, 1, a2 # e0 :
+ bne t7, $eos # .. e1 :
+ xor t0, t1, t4 # e0 : compare the words
+ bne t4, $wordcmp # .. e1 (zdb)
+ cmpbge zero, t2, t4 # e0 : find zero in next low bits
+ beq t4, $u_loop # .. e1 (zdb)
+
+ /* We've found a zero in the low bits of the last s2 word. Get
+ the next s1 word and align them. */
+$u_final:
+ ldq_u t0, 8(a0) # e1 :
+ extql t2, a1, t1 # .. e0 :
+ cmpbge zero, t1, t7 # e0 :
+ bne a2, $eos # .. e1 :
+
+ /* We've hit end of count. Zero everything after the count
+ and compare whats left. */
+
+ .align 3
+$eoc:
+ mskql t0, t10, t0
+ mskql t1, t10, t1
+
+ /* We've found a zero somewhere in a word we just read.
+ On entry to this basic block:
+ t0 == s1 word
+ t1 == s2 word
+ t7 == cmpbge mask containing the zero. */
+
+$eos:
+ negq t7, t6 # e0 : create bytemask of valid data
+ and t6, t7, t8 # e1 :
+ subq t8, 1, t6 # e0 :
+ or t6, t8, t7 # e1 :
+ zapnot t0, t7, t0 # e0 : kill the garbage
+ zapnot t1, t7, t1 # .. e1 :
+ xor t0, t1, v0 # e0 : and compare
+ beq v0, $done # .. e1 :
+
+ /* Here we have two differing co-aligned words in t0 & t1.
+ Bytewise compare them and return (t0 > t1 ? 1 : -1). */
+$wordcmp:
+ cmpbge t0, t1, t2 # e0 : comparison yields bit mask of ge
+ cmpbge t1, t0, t3 # .. e1 :
+ xor t2, t3, t0 # e0 : bits set iff t0/t1 bytes differ
+ negq t0, t1 # e1 : clear all but least bit
+ and t0, t1, t0 # e0 :
+ lda v0, -1 # .. e1 :
+ and t0, t2, t1 # e0 : was bit set in t0 > t1?
+ cmovne t1, 1, v0 # .. e1 (zdb)
+
+$done:
+ ret # e1 :
+
+$zerolength:
+ clr v0
+ ret
+
+ END(strncmp)
diff --git a/sysdeps/alpha/strncpy.S b/sysdeps/alpha/strncpy.S
index e13769c5c3..c077ab35b7 100644
--- a/sysdeps/alpha/strncpy.S
+++ b/sysdeps/alpha/strncpy.S
@@ -31,6 +31,10 @@ Cambridge, MA 02139, USA. */
ENTRY(strncpy)
ldgp gp, 0(pv)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
.prologue 1
mov a0, v0 # set return value now
diff --git a/sysdeps/alpha/strrchr.S b/sysdeps/alpha/strrchr.S
index 464f754b20..02f37f50be 100644
--- a/sysdeps/alpha/strrchr.S
+++ b/sysdeps/alpha/strrchr.S
@@ -31,7 +31,14 @@ Cambridge, MA 02139, USA. */
.set noat
ENTRY(strrchr)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
zapnot a1, 1, a1 # e0 : zero extend our test character
mov zero, t6 # .. e1 : t6 is last match aligned addr
diff --git a/sysdeps/alpha/udiv_qrnnd.S b/sysdeps/alpha/udiv_qrnnd.S
index eb134f25c7..75d11827f9 100644
--- a/sysdeps/alpha/udiv_qrnnd.S
+++ b/sysdeps/alpha/udiv_qrnnd.S
@@ -27,8 +27,15 @@
.text
LEAF(__udiv_qrnnd, 0)
-
+#ifdef PROF
+ ldgp gp, 0(pv)
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+ .prologue 1
+#else
.prologue 0
+#endif
+
#define cnt $2
#define tmp $3
#define rem_ptr $16
@@ -38,9 +45,9 @@ LEAF(__udiv_qrnnd, 0)
#define qb $20
ldiq cnt,16
- blt d,.Largedivisor
+ blt d,$largedivisor
-.Loop1: cmplt n0,0,tmp
+$loop1: cmplt n0,0,tmp
addq n1,n1,n1
bis n1,tmp,n1
addq n0,n0,n0
@@ -73,12 +80,12 @@ LEAF(__udiv_qrnnd, 0)
cmovne qb,tmp,n1
bis n0,qb,n0
subq cnt,1,cnt
- bgt cnt,.Loop1
+ bgt cnt,$loop1
stq n1,0(rem_ptr)
bis $31,n0,$0
ret $31,($26),1
-.Largedivisor:
+$largedivisor:
and n0,1,$4
srl n0,1,n0
@@ -90,7 +97,7 @@ LEAF(__udiv_qrnnd, 0)
srl d,1,$5
addq $5,$6,$5
-.Loop2: cmplt n0,0,tmp
+$loop2: cmplt n0,0,tmp
addq n1,n1,n1
bis n1,tmp,n1
addq n0,n0,n0
@@ -123,27 +130,30 @@ LEAF(__udiv_qrnnd, 0)
cmovne qb,tmp,n1
bis n0,qb,n0
subq cnt,1,cnt
- bgt cnt,.Loop2
+ bgt cnt,$loop2
addq n1,n1,n1
addq $4,n1,n1
- bne $6,.LOdd
+ bne $6,$Odd
stq n1,0(rem_ptr)
bis $31,n0,$0
ret $31,($26),1
-.LOdd:
+$Odd:
/* q' in n0. r' in n1 */
addq n1,n0,n1
+
cmpult n1,n0,tmp # tmp := carry from addq
- beq tmp,.LLp6
- addq n0,1,n0
- subq n1,d,n1
-.LLp6: cmpult n1,d,tmp
- bne tmp,.LLp7
- addq n0,1,n0
- subq n1,d,n1
-.LLp7:
+ subq n1,d,AT
+ addq n0,tmp,n0
+ cmovne tmp,AT,n1
+
+ cmpult n1,d,tmp
+ addq n0,1,AT
+ cmoveq tmp,AT,n0
+ subq n1,d,AT
+ cmoveq tmp,AT,n1
+
stq n1,0(rem_ptr)
bis $31,n0,$0
ret $31,($26),1
diff --git a/sysdeps/alpha/w_sqrt.S b/sysdeps/alpha/w_sqrt.S
new file mode 100644
index 0000000000..b5c980e557
--- /dev/null
+++ b/sysdeps/alpha/w_sqrt.S
@@ -0,0 +1,161 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ Contributed by David Mosberger (davidm@cs.arizona.edu).
+ Based on public-domain C source by Linus Torvalds.
+
+ 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. */
+
+/* This version is much faster than generic sqrt implementation, but
+ it doesn't handle exceptional values or the inexact flag. Don't use
+ this if _IEEE_FP or _IEEE_FP_INEXACT is in effect. */
+
+#ifndef _IEEE_FP
+
+#include <errnos.h>
+#include <sysdep.h>
+
+ .set noreorder
+
+#ifdef __ELF__
+ .section .rodata
+#else
+ .rdata
+#endif
+ .align 5 # align to cache line
+
+ /* Do all memory accesses relative to sqrtdata. */
+sqrtdata:
+
+#define DN 0x00
+#define UP 0x08
+#define HALF 0x10
+#define ALMOST_THREE_HALF 0x18
+#define T2 0x20
+
+ .quad 0x3fefffffffffffff /* DN = next(1.0) */
+ .quad 0x3ff0000000000001 /* UP = prev(1.0) */
+ .quad 0x3fe0000000000000 /* HALF = 0.5 */
+ .quad 0x3ff7ffffffc00000 /* ALMOST_THREE_HALF = 1.5-2^-30 */
+
+/* table T2: */
+.long 0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866
+.long 0xf14a, 0x1091b, 0x11fcd, 0x13552, 0x14999, 0x15c98, 0x16e34, 0x17e5f
+.long 0x18d03, 0x19a01, 0x1a545, 0x1ae8a, 0x1b5c4, 0x1bb01, 0x1bfde, 0x1c28d
+.long 0x1c2de, 0x1c0db, 0x1ba73, 0x1b11c, 0x1a4b5, 0x1953d, 0x18266, 0x16be0
+.long 0x1683e, 0x179d8, 0x18a4d, 0x19992, 0x1a789, 0x1b445, 0x1bf61, 0x1c989
+.long 0x1d16d, 0x1d77b, 0x1dddf, 0x1e2ad, 0x1e5bf, 0x1e6e8, 0x1e654, 0x1e3cd
+.long 0x1df2a, 0x1d635, 0x1cb16, 0x1be2c, 0x1ae4e, 0x19bde, 0x1868e, 0x16e2e
+.long 0x1527f, 0x1334a, 0x11051, 0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd
+
+/*
+ * Stack variables:
+ */
+#define K 16(sp)
+#define Y 24(sp)
+#define FSIZE 32
+
+ .text
+
+LEAF(__sqrt, FSIZE)
+ lda sp, -FSIZE(sp)
+ ldgp gp, .-__sqrt(pv)
+ stq ra, 0(sp)
+#ifdef PROF
+ lda AT, _mcount
+ jsr AT, (AT), _mcount
+#endif
+ .prologue 1
+
+ stt $f16, K
+ lda t3, sqrtdata # load base address into t3
+
+ fblt $f16, $negative
+
+ /* Compute initial guess. */
+
+ .align 3
+
+ ldah t1, 0x5fe8 # e0 :
+ ldq t2, K # .. e1 :
+ ldt $f12, HALF(t3) # e0 :
+ ldt $f18, ALMOST_THREE_HALF(t3) # .. e1 :
+ srl t2, 33, t0 # e0 :
+ mult $f16, $f12, $f11 # .. fm : $f11 = x * 0.5
+ subl t1, t0, t1 # e0 :
+ addt $f12, $f12, $f17 # .. fa : $f17 = 1.0
+ srl t1, 12, t0 # e0 :
+ and t0, 0xfc, t0 # .. e1 :
+ addq t0, t3, t0 # e0 :
+ ldl t0, T2(t0) # .. e1 :
+ addt $f12, $f17, $f15 # fa : $f15 = 1.5
+ subl t1, t0, t1 # .. e1 :
+ sll t1, 32, t1 # e0 :
+ ldt $f14, DN(t3) # .. e1 :
+ stq t1, Y # e0 :
+ ldt $f13, Y # e1 :
+ addq sp, FSIZE, sp # e0 :
+
+ mult $f11, $f13, $f10 # fm : $f10 = (x * 0.5) * y
+ mult $f10, $f13, $f10 # fm : $f10 = ((x * 0.5) * y) * y
+ subt $f15, $f10, $f1 # fa : $f1 = (1.5 - 0.5*x*y*y)
+ mult $f13, $f1, $f13 # fm : yp = y*(1.5 - 0.5*x*y*y)
+ mult $f11, $f13, $f11 # fm : $f11 = x * 0.5 * yp
+ mult $f11, $f13, $f11 # fm : $f11 = (x * 0.5 * yp) * yp
+ subt $f18, $f11, $f1 # fa : $f1= (1.5-2^-30) - 0.5*x*yp*yp
+ mult $f13, $f1, $f13 # fm : ypp = $f13 = yp*$f1
+ subt $f15, $f12, $f1 # fa : $f1 = (1.5 - 0.5)
+ ldt $f15, UP(t3) # .. e1 :
+ mult $f16, $f13, $f10 # fm : z = $f10 = x * ypp
+ mult $f10, $f13, $f11 # fm : $f11 = z*ypp
+ mult $f10, $f12, $f12 # fm : $f12 = z*0.5
+ subt $f1, $f11, $f1 # .. fa : $f1 = 1 - z*ypp
+ mult $f12, $f1, $f12 # fm : $f12 = z*0.5*(1 - z*ypp)
+ addt $f10, $f12, $f0 # fa : zp=res=$f0= z + z*0.5*(1 - z*ypp)
+
+ mult/c $f0, $f14, $f12 # fm : zmi = zp * DN
+ mult/c $f0, $f15, $f11 # fm : zpl = zp * UP
+ mult/c $f0, $f12, $f1 # fm : $f1 = zp * zmi
+ mult/c $f0, $f11, $f15 # fm : $f15 = zp * zpl
+
+ subt $f1, $f16, $f13 # fa : y1 = zp*zmi - x
+ subt $f15, $f16, $f15 # fa : y2 = zp*zpl - x
+
+ fcmovge $f13, $f12, $f0 # res = (y1 >= 0) ? zmi : res
+ fcmovlt $f15, $f11, $f0 # res = (y2 < 0) ? zpl : res
+
+ ret
+
+$negative:
+ lda t1, -1
+ stq t1, K
+ lda t1, EDOM
+ stl t1, errno
+#ifdef _LIBC_REENTRANT
+ jsr ra, __errno_location
+ lda t1, -1
+ ldq ra, 0(sp)
+ stl t1, 0(v0)
+#endif
+ ldt $f0, K # res = (double) 0xffffffffffffffff
+ addq sp, FSIZE, sp
+ ret
+
+ END(__sqrt)
+
+weak_alias(__sqrt, sqrt)
+
+#endif /* !_IEEE_FP */
diff --git a/sysdeps/generic/confname.h b/sysdeps/generic/confname.h
index 3d76843d12..5b5cf742b6 100644
--- a/sysdeps/generic/confname.h
+++ b/sysdeps/generic/confname.h
@@ -1,21 +1,21 @@
/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
-Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ Copyright (C) 1993, 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 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.
+ 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. */
+ 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. */
/* Values for the NAME argument to `pathconf' and `fpathconf'. */
enum
@@ -237,8 +237,83 @@ enum
#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX
_SC_PASS_MAX,
#define _SC_PASS_MAX _SC_PASS_MAX
- _SC_XOPEN_VERSION
+
+ _SC_XOPEN_VERSION,
#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION
+ _SC_XOPEN_XCU_VERSION,
+#define _SC_XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION
+ _SC_XOPEN_UNIX,
+#define _SC_XOPEN_UNIX _SC_XOPEN_UNIX
+ _SC_XOPEN_CRYPT,
+#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
+ _SC_XOPEN_ENH_I18N,
+#define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N
+ _SC_XOPEN_SHM,
+#define _SC_XOPEN_SHM _SC_XOPEN_SHM
+
+ _SC_2_CHAR_TERM,
+#define _SC_2_CHAR_TERM _SC_2_CHAR_TERM
+ _SC_2_C_VERSION,
+#define _SC_2_C_VERSION _SC_2_C_VERSION
+ _SC_2_UPE,
+#define _SC_2_UPE _SC_2_UPE
+
+ _SC_XOPEN_XPG2,
+#define _SC_XOPEN_XPG2 _SC_XOPEN_XPG2
+ _SC_XOPEN_XPG3,
+#define _SC_XOPEN_XPG3 _SC_XOPEN_XPG3
+ _SC_XOPEN_XPG4,
+#define _SC_XOPEN_XPG4 _SC_XOPEN_XPG4
+
+ _SC_CHAR_BIT,
+#define _SC_CHAR_BIT _SC_CHAR_BIT
+ _SC_CHAR_MAX,
+#define _SC_CHAR_MAX _SC_CHAR_MAX
+ _SC_CHAR_MIN,
+#define _SC_CHAR_MIN _SC_CHAR_MIN
+ _SC_INT_MAX,
+#define _SC_INT_MAX _SC_INT_MAX
+ _SC_INT_MIN,
+#define _SC_INT_MIN _SC_INT_MIN
+ _SC_LONG_BIT,
+#define _SC_LONG_BIT _SC_LONG_BIT
+ _SC_WORD_BIT,
+#define _SC_WORD_BIT _SC_WORD_BIT
+ _SC_MB_LEN_MAX,
+#define _SC_MB_LEN_MAX _SC_MB_LEN_MAX
+ _SC_NZERO,
+#define _SC_NZERO _SC_NZERO
+ _SC_SSIZE_MAX,
+#define _SC_SSIZE_MAX _SC_SSIZE_MAX
+ _SC_SCHAR_MAX,
+#define _SC_SCHAR_MAX _SC_SCHAR_MAX
+ _SC_SCHAR_MIN,
+#define _SC_SCHAR_MIN _SC_SCHAR_MIN
+ _SC_SHRT_MAX,
+#define _SC_SHRT_MAX _SC_SHRT_MAX
+ _SC_SHRT_MIN,
+#define _SC_SHRT_MIN _SC_SHRT_MIN
+ _SC_UCHAR_MAX,
+#define _SC_UCHAR_MAX _SC_UCHAR_MAX
+ _SC_UINT_MAX,
+#define _SC_UINT_MAX _SC_UINT_MAX
+ _SC_ULONG_MAX,
+#define _SC_ULONG_MAX _SC_ULONG_MAX
+ _SC_USHRT_MAX,
+#define _SC_USHRT_MAX _SC_USHRT_MAX
+
+ _SC_NL_ARGMAX,
+#define _SC_NL_ARGMAX _SC_NL_ARGMAX
+ _SC_NL_LANGMAX,
+#define _SC_NL_LANGMAX _SC_NL_LANGMAX
+ _SC_NL_MSGMAX,
+#define _SC_NL_MSGMAX _SC_NL_MSGMAX
+ _SC_NL_NMAX,
+#define _SC_NL_NMAX _SC_NL_NMAX
+ _SC_NL_SETMAX,
+#define _SC_NL_SETMAX _SC_NL_SETMAX
+ _SC_NL_TEXTMAX
+#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX
};
#ifdef __USE_POSIX2
diff --git a/stdlib/div.c b/sysdeps/generic/div.c
index 51f5e35e71..51f5e35e71 100644
--- a/stdlib/div.c
+++ b/sysdeps/generic/div.c
diff --git a/stdlib/ldiv.c b/sysdeps/generic/ldiv.c
index 995e40de39..995e40de39 100644
--- a/stdlib/ldiv.c
+++ b/sysdeps/generic/ldiv.c
diff --git a/stdlib/lldiv.c b/sysdeps/generic/lldiv.c
index 1659e0f837..1659e0f837 100644
--- a/stdlib/lldiv.c
+++ b/sysdeps/generic/lldiv.c
diff --git a/sysdeps/generic/paths.h b/sysdeps/generic/paths.h
index 760ae7cfe0..12e12b3a99 100644
--- a/sysdeps/generic/paths.h
+++ b/sysdeps/generic/paths.h
@@ -56,6 +56,7 @@
#define _PATH_MOUNTED "/var/run/mtab"
#define _PATH_NOLOGIN "/etc/nologin"
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
+#define _PATH_SHADOW "/etc/shadow"
#define _PATH_SHELLS "/etc/shells"
#define _PATH_TTY "/dev/tty"
#define _PATH_UNIX "/vmunix"
diff --git a/sysdeps/generic/sysdep.h b/sysdeps/generic/sysdep.h
index 6b5cc68a6b..014cd1c745 100644
--- a/sysdeps/generic/sysdep.h
+++ b/sysdeps/generic/sysdep.h
@@ -1,21 +1,21 @@
/* Generic asm macros used on many machines.
-Copyright (C) 1991, 92, 93, 96 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ Copyright (C) 1991, 92, 93, 96 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 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.
+ 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. */
+ 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 C_LABEL
@@ -38,4 +38,6 @@ Cambridge, MA 02139, USA. */
/* Mark the end of function named SYM. This is used on some platforms
to generate correct debugging information. */
+#ifndef END
#define END(sym)
+#endif
diff --git a/sysdeps/i386/sysdep.h b/sysdeps/i386/sysdep.h
index a11aa72d22..eea863304f 100644
--- a/sysdeps/i386/sysdep.h
+++ b/sysdeps/i386/sysdep.h
@@ -1,21 +1,21 @@
/* Assembler macros for i386.
-Copyright (C) 1991, 92, 93, 95, 96 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. */
+ Copyright (C) 1991, 92, 93, 95, 96 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 <sysdeps/generic/sysdep.h>
diff --git a/sysdeps/mach/getpagesize.c b/sysdeps/mach/getpagesize.c
index 84f227f04f..725505fee1 100644
--- a/sysdeps/mach/getpagesize.c
+++ b/sysdeps/mach/getpagesize.c
@@ -1,30 +1,27 @@
-/* Copyright (C) 1991, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 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 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.
+ 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. */
+ 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 <ansidecl.h>
-#include <stddef.h>
#include <unistd.h>
-#include <errno.h>
#include <mach.h>
/* Return the system page size. */
-size_t
-DEFUN_VOID(__getpagesize)
+int
+__getpagesize ()
{
return __vm_page_size;
}
diff --git a/sysdeps/mach/hurd/ttyname_r.c b/sysdeps/mach/hurd/ttyname_r.c
index f958dd9e4f..05c2a6f2fa 100644
--- a/sysdeps/mach/hurd/ttyname_r.c
+++ b/sysdeps/mach/hurd/ttyname_r.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <string.h>
@@ -31,13 +31,13 @@ ttyname_r (int fd, char *buf, size_t buflen)
error_t err;
char nodename[1024]; /* XXX */
char *cp;
- int len;
+ size_t len;
nodename[0] = '\0';
if (err = HURD_DPORT_USE (fd, __term_get_nodename (port, nodename)))
return __hurd_dfail (fd, err), -1;
- len = (int) strlen (nodename) + 1;
+ len = strlen (nodename) + 1;
if (len > buflen)
{
errno = EINVAL;
diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c
index 140442fdee..3108a46c21 100644
--- a/sysdeps/posix/cuserid.c
+++ b/sysdeps/posix/cuserid.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <pwd.h>
#include <stdio.h>
@@ -30,9 +30,11 @@ cuserid (s)
char *s;
{
static char name[L_cuserid];
- struct passwd *pwent = getpwuid (geteuid ());
+ char buf[NSS_BUFLEN_PASSWD];
+ struct passwd pwent;
+ struct passwd *pwptr;
- if (pwent == NULL)
+ if (__getpwuid_r (geteuid (), &pwent, buf, sizeof (buf), &pwptr))
{
if (s != NULL)
s[0] = '\0';
@@ -41,5 +43,5 @@ cuserid (s)
if (s == NULL)
s = name;
- return strcpy (s, pwent->pw_name);
+ return strncpy (s, pwptr->pw_name, L_cuserid);
}
diff --git a/sysdeps/posix/getpagesize.c b/sysdeps/posix/getpagesize.c
index 4deb208633..6b2082e926 100644
--- a/sysdeps/posix/getpagesize.c
+++ b/sysdeps/posix/getpagesize.c
@@ -1,29 +1,27 @@
-/* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
Contributed by Brendan Kehoe (brendan@cygnus.com).
-The GNU C Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+ The GNU C Library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, 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 General Public License for more details.
+ 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 General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with the GNU C Library; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 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 <ansidecl.h>
-#include <stddef.h>
#include <unistd.h>
-extern long int EXFUN(__sysconf, (int));
-
/* Return the system page size. */
-size_t
-DEFUN_VOID(__getpagesize)
+int
+__getpagesize (void)
{
return __sysconf (_SC_PAGESIZE);
}
diff --git a/sysdeps/posix/mkstemp.c b/sysdeps/posix/mkstemp.c
index 920136d416..6daba79266 100644
--- a/sysdeps/posix/mkstemp.c
+++ b/sysdeps/posix/mkstemp.c
@@ -1,21 +1,22 @@
/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
diff --git a/sysdeps/posix/mktemp.c b/sysdeps/posix/mktemp.c
index 111206f663..f7a1783c8f 100644
--- a/sysdeps/posix/mktemp.c
+++ b/sysdeps/posix/mktemp.c
@@ -1,21 +1,22 @@
/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
index 9660724a39..8dde095b79 100644
--- a/sysdeps/posix/sysconf.c
+++ b/sysdeps/posix/sysconf.c
@@ -1,20 +1,20 @@
/* Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ 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 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.
+ 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. */
+ 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 <limits.h>
@@ -26,8 +26,6 @@ Cambridge, MA 02139, USA. */
#include <unistd.h>
#include <sys/sysinfo.h>
-extern int __getdtablesize __P ((void));
-extern size_t __getpagesize __P ((void));
/* Get the value of the system variable NAME. */
long int
@@ -463,6 +461,13 @@ __sysconf (name)
return -1;
#endif
+ case _SC_2_C_VERSION:
+#ifdef _POSIX2_C_VERSION
+ return _POSIX2_C_VERSION;
+#else
+ return -1;
+#endif
+
case _SC_2_FORT_DEV:
#ifdef _POSIX2_FORT_DEV
return _POSIX2_FORT_DEV;
@@ -484,6 +489,20 @@ __sysconf (name)
return -1;
#endif
+ case _SC_2_CHAR_TERM:
+#ifdef _POSIX2_CHAR_TERM
+ return _POSIX2_CHAR_TERM;
+#else
+ return -1;
+#endif
+
+ case _SC_2_UPE:
+#ifdef _POSIX2_UPE
+ return _POSIX2_UPE;
+#else
+ return -1;
+#endif
+
/* POSIX 1003.1c (POSIX Threads). */
case _SC_THREADS:
#ifdef _POSIX_THREADS
@@ -620,6 +639,150 @@ __sysconf (name)
case _SC_XOPEN_VERSION:
return _XOPEN_VERSION;
+
+ case _SC_XOPEN_XCU_VERSION:
+ return _XOPEN_XCU_VERSION;
+
+ case _SC_XOPEN_UNIX:
+ return _XOPEN_UNIX;
+
+ case _SC_XOPEN_CRYPT:
+#ifdef _XOPEN_CRYPT
+ return _XOPEN_CRYPT;
+#else
+ return -1;
+#endif
+
+ case _SC_XOPEN_ENH_I18N:
+#ifdef _XOPEN_ENH_I18N
+ return _XOPEN_ENH_I18N;
+#else
+ return -1;
+#endif
+
+ case _SC_XOPEN_SHM:
+#ifdef _XOPEN_SHM
+ return _XOPEN_SHM;
+#else
+ return -1;
+#endif
+
+ case _SC_XOPEN_XPG2:
+#ifdef _XOPEN_XPG2
+ return _XOPEN_XPG2;
+#else
+ return -1;
+#endif
+
+ case _SC_XOPEN_XPG3:
+#ifdef _XOPEN_XPG3
+ return _XOPEN_XPG3;
+#else
+ return -1;
+#endif
+
+ case _SC_XOPEN_XPG4:
+#ifdef _XOPEN_XPG4
+ return _XOPEN_XPG4;
+#else
+ return -1;
+#endif
+
+ case _SC_CHAR_BIT:
+ return CHAR_BIT;
+
+ case _SC_CHAR_MAX:
+ return CHAR_MAX;
+
+ case _SC_CHAR_MIN:
+ return CHAR_MIN;
+
+ case _SC_INT_MAX:
+ return INT_MAX;
+
+ case _SC_INT_MIN:
+ return INT_MIN;
+
+ case _SC_LONG_BIT:
+ return sizeof (long int) * CHAR_BIT;
+
+ case _SC_WORD_BIT:
+ return sizeof (int) * CHAR_BIT;
+
+ case _SC_MB_LEN_MAX:
+ return MB_LEN_MAX;
+
+ case _SC_NZERO:
+ return NZERO;
+
+ case _SC_SSIZE_MAX:
+ return _POSIX_SSIZE_MAX;
+
+ case _SC_SCHAR_MAX:
+ return SCHAR_MAX;
+
+ case _SC_SCHAR_MIN:
+ return SCHAR_MIN;
+
+ case _SC_SHRT_MAX:
+ return SHRT_MAX;
+
+ case _SC_SHRT_MIN:
+ return SHRT_MIN;
+
+ case _SC_UCHAR_MAX:
+ return UCHAR_MAX;
+
+ case _SC_UINT_MAX:
+ return UINT_MAX;
+
+ case _SC_ULONG_MAX:
+ return ULONG_MAX;
+
+ case _SC_USHRT_MAX:
+ return USHRT_MAX;
+
+ case _SC_NL_ARGMAX:
+#ifdef NL_ARGMAX
+ return NL_ARGMAX;
+#else
+ return -1;
+#endif
+
+ case _SC_NL_LANGMAX:
+#ifdef NL_LANGMAX
+ return NL_LANGMAX;
+#else
+ return -1;
+#endif
+
+ case _SC_NL_MSGMAX:
+#ifdef NL_MSGMAX
+ return NL_MSGMAX;
+#else
+ return -1;
+#endif
+
+ case _SC_NL_NMAX:
+#ifdef NL_NMAX
+ return NL_NMAX;
+#else
+ return -1;
+#endif
+
+ case _SC_NL_SETMAX:
+#ifdef NL_SETMAX
+ return NL_SETMAX;
+#else
+ return -1;
+#endif
+
+ case _SC_NL_TEXTMAX:
+#ifdef NL_TEXTMAX
+ return NL_TEXTMAX;
+#else
+ return -1;
+#endif
}
}
diff --git a/xopen_lim.h b/xopen_lim.h
new file mode 100644
index 0000000000..04a11ba320
--- /dev/null
+++ b/xopen_lim.h
@@ -0,0 +1,90 @@
+/* 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. */
+
+/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2
+ System Interfaces and Headers, 4.16 <limits.h>
+
+ Please note only the values which are not greater than the minimum
+ stated in the standard document are listed. The `sysconf' functions
+ should be used to obtain the actual value. */
+
+#ifndef _XOPEN_LIM_H
+
+#define _XOPEN_LIM_H 1
+
+/* We do not provide fixed values for
+
+ ARG_MAX Maximum length of argument to the `exec' function
+ including environment data.
+
+ ATEXIT_MAX Maximum number of functions that may be registered
+ with `atexit'.
+
+ CHILD_MAX Maximum number of simultaneous processes per real
+ user ID.
+
+ OPEN_MAX Maximum number of files that one process can have open
+ at anyone time.
+
+ PAGESIZE
+ PAGE_SIZE Size of bytes of a page.
+
+ PASS_MAX Maximum number of significant bytes in a password.
+*/
+
+
+/* Maximum number of `iovec' structures that one process has available
+ for use with `readv' or writev'. */
+#define IOV_MAX _XOPEN_IOV_MAX
+
+/* The number of streams that one process can have open at one time. */
+#define STREAM_MAX _POSIX_STREAM_MAX
+
+/* Maximum number of bytes supported for the name of a time zone. */
+#define TZNAME_MAX _POSIX_TZNAME_MAX
+
+
+/* Maximum number of `iovec' structures that one process has available
+ for use with `readv' or writev'. */
+#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV
+
+
+/* Maximum value of `digit' in calls to the `printf' and `scanf'
+ functions. We have no limit, so return a reasonable value. */
+#define NL_ARGMAX _POSIX_ARG_MAX
+
+/* Maximum number of bytes in a `LANG' name. We have no limit. */
+#define NL_LANGMAX _POSIX2_LINE_MAX
+
+/* Maximum message number. We have no limit. */
+#define NL_MSGMAX INT_MAX
+
+/* Maximum number of bytes in N-to-1 collation mapping. We have no
+ limit. */
+#define NL_NMAX INT_MAX
+
+/* Maximum set number. We have no limit. */
+#define NL_SETMAX INT_MAX
+
+/* Maximum number of bytes in a message. We have no limit. */
+#define NL_TEXTMAX INT_MAX
+
+/* Default process priority. */
+#define NZERO 20
+
+#endif /* xopen_lim.h */