aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog222
-rw-r--r--Makefile12
-rw-r--r--catgets/gencat.c11
-rw-r--r--db/makedb.c13
-rw-r--r--elf/ldd.bash.in46
-rw-r--r--elf/ldd.sh.in41
-rw-r--r--elf/rtld.c4
-rw-r--r--features.h19
-rw-r--r--glibcbug.in2
-rw-r--r--isomac.c320
-rw-r--r--libio/clearerr.c6
-rw-r--r--libio/feof.c8
-rw-r--r--libio/ferror.c5
-rw-r--r--libio/fileno.c1
-rw-r--r--libio/fputc.c2
-rw-r--r--libio/getc.c6
-rw-r--r--libio/getchar.c6
-rw-r--r--libio/iofflush.c4
-rw-r--r--libio/putc.c34
-rw-r--r--libio/putchar.c34
-rw-r--r--libio/stdio.h740
-rw-r--r--locale/C-time.c3
-rw-r--r--locale/programs/locale.c10
-rw-r--r--locale/programs/localedef.c7
-rw-r--r--malloc/malloc.c162
-rw-r--r--malloc/malloc.h7
-rw-r--r--malloc/thread-m.h36
-rw-r--r--manual/stdio-fp.c28
-rw-r--r--manual/stdio.texi55
-rw-r--r--math/math.h11
-rw-r--r--misc/error.c13
-rw-r--r--misc/sys/cdefs.h7
-rwxr-xr-xrellns-sh8
-rw-r--r--stdio-common/Makefile2
-rw-r--r--stdio-common/printf_fp.c10
-rw-r--r--stdio-common/printf_fphex.c440
-rw-r--r--stdio-common/tstscanf.c10
-rw-r--r--stdio-common/vfprintf.c86
-rw-r--r--stdio-common/vfscanf.c4
-rw-r--r--stdio/stdio.h69
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/stdlib.h155
-rw-r--r--stdlib/strtod.c52
-rw-r--r--stdlib/strtof.c2
-rw-r--r--stdlib/strtol.c16
-rw-r--r--stdlib/strtold.c2
-rw-r--r--stdlib/strtoll.c (renamed from stdlib/strtoq.c)2
-rw-r--r--stdlib/strtoull.c (renamed from stdlib/strtouq.c)2
-rw-r--r--stdlib/tst-strtol.c4
-rw-r--r--string/string.h22
-rw-r--r--sysdeps/ieee754/huge_val.h40
-rw-r--r--sysdeps/libm-ieee754/s_cbrtl.c2
-rw-r--r--sysdeps/posix/gai_strerror.c2
-rw-r--r--sysdeps/unix/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/accept.S1
-rw-r--r--sysdeps/unix/sysv/linux/bind.S1
-rw-r--r--sysdeps/unix/sysv/linux/connect.S1
-rw-r--r--sysdeps/unix/sysv/linux/getpeername.S1
-rw-r--r--sysdeps/unix/sysv/linux/getsockname.S1
-rw-r--r--sysdeps/unix/sysv/linux/getsockopt.S1
-rw-r--r--sysdeps/unix/sysv/linux/i386/socket.S34
-rw-r--r--sysdeps/unix/sysv/linux/listen.S1
-rw-r--r--sysdeps/unix/sysv/linux/recv.S1
-rw-r--r--sysdeps/unix/sysv/linux/recvfrom.S1
-rw-r--r--sysdeps/unix/sysv/linux/recvmsg.S1
-rw-r--r--sysdeps/unix/sysv/linux/send.S1
-rw-r--r--sysdeps/unix/sysv/linux/sendmsg.S1
-rw-r--r--sysdeps/unix/sysv/linux/sendto.S1
-rw-r--r--sysdeps/unix/sysv/linux/setsockopt.S1
-rw-r--r--sysdeps/unix/sysv/linux/shutdown.S1
-rw-r--r--sysdeps/unix/sysv/linux/socketpair.S1
-rw-r--r--sysdeps/unix/sysv/linux/timebits.h6
-rw-r--r--time/time.h5
-rw-r--r--wcsmbs/Makefile9
-rw-r--r--wcsmbs/wchar.h236
-rw-r--r--wcsmbs/wcscasecmp.c56
-rw-r--r--wcsmbs/wcsncase.c55
-rw-r--r--wcsmbs/wcstof.c2
-rw-r--r--wcsmbs/wcstold.c2
-rw-r--r--wcsmbs/wcstoll.c (renamed from wcsmbs/wcstoq.c)2
-rw-r--r--wcsmbs/wcstoull.c (renamed from wcsmbs/wcstouq.c)2
81 files changed, 2560 insertions, 674 deletions
diff --git a/ChangeLog b/ChangeLog
index 58f22b6917..c6bc83d747 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,168 @@
-Fri Feb 21 00:22:28 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-24 23:05 Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>
+
+ * malloc/malloc.c (malloc_get_state): New function.
+ Saves global malloc state to an opaque data structure which
+ is dynamically allocated in the heap.
+ * malloc/malloc.c (malloc_set_state): New function.
+ Restore previously obtained state.
+ * malloc/malloc.h: Add declaration of malloc_get_state()
+ and malloc_set_state().
+
+1997-02-24 23:27 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/libm-ieee754/s_cbrtl.c: Shift B1_EXP value to right
+ position.
+
+1997-02-24 17:38 Ulrich Drepper <drepper@cygnus.com>
+
+ * misc/error.c: Make error and error_at_line weak aliases of
+ __error and __error_at_line respectively.
+ Suggested by David Mosberger-Tang <davidm@AZStarNet.COM>.
+
+ * sysdeps/unix/sysv/linux/i386/socket.S: Update copyright.
+
+1997-02-22 11:30 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * elf/ldd.bash.in: Run the program directly, not as argument
+ to the dynamic linker, if it contains an interpreter segment.
+ * elf/ldd.sh.in: Likewise.
+
+ * elf/rtld.c (dl_main): In verify mode check whether the dynamic
+ object contains an interpreter segment and exit with 2 if not.
+
+1997-02-23 01:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makefile (distribute): Remove nsswitch.h, netgroup.h, mcheck.h
+ and xlocale.h. Make-dist adds them automagically.
+
+1997-02-22 12:25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * locale/C-time.c (_nl_C_LC_TIME): Add missing entry for
+ time-era-num-entries.
+
+1997-02-06 13:49 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * rellns-sh: No need to check for existance of first parameter.
+
+1997-02-24 15:20 Jonathan T. Agnew <jtagnew@amherst.edu>
+
+ * glibcbug.in: Don't mention destination on MAIL_AGENT command line
+ to avoid duplicate mail.
+
+1997-02-24 03:51 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile (distribute): Add isomac.c.
+ (tests): Run isomac test.
+
+ * features.h (__USE_ISOC9X): New macro.
+
+ * catgets/catgets.c: Don't use global variable `optind'. Instead
+ use result computed by argp_parse.
+ * db/makedb: Likewise.
+ * locale/programs/locale.c: Likewise.
+ * locale/programs/localedef.c: Likewise.
+
+ * libio/stdio.h: Rewrite. Make it more readable and add comments.
+
+ * libio/clearerr.c: Remove clearerr_locked alias.
+ * libio/feof.c: Remove feof_locked alias.
+ * libio/ferror.c: Remove feof_locked alias.
+ * libio/fileno.c: Remove fileno_locked alias.
+ * libio/fputc.c: Remove fputc_locked alias.
+ * libio/getc.c: Remove getc_locked alias.
+ * libio/getchar.c: Remove getchar_locked alias.
+ * libio/iofflush.c: Remove fflush_locked alias.
+ * libio/putc.c: Remove putc_locked alias.
+ * libio/putc.c: Remove putchar_locked alias.
+
+ * stdio-common/printf_fp.c: When number is inifinity print INF
+ or inf depending on case of specifier. Same for NaN where NAN
+ or nan is printed. Specified in ISO C 9X.
+
+ * misc/sys/cdefs.h (__restrict): Define to empty string for now.
+ * stdio/stdio.h: Add __restrict to prototypes where necessary.
+ * libio/stdio.h: Likewise.
+ * stdlib/stdlib.h: Likewise.
+ * string/string.h: Likewise.
+ * time/time.h: Likewise.
+ * wcsmbs/wchar.h: Likewise.
+
+ * stdlib/strtod.c: Change to recognize INF, INFINITY, NAN, and
+ NAN(...).
+
+ * sysdeps/ieee754/huge_val.h: Define HUGE_VALF and HUGE_VALL instead
+ of HUGE_VALf and HUGE_VALL.
+ * stdlib/strtof.c (FLOAT_HUGE_VAL): Use standard name HUGE_VALF
+ instead of HUGE_VALf.
+ * wcsmbs/wcstof.c: Likewise.
+ * stdlib/strtold.c (FLOAT_HUGE_VAL): Use standard name HUGE_VALL
+ instead of HUGE_VALl.
+ * wcsmbs/wcstold.c: Likewise.
+
+ * sysdeps/posix/gai_strerror.c: Use size_t for counter variable to
+ avoid warning.
+
+ * wcsmbs/Makefile (routines): Add wcscasecmp and wcsncase.
+ * wcsmbs/wchar.h: Add prototypes for wcscasecmp and wcsncase.
+ * wcsmbs/wcscasecmp.c: New file.
+ * wcsmbs/wcsncase.c: New file.
+
+ * stdlib/strtol.c: Define wide character quad word functions as
+ wcstoll and wcstoull and normal versions as strtoll and strtoull.
+ * wcsmbs/wchar.h: Add prototypes for wcstoll and wcstoull.
+ * wcsmbs/wcstoq: Renamed to wcstoll.c.
+ * wcsmbs/wcstouq: Renamed to wcstoull.c.
+ * wcsmbs/wcstoll.c: Renamed from wcstoq.c. Make wcstoq a weak
+ alias of wcstoll.
+ * wcsmbs/wcstoull.c: Renamed from wcstouq.c. Make wcstouq a weak
+ alias of wcstoull.
+ * wcsmbs/Makefile (routines): Replace wcstoq and wcstouq by
+ wcstoll and wcstoull respectively.
+ * stdlib/strtoq.c: Rename to strtoll.c.
+ * stdlib/strtouq.c: Rename to strtoull.c.
+ * stdlib/strtoll.c: Renamed from strtoq.c. Make strtoq a weak
+ alias of strtoll.
+ * stdlib/strtoll.c: Renamed from strtouq.c. Make strtouq a weak
+ alias of strtoull.
+ * stdlib/Makefile (routines): Replace strtoq and strtouq by
+ strtoll and strtoull respectively.
+ * stdio-common/vfscanf.c: Don't use __strtoq_internal and
+ __strtouq_internal but instead __strtoll_internal and
+ __strtoull_internal respectively.
+ * stdlib/stdlib.h (strtoq): Use __internal_strtoll in inline version.
+ (strtouq): Similar with __internal_strtoull.
+ * wcsmbs/wchar.h (wcstoq): Use __internal_wcstoll in inline version.
+ (wcstouq): Similar with __internal_wcstoull.
+
+1997-02-23 04:38 Ulrich Drepper <drepper@cygnus.com>
+
+ * stdlib/strtol.c (STRTOL): It is not illegal to parse a minus
+ sign in the strtouXX functions. The results gets simply negated.
+ * stdio-common/tstscanf.c: Add testcase for above case.
+ * stdlib/tst-strtol.c: Correct tests.
+
+ * manual/stdio-fp.c: New file. Generate output for example program
+ in stdio.texi.
+
+ * stdio-common/Makefile (routines): Add printf_fphex.
+ * stdio-common/vfprintf.c: Add handling of %a and %A specifier.
+ * stdio-common/printf_fphex.c: New file. Implement %a and %A
+ specifier.
+
+1997-02-22 03:01 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/timebits.h (CLK_TCK): Don't defined if
+ __STRICT_ANSI__.
+
+ * math/math.h: Prevent definition of struct exception when using
+ C++.
+
+1997-02-22 01:45 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/syscalls.list: Dup takes only one argument.
+ Reported by Greg McGary.
+
+1997-02-21 00:22 Miles Bader <miles@gnu.ai.mit.edu>
* sysdeps/mach/hurd/readlink.c (__readlink): Use io_read rather
than file_get_translator.
@@ -6,12 +170,12 @@ Fri Feb 21 00:22:28 1997 Miles Bader <miles@gnu.ai.mit.edu>
* sysdeps/mach/hurd/defs.c, sysdeps/stub/defs.c, sysdeps/posix/defs.c
(_cleanup): Use __fcloseall instead of fclose with a NULL stream.
-Thu Feb 20 01:28:39 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-20 01:28 Miles Bader <miles@gnu.ai.mit.edu>
* hurd/fchroot.c (fchroot): Reparent DIR to make it a real root.
* sysdeps/mach/hurd/chroot.c (chroot): Likewise.
-Wed Feb 19 13:56:04 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-19 13:56 Miles Bader <miles@gnu.ai.mit.edu>
* sysdeps/mach/hurd/accept.c (accept): Don't segv if ADDR_LEN == 0
but ADDR also == 0.
@@ -20,7 +184,7 @@ Wed Feb 19 13:56:04 1997 Miles Bader <miles@gnu.ai.mit.edu>
now instead of a weak extern, as some old programs expect it to be
defined by ld.so.
-Tue Feb 18 15:39:08 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-18 15:39 Miles Bader <miles@gnu.ai.mit.edu>
* hurd/hurdfault.c (_hurdsig_fault_preempter): New weak alias.
@@ -30,7 +194,7 @@ Tue Feb 18 15:39:08 1997 Miles Bader <miles@gnu.ai.mit.edu>
* malloc/thread-m.h (mutex_trylock): Invert sense of return value.
-Mon Feb 17 10:58:14 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-17 10:58 Miles Bader <miles@gnu.ai.mit.edu>
* malloc/thread-m.h (mutex_trylock): Define to be __mutex_trylock,
not __mutex_try_lock.
@@ -40,24 +204,26 @@ Mon Feb 17 10:58:14 1997 Miles Bader <miles@gnu.ai.mit.edu>
* hurd/hurdinit.c (__libc_argv): Remove extern.
(__libc_argc): New variable.
-Sat Feb 15 10:23:32 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-15 10:23 Miles Bader <miles@gnu.ai.mit.edu>
* hurd/hurd/threadvar.h (enum __hurd_threadvar_index): Add
_HURD_THREADVAR_MALLOC.
* malloc/thread-m.h
[_LIBC && !PTHREAD_MUTEX_INITIALIZER && MUTEX_INITIALIZER]
- (__x_mutex_lock, __x_mutex_unlock): Functions removed.
- (mutex_lock, mutex_unlock): Defined in terms of __mutex_*.
- (tsd_key_create, tsd_setspecific, tsd_setspecific): Change to
- hurd-specific definitions, using __hurd_threadvar_location.
+ (mutex_lock, mutex_unlock, mutex_trylock): Defined in terms of
+ __mutex_*.
+ (mutex_t): Type removed & replaced by new macro.
+ (tsd_key_t): Typedef to int instead of pthread_key_t.
+ (tsd_key_create, tsd_setspecific, tsd_getspecific): New macros.
+ (__pthread_initialize): New macro, work around assumption of pthreads.
(tsd_keys_alloced): New static variable.
<hurd/threadvar.h>: New include.
-
+
* hurd/report-wait.c (_hurd_itimer_thread): Make a weak extern.
(_S_msg_report_wait): Check to see if _hurd_itimer_thread is
defined before using it.
- * sysdeps/mach/hurd/i386/init-first.c (__libc_argv, __libc_argc):
+ * sysdeps/mach/hurd/i386/init-first.c (__libc_argv, __libc_argc):
Make extern.
* hurd/hurdinit.c (__libc_argv): Make extern.
@@ -76,13 +242,13 @@ Sat Feb 15 10:23:32 1997 Miles Bader <miles@gnu.ai.mit.edu>
(__hurd_threadvar_max, __hurd_threadvar_stack_offset,
__hurd_threadvar_stack_mask): Variables removed.
* sysdeps/mach/hurd/dl-sysdep.c (__hurd_sigthread_stack_base,
- __hurd_sigthread_stack_end, __hurd_sigthread_stack_variables,
- __hurd_threadvar_max, __hurd_threadvar_stack_offset,
- __hurd_threadvar_stack_mask): Variables removed.
+ __hurd_sigthread_stack_end, __hurd_sigthread_stack_variables,
+ __hurd_threadvar_max, __hurd_threadvar_stack_offset,
+ __hurd_threadvar_stack_mask): Variables removed.
-Fri Feb 14 14:07:19 1997 Miles Bader <miles@gnu.ai.mit.edu>
+1997-02-14 14:07 Miles Bader <miles@gnu.ai.mit.edu>
- * hurd/hurd.h (_hurd_pids_changed_stamp, _hurd_pids_changed_sync):
+ * hurd/hurd.h (_hurd_pids_changed_stamp, _hurd_pids_changed_sync):
Declare extern.
* malloc/thread-m.h
@@ -103,6 +269,26 @@ Fri Feb 14 14:07:19 1997 Miles Bader <miles@gnu.ai.mit.edu>
* locale/weight.h (collate_rules): It's an u_int32_t array.
(get_weight): Compute initial SLOT value correctly.
+1997-02-24 17:06 Geoffrey Keating <geoffk@discus.anu.edu.au>
+
+ * sysdeps/unix/sysv/linux/accept.S (NARGS): Describe number of
+ arguments taken, for sysdeps/unix/sysv/linux/powerpc/socket.S.
+ * sysdeps/unix/sysv/linux/bind.S: Likewise.
+ * sysdeps/unix/sysv/linux/connect.S: Likewise.
+ * sysdeps/unix/sysv/linux/getpeername.S: Likewise.
+ * sysdeps/unix/sysv/linux/getsockname.S: Likewise.
+ * sysdeps/unix/sysv/linux/getsockopt.S: Likewise.
+ * sysdeps/unix/sysv/linux/listen.S: Likewise.
+ * sysdeps/unix/sysv/linux/recv.S: Likewise.
+ * sysdeps/unix/sysv/linux/recvfrom.S: Likewise.
+ * sysdeps/unix/sysv/linux/recvmsg.S: Likewise.
+ * sysdeps/unix/sysv/linux/send.S: Likewise.
+ * sysdeps/unix/sysv/linux/sendmsg.S: Likewise.
+ * sysdeps/unix/sysv/linux/sendto.S: Likewise.
+ * sysdeps/unix/sysv/linux/setsockopt.S: Likewise.
+ * sysdeps/unix/sysv/linux/shutdown.S: Likewise.
+ * sysdeps/unix/sysv/linux/socketpair.S: Likewise.
+
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
@@ -436,7 +622,7 @@ Fri Feb 14 14:07:19 1997 Miles Bader <miles@gnu.ai.mit.edu>
trying to resolv name as numeric IPv6 address.
* nss/digits_dots.c: Likewise.
-Sat Feb 15 04:51:08 1997 Ulrich Drepper <drepper@cygnus.com>
+1997-02-15 04:51 Ulrich Drepper <drepper@cygnus.com>
* locale/setlocale.c (setlocale): Don't try to be clever about
unused locales. When the existence of the locale files isn't
diff --git a/Makefile b/Makefile
index 2d3762a00f..02e87d0ce7 100644
--- a/Makefile
+++ b/Makefile
@@ -277,19 +277,25 @@ parent_echo-distinfo:
$(addprefix +nodist+,$(generated))
+# Run a test on the header files we use.
+tests: $(objpfx)isomac
+ $(objpfx)isomac $(CC) '$(+sysdep-includes)' >$(common-objpfx)isomac.out
+
+$(objpfx)isomac: isomac.c
+ $(native-compile)
+
# Make the distribution tarfile.
distribute := README INSTALL FAQ NOTES NEWS PROJECTS \
COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
- extra-lib.mk o-iterator.mk \
+ extra-lib.mk o-iterator.mk isomac.c \
ansidecl.h mkinstalldirs move-if-change install-sh \
configure configure.in aclocal.m4 config.sub config.guess\
config.h.in config.make.in config-name.in Makefile.in \
autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
- rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h \
- mcheck.h glibcbug.in xlocale.h
+ rpm/Makefile rpm/template rpm/rpmrc glibcbug.in
distribute := $(strip $(distribute))
generated := $(generated) stubs.h version-info.h
diff --git a/catgets/gencat.c b/catgets/gencat.c
index 9f1e762f53..bee101eb74 100644
--- a/catgets/gencat.c
+++ b/catgets/gencat.c
@@ -152,6 +152,7 @@ int
main (int argc, char *argv[])
{
struct catalog *result;
+ int remaining;
/* Set program name for messages. */
error_print_progname = error_print;
@@ -166,18 +167,18 @@ main (int argc, char *argv[])
result = NULL;
/* Parse and process arguments. */
- argp_parse (&argp, argc, argv, 0, 0, NULL);
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
/* Determine output file. */
if (output_name == NULL)
- output_name = optind < argc ? argv[optind++] : "-";
+ output_name = remaining < argc ? argv[remaining++] : "-";
/* Process all input files. */
setlocale (LC_CTYPE, "C");
- if (optind < argc)
+ if (remaining < argc)
do
- result = read_input_file (result, argv[optind]);
- while (++optind < argc);
+ result = read_input_file (result, argv[remaining]);
+ while (++remaining < argc);
else
result = read_input_file (NULL, "-");
diff --git a/db/makedb.c b/db/makedb.c
index 9f84ea39fc..32029fbbc6 100644
--- a/db/makedb.c
+++ b/db/makedb.c
@@ -99,6 +99,7 @@ main (argc, argv)
FILE *input_file;
DB *db_file;
int status;
+ int remaining;
/* Set locale via LC_ALL. */
setlocale (LC_ALL, "");
@@ -110,27 +111,27 @@ main (argc, argv)
input_name = NULL;
/* Parse and process arguments. */
- argp_parse (&argp, argc, argv, 0, 0, NULL);
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
/* Determine file names. */
if (do_undo || output_name != NULL)
{
- if (optind + 1 != argc)
+ if (remaining + 1 != argc)
{
wrong_arguments:
error (0, 0, gettext ("wrong number of arguments"));
argp_help (&argp, stdout, ARGP_HELP_SEE,
program_invocation_short_name);
}
- input_name = argv[optind];
+ input_name = argv[remaining];
}
else
{
- if (optind + 2 != argc)
+ if (remaining + 2 != argc)
goto wrong_arguments;
- input_name = argv[optind++];
- output_name = argv[optind];
+ input_name = argv[remaining++];
+ output_name = argv[remaining];
}
/* Special handling if we are asked to print the database. */
diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
index dd4fc6ab96..48d5c90fd5 100644
--- a/elf/ldd.bash.in
+++ b/elf/ldd.bash.in
@@ -69,6 +69,7 @@ Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>."
esac
done
+add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
case $# in
0)
echo >&2 $"ldd: missing file arguments"
@@ -86,20 +87,29 @@ case $# in
elif test -r "$file"; then
test -x "$file" ||
echo $"ldd: warning: you do not have execution permission for" "\`$file'"
- if ${RTLD} --verify "$file"; then
- LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \
- exec ${RTLD} ${RELOCS} "$file" || exit 1
- else
- echo $" not a dynamic executable"
- exit 1
- fi
+ ${RTLD} --verify "$file"
+ case $? in
+ 0)
+ eval $add_env exec '"$file"' || exit 1
+ ;;
+ 1)
+ echo $" not a dynamic executable"
+ exit 1
+ ;;
+ 2)
+ eval $add_env exec \${RTLD} '"$file"' || exit 1
+ ;;
+ *)
+ echo $"ldd: ${RTLD} exited with unknown exit code ($?)" >&2
+ exit 1
+ ;;
+ esac
else
echo $"ldd: error: you do not have read permission for" "\`$file'"
exit 1
fi
exit ;;
*)
- set -e # Bail out immediately if ${RTLD} loses on any argument.
result=0
for file; do
echo "${file}:"
@@ -113,13 +123,23 @@ case $# in
elif test -r "$file"; then
test -x "$file" || echo $"\
ldd: warning: you do not have execution permission for" "\`$file'"
- if ${RTLD} --verify "$file"; then
- LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \
- ${RTLD} ${RELOCS} "$file" || result=1
- else
+ ${RTLD} --verify "$file"
+ case $? in
+ 0)
+ eval $add_env '"$file"' || result=1
+ ;;
+ 1)
echo $" not a dynamic executable"
result=1
- fi
+ ;;
+ 2)
+ eval $add_env ${RTLD} '"$file"' || result=1
+ ;;
+ *)
+ echo $"ldd: ${RTLD} exited with unknown exit code ($?)" >&2
+ exit 1
+ ;;
+ esac
else
echo $"ldd: error: you do not have read permission for" "\`$file'"
result=1
diff --git a/elf/ldd.sh.in b/elf/ldd.sh.in
index 0f3ed2e729..d5dd54a536 100644
--- a/elf/ldd.sh.in
+++ b/elf/ldd.sh.in
@@ -66,6 +66,7 @@ Try \`ldd --help' for more information."
esac
done
+add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
case $# in
0)
echo >&2 "\
@@ -85,13 +86,23 @@ Try \`ldd --help' for more information."
if test -r "$file"; then
test -x "$file" ||
echo "ldd: warning: you do not have execution permission for \`$file'"
- if ${RTLD} --verify "$file"; then
- LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \
- exec ${RTLD} "$file" || exit 1
- else
+ ${RTLD} --verify "$file"
+ case $? in
+ 0)
+ eval $add_env exec '"$file"' || exit 1
+ ;;
+ 1)
echo ' not a dynamic executable'
exit 1
- fi
+ ;;
+ 2)
+ eval $add_env exec \${RTLD} '"$file"' || exit 1
+ ;;
+ *)
+ echo "ldd: ${RTLD} exited with unknown exit code ($?)" >&2
+ exit 1
+ ;;
+ esac
else
echo "ldd: error: you do not have read permission for \`$file'"
exit 1
@@ -114,13 +125,23 @@ Try \`ldd --help' for more information."
if test -r "$file"; then
test -x "$file" || echo "\
ldd: warning: you do not have execution permission for \`$file'"
- if ${RTLD} --verify "$file"; then
- LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now \
- ${RTLD} "$file" || result=1
- else
+ ${RTLD} --verify "$file"
+ case $? in
+ 0)
+ eval $add_env '"$file"' || result=1
+ ;;
+ 1)
echo ' not a dynamic executable'
result=1
- fi
+ ;;
+ 2)
+ eval $add_env ${RTLD} '"$file"' || result=1
+ ;;
+ *)
+ echo "ldd: ${RTLD} exited with unknown exit code ($?)" >&2
+ exit 1
+ ;;
+ esac
else
echo "ldd: error: you do not have read permission for \`$file'"
result=1
diff --git a/elf/rtld.c b/elf/rtld.c
index 26cacef894..eb7b3bec2a 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -155,6 +155,7 @@ dl_main (const ElfW(Phdr) *phdr,
const char *preloadlist;
size_t file_size;
char *file;
+ int has_interp = 0;
mode = getenv ("LD_TRACE_LOADED_OBJECTS") != NULL ? trace : normal;
@@ -299,6 +300,7 @@ of this helper program; chances are you did not intend to run this program.\n",
_dl_rtld_libname.name = (const char *) l->l_addr + ph->p_vaddr;
_dl_rtld_libname.next = NULL;
_dl_rtld_map.l_libname = &_dl_rtld_libname;
+ has_interp = 1;
break;
}
if (! _dl_rtld_map.l_libname && _dl_rtld_map.l_name)
@@ -315,7 +317,7 @@ of this helper program; chances are you did not intend to run this program.\n",
if (mode == verify)
/* We were called just to verify that this is a dynamic executable
using us as the program interpreter. */
- _exit (l->l_ld == NULL ? EXIT_FAILURE : EXIT_SUCCESS);
+ _exit (l->l_ld == NULL ? 1 : has_interp ? 0 : 2);
/* Extract the contents of the dynamic section for easy access. */
elf_get_dynamic_info (l->l_ld, l->l_info);
diff --git a/features.h b/features.h
index 9baaa053fa..a14179b6a3 100644
--- a/features.h
+++ b/features.h
@@ -24,6 +24,7 @@
to specify the desired environment:
__STRICT_ANSI__ ISO Standard C.
+ _ISOC9X_SOURCE Extensions to ISO C 89 from ISO C 9x.
_POSIX_SOURCE IEEE Std 1003.1.
_POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
if >=199309L, add IEEE Std 1003.1b-1993
@@ -44,6 +45,7 @@
These are defined by this file and are used by the
header files to decide what to declare or define:
+ __USE_ISOC9X Define ISO C 9X things.
__USE_POSIX Define IEEE Std 1003.1 things.
__USE_POSIX2 Define IEEE Std 1003.2 things.
__USE_POSIX199309 Define IEEE Std 1003.1b things.
@@ -69,6 +71,7 @@
/* Undefine everything, so we get a clean slate. */
+#undef __USE_ISOC9X
#undef __USE_POSIX
#undef __USE_POSIX2
#undef __USE_POSIX199309
@@ -102,6 +105,8 @@
/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
#ifdef _GNU_SOURCE
+#undef _ISOC9X_SOURCE
+#define _ISOC9X_SOURCE 1
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
@@ -118,14 +123,20 @@
/* 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 _XOPEN_SOURCE && \
- !defined _XOPEN_SOURCE_EXTENDED && !defined _BSD_SOURCE && \
- !defined _SVID_SOURCE)
+#if (!defined __STRICT_ANSI__ && !defined _ISOC9X_SOURCE && \
+ !defined _POSIX_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
#endif
+/* This is to enable the ISO C 9x extension. It will go away as soon
+ as this standard is officially released. */
+#ifdef _ISOC9X_SOURCE
+#define __USE_ISOC9X 1
+#endif
+
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
(and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
diff --git a/glibcbug.in b/glibcbug.in
index 28087892a5..0d46b325ab 100644
--- a/glibcbug.in
+++ b/glibcbug.in
@@ -232,7 +232,7 @@ sed -e "
/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
" $TEMP > $TEMP.x
-if $MAIL_AGENT $BUGGLIBC < $TEMP.x; then
+if $MAIL_AGENT < $TEMP.x; then
echo "$COMMAND: problem report sent"
xs=0; exit
else
diff --git a/isomac.c b/isomac.c
new file mode 100644
index 0000000000..fc6de89558
--- /dev/null
+++ b/isomac.c
@@ -0,0 +1,320 @@
+/* Check system header files for ISO 9899:1990 (ISO C) compliance.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jens Schweikhardt <schweikh@noc.dfn.de>, 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. */
+
+/* This is a simple minded program that tries to find illegal macro
+ definitions in system header files. Illegal macro definitions are
+ those not from the implementation namespace (i.e. not starting with
+ an underscore) or not matching any identifier mandated by The
+ Standard. Some common macro names are considered okay, e.g. all those
+ beginning with E (which may be defined in <errno.h>) or ending in
+ _MAX. See the arrays prefix[] and suffix[] below for details.
+
+ In a compliant implementation no other macros can be defined, because
+ you could write strictly conforming programs that may fail to compile
+ due to syntax errors: suppose <stdio.h> defines PIPE_BUF, then the
+ conforming
+
+ #include <assert.h>
+ #include <stdio.h> <- or where the bogus macro is defined
+ #include <string.h>
+ #define STR(x) #x
+ #define XSTR(x) STR(x)
+ int main (void)
+ {
+ int PIPE_BUF = 0;
+ assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0);
+ return 0;
+ }
+
+ is expected to compile and meet the assertion. If it does not, your
+ compiler compiles some other language than Standard C.
+
+ REQUIREMENTS:
+ This program calls gcc to get the list of defined macros. If you
+ don't have gcc you're probably out of luck unless your compiler or
+ preprocessor has something similar to gcc's -dM option. Tune
+ PRINT_MACROS in this case. This program assumes headers are found
+ under /usr/include and that there is a writable /tmp directory.
+ Tune SYSTEM_INCLUDE and TMPFILE if your system differs.
+ #define BROKEN_SYSTEM if system(NULL) bombs -- one more violation
+ of ISO C, by the way.
+
+ OUTPUT:
+ Each header file name is printed, followed by illegal macro names
+ and their definition. For the above example, you would see
+ ...
+ /usr/include/stdio.h
+ #define PIPE_BUF 5120
+ ...
+ If your implementation does not yet incorporate Amendment 1 you
+ will see messages about iso646.h, wctype.h and wchar.h not being
+ found. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define TMPFILE "/tmp/macros"
+#define HEADER_MAX 256
+
+/* ISO C header names including Amendment 1 (without ".h" suffix). */
+static char *header[] =
+{
+ "assert", "ctype", "errno", "float", "iso646", "limits", "locale",
+ "math", "setjmp", "signal", "stdarg", "stddef", "stdio", "stdlib",
+ "string", "time", "wchar", "wctype"
+};
+
+/* Macros with these prefixes are considered okay. */
+static char *prefix[] =
+{
+ "_", "E", "is", "str", "mem", "SIG", "FLT_", "DBL_", "LDBL_",
+ "LC_", "wmem", "wcs"
+};
+
+/* Macros with these suffixes are considered okay. Will not work for
+ parametrized macros with arguments. */
+static char *suffix[] =
+{
+ "_MAX", "_MIN"
+};
+
+/* These macros are considered okay. In fact, these are just more prefixes. */
+static char *macros[] =
+{
+ "BUFSIZ", "CHAR_BIT", "CHAR_MAX", "CHAR_MIN", "CLOCKS_PER_SEC",
+ "DBL_DIG", "DBL_EPSILON", "DBL_MANT_DIG", "DBL_MAX",
+ "DBL_MAX_10_EXP", "DBL_MAX_EXP", "DBL_MIN", "DBL_MIN_10_EXP",
+ "DBL_MIN_EXP", "EDOM", "EILSEQ", "EOF", "ERANGE", "EXIT_FAILURE",
+ "EXIT_SUCCESS", "FILENAME_MAX", "FLT_DIG", "FLT_EPSILON",
+ "FLT_MANT_DIG", "FLT_MAX", "FLT_MAX_10_EXP", "FLT_MAX_EXP",
+ "FLT_MIN", "FLT_MIN_10_EXP", "FLT_MIN_EXP", "FLT_RADIX",
+ "FLT_ROUNDS", "FOPEN_MAX", "HUGE_VAL", "INT_MAX", "INT_MIN",
+ "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC",
+ "LC_TIME", "LDBL_DIG", "LDBL_EPSILON", "LDBL_MANT_DIG", "LDBL_MAX",
+ "LDBL_MAX_10_EXP", "LDBL_MAX_EXP", "LDBL_MIN", "LDBL_MIN_10_EXP",
+ "LDBL_MIN_EXP", "LONG_MAX", "LONG_MIN", "L_tmpnam", "MB_CUR_MAX",
+ "MB_LEN_MAX", "NDEBUG", "NULL", "RAND_MAX", "SCHAR_MAX",
+ "SCHAR_MIN", "SEEK_CUR", "SEEK_END", "SEEK_SET", "SHRT_MAX",
+ "SHRT_MIN", "SIGABRT", "SIGFPE", "SIGILL", "SIGINT", "SIGSEGV",
+ "SIGTERM", "SIG_DFL", "SIG_ERR", "SIG_IGN", "TMP_MAX", "UCHAR_MAX",
+ "UINT_MAX", "ULONG_MAX", "USHRT_MAX", "WCHAR_MAX", "WCHAR_MIN",
+ "WEOF", "_IOFBF", "_IOLBF", "_IONBF", "abort", "abs", "acos",
+ "acosf", "acosl", "and", "and_eq", "asctime", "asin", "asinf",
+ "asinl", "assert", "atan", "atan2", "atan2f", "atan2l", "atanf",
+ "atanl", "atexit", "atof", "atoi", "atol", "bitand", "bitor",
+ "bsearch", "btowc", "calloc", "ceil", "ceilf", "ceill", "clearerr",
+ "clock", "clock_t", "compl", "cos", "cosf", "cosh", "coshf",
+ "coshl", "cosl", "ctime", "difftime", "div", "div_t", "errno",
+ "exit", "exp", "expf", "expl", "fabs", "fabsf", "fabsl", "fclose",
+ "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets", "fgetwc",
+ "fgetws", "floor", "floorf", "floorl", "fmod", "fmodf", "fmodl",
+ "fopen", "fprintf", "fputc", "fputs", "fputwc", "fputws", "fread",
+ "free", "freopen", "frexp", "frexpf", "frexpl", "fscanf", "fseek",
+ "fsetpos", "ftell", "fwide", "fwprintf", "fwrite", "fwscanf",
+ "getc", "getchar", "getenv", "gets", "getwc", "getwchar", "gmtime",
+ "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower",
+ "isprint", "ispunct", "isspace", "isupper", "iswalnum", "iswalpha",
+ "iswcntrl", "iswctype", "iswdigit", "iswgraph", "iswlower",
+ "iswprint", "iswpunct", "iswspace", "iswupper", "iswxdigit",
+ "isxdigit", "labs", "ldexp", "ldexpf", "ldexpl", "ldiv", "ldiv_t",
+ "localeconv", "localtime", "log", "log10", "log10f", "log10l",
+ "logf", "logl", "longjmp", "malloc", "mblen", "mbrlen", "mbrtowc",
+ "mbsinit", "mbsrtowcs", "mbstate_t", "mbstowcs", "mbtowc", "memchr",
+ "memcmp", "memcpy", "memmove", "memset", "mktime", "modf", "modff",
+ "modfl", "not", "not_eq", "offsetof", "or", "or_eq", "perror",
+ "pow", "powf", "powl", "printf", "ptrdiff_t", "putc", "putchar",
+ "puts", "putwc", "putwchar", "qsort", "raise", "rand", "realloc",
+ "remove", "rename", "rewind", "scanf", "setbuf", "setjmp",
+ "setlocale", "setvbuf", "sig_atomic_t", "signal", "sin", "sinf",
+ "sinh", "sinhf", "sinhl", "sinl", "size_t", "sprintf", "sqrt",
+ "sqrtf", "sqrtl", "srand", "sscanf", "stderr", "stdin", "stdout",
+ "strcat", "strchr", "strcmp", "strcoll", "strcpy", "strcspn",
+ "strerror", "strftime", "strlen", "strncat", "strncmp", "strncpy",
+ "strpbrk", "strrchr", "strspn", "strstr", "strtod", "strtok",
+ "strtol", "strtoul", "strxfrm", "swprintf", "swscanf", "system",
+ "tan", "tanf", "tanh", "tanhf", "tanhl", "tanl", "time", "time_t",
+ "tmpfile", "tmpnam", "tolower", "toupper", "towctrans", "towlower",
+ "towupper", "ungetc", "ungetwc", "va_arg", "va_end", "va_start",
+ "vfprintf", "vfwprintf", "vprintf", "vsprintf", "vswprintf",
+ "vwprintf", "wchar_t", "wcrtomb", "wcscat", "wcschr", "wcscmp",
+ "wcscoll", "wcscpy", "wcscspn", "wcsftime", "wcslen", "wcsncat",
+ "wcsncmp", "wcsncpy", "wcspbrk", "wcsrchr", "wcsrtombs", "wcsspn",
+ "wcsstr", "wcstod", "wcstok", "wcstol", "wcstombs", "wcstoul",
+ "wcsxfrm", "wctob", "wctomb", "wctrans", "wctrans_t", "wctype",
+ "wctype_t", "wint_t", "wmemchr", "wmemcmp", "wmemcpy", "wmemmove",
+ "wmemset", "wprintf", "wscanf", "xor", "xor_eq"
+};
+
+#define NUMBER_OF_HEADERS (sizeof header / sizeof *header)
+#define NUMBER_OF_PREFIXES (sizeof prefix / sizeof *prefix)
+#define NUMBER_OF_SUFFIXES (sizeof suffix / sizeof *suffix)
+#define NUMBER_OF_MACROS (sizeof macros / sizeof *macros)
+
+/* The compiler we use (given on the command line). */
+char *CC;
+/* The -I parameters for CC to find all headers. */
+char *INC;
+
+static int check_header (const char *);
+
+int
+main (int argc, char *argv[])
+{
+ int h;
+ int result = 0;
+
+ CC = argc > 1 ? argv[1] : "gcc";
+ INC = argc > 2 ? argv[2] : "";
+
+ if (system (NULL) == 0)
+ {
+ puts ("Sorry, no command processor.");
+ return EXIT_FAILURE;
+ }
+
+ for (h = 0; h < NUMBER_OF_HEADERS; ++h)
+ {
+ char file_name[HEADER_MAX];
+ sprintf (file_name, "%s.h", header[h]);
+ result |= check_header (file_name);
+ }
+
+
+#if 0
+ /* The test suite should return errors but for now this is not
+ practical. Give a warning and ask the user to correct the bugs. */
+ return result;
+#else
+ if (result)
+ fputs ("\
+##########################################################################\n\
+# The test suite found some problems with your system (see the generated #\n\
+# isomac.out file). These are all violations of the ISO C rules and #\n\
+# should be corrected. If the problem is in the libc, report it using #\n\
+# the glibcbug script to <bugs@gnu.ai.mit.edu>. If it is a problem with #\n\
+# your compiler, contact the compiler manufacturer. #\n\
+##########################################################################\n",
+ stderr);
+
+ return 0;
+#endif
+}
+
+static int
+check_header (const char *file_name)
+{
+ char line[BUFSIZ], *command;
+ FILE *input;
+ int result = 0;
+ static const char fmt[] = "\
+echo \"#include <%s>\" |\
+%s -E -dM -ansi -pedantic %s -D_LIBC -I. -I `%s --print-prog-name=include` -\
+> %s";
+
+ command = malloc (sizeof fmt + strlen (file_name) + 2 * strlen (CC)
+ + strlen (INC) + strlen (TMPFILE));
+
+ if (command == NULL)
+ {
+ puts ("No more memory.");
+ exit (1);
+ }
+
+ puts (file_name);
+ sprintf (command, fmt, file_name, CC, INC, CC, TMPFILE);
+
+ if (system (command))
+ {
+ puts ("system() returned nonzero");
+ result = 1;
+ }
+ free (command);
+ input = fopen (TMPFILE, "r");
+
+ if (input == NULL)
+ {
+ printf ("Could not read %s: ", TMPFILE);
+ perror (NULL);
+ return 1;
+ }
+
+ while (fgets (line, sizeof line, input) != NULL)
+ {
+ int i, okay = 0;
+ size_t endmac;
+ if (strlen (line) < 9 || line[7] != ' ')
+ { /* "#define A" */
+ printf ("Malformed input, expected '#define MACRO'\ngot '%s'\n",
+ line);
+ result = 1;
+ continue;
+ }
+ for (i = 0; i < NUMBER_OF_PREFIXES; ++i)
+ {
+ if (!strncmp (line+8, prefix[i], strlen (prefix[i]))) {
+ ++okay;
+ break;
+ }
+ }
+ if (okay)
+ continue;
+ for (i = 0; i < NUMBER_OF_MACROS; ++i)
+ {
+ if (!strncmp (line+8, macros[i], strlen (macros[i])))
+ {
+ ++okay;
+ break;
+ }
+ }
+ if (okay)
+ continue;
+ /* Find next char after the macro identifier; this can be either
+ a space or an open parenthesis. */
+ endmac = strcspn (line + 8, " (");
+ if (line[8+endmac] == '\0')
+ {
+ printf ("malformed input, expected '#define MACRO VALUE'\n"
+ "got '%s'\n", line);
+ result = 1;
+ continue;
+ }
+ for (i = 0; i < NUMBER_OF_SUFFIXES; ++i)
+ {
+ size_t len = strlen (suffix[i]);
+ if (!strncmp (line + 8 + endmac - len, suffix[i], len))
+ {
+ ++okay;
+ break;
+ }
+ }
+ if (!okay)
+ {
+ fputs (line, stdout);
+ result = 2;
+ }
+ }
+ fclose (input);
+ remove (TMPFILE);
+
+ return result;
+}
+
+/* EOF */
diff --git a/libio/clearerr.c b/libio/clearerr.c
index 7c7fb93dc0..4776250ff8 100644
--- a/libio/clearerr.c
+++ b/libio/clearerr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,7 +28,3 @@ clearerr (fp)
_IO_clearerr (fp);
_IO_funlockfile (fp);
}
-
-#ifdef _IO_MTSAFE_IO
-weak_alias (clearerr, clearerr_locked)
-#endif
diff --git a/libio/feof.c b/libio/feof.c
index 34ca1da161..23674704d6 100644
--- a/libio/feof.c
+++ b/libio/feof.c
@@ -36,11 +36,3 @@ _IO_feof (fp)
return result;
}
weak_alias (_IO_feof, feof)
-
-#ifdef _IO_MTSAFE_IO
-/* The feof implementation for libio does not require locking because
- it only accesses once a single variable and this is already atomic
- (at least at thread level). */
-
-weak_alias (_IO_feof, feof_locked)
-#endif
diff --git a/libio/ferror.c b/libio/ferror.c
index 4f75092149..b9ed64587c 100644
--- a/libio/ferror.c
+++ b/libio/ferror.c
@@ -36,8 +36,3 @@ _IO_ferror (fp)
return result;
}
weak_alias (_IO_ferror, ferror)
-
-#ifdef _IO_MTSAFE_IO
-
-weak_alias (ferror, ferror_locked)
-#endif
diff --git a/libio/fileno.c b/libio/fileno.c
index 08e657b970..269ecb875a 100644
--- a/libio/fileno.c
+++ b/libio/fileno.c
@@ -43,5 +43,4 @@ fileno (fp)
(at least at thread level). */
weak_alias (fileno, fileno_unlocked)
-weak_alias (fileno, fileno_locked)
#endif
diff --git a/libio/fputc.c b/libio/fputc.c
index 89359dc46d..e1f10f1b20 100644
--- a/libio/fputc.c
+++ b/libio/fputc.c
@@ -38,5 +38,3 @@ fputc (c, fp)
_IO_cleanup_region_end (1);
return result;
}
-
-weak_alias (fputc, fputc_locked)
diff --git a/libio/getc.c b/libio/getc.c
index eede63984f..d3e89fcc27 100644
--- a/libio/getc.c
+++ b/libio/getc.c
@@ -41,9 +41,3 @@ _IO_getc (fp)
}
#undef getc
weak_alias (_IO_getc, getc)
-
-#ifdef _IO_MTSAFE_IO
-# undef getc_locked
-
-weak_alias (getc, getc_locked)
-#endif
diff --git a/libio/getchar.c b/libio/getchar.c
index aa675591ad..25eb2b10ae 100644
--- a/libio/getchar.c
+++ b/libio/getchar.c
@@ -37,9 +37,3 @@ getchar ()
_IO_cleanup_region_end (1);
return result;
}
-
-#ifdef _IO_MTSAFE_IO
-# undef getchar_locked
-
-weak_alias (getchar, getchar_locked)
-#endif
diff --git a/libio/iofflush.c b/libio/iofflush.c
index af69486164..96cb49b2dc 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -44,7 +44,3 @@ _IO_fflush (fp)
}
weak_alias (_IO_fflush, fflush)
-
-#ifdef _IO_MTSAFE_IO
-weak_alias (_IO_fflush, fflush_locked)
-#endif
diff --git a/libio/putc.c b/libio/putc.c
index 5aa3b68137..6d84f24995 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is 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 "libioP.h"
#include "stdio.h"
@@ -36,9 +36,3 @@ _IO_putc (c, fp)
}
#undef putc
weak_alias (_IO_putc, putc)
-
-#ifdef _IO_MTSAFE_IO
-# undef putc_locked
-
-weak_alias (putc, putc_locked)
-#endif
diff --git a/libio/putchar.c b/libio/putchar.c
index 7822a31a1a..b8a41ebf76 100644
--- a/libio/putchar.c
+++ b/libio/putchar.c
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is 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 "libioP.h"
#include "stdio.h"
@@ -33,9 +33,3 @@ putchar (c)
__libc_cleanup_region_end (1);
return result;
}
-
-#ifdef _IO_MTSAFE_IO
-# undef putchar_locked
-
-weak_alias (putchar, putchar_locked)
-#endif
diff --git a/libio/stdio.h b/libio/stdio.h
index 88e9c6a985..0ed711a8cb 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -1,209 +1,191 @@
-/* This is part of the iostream/stdio library, providing -*- C -*- I/O.
- Define ANSI C stdio on top of C++ iostreams.
+/* Define ISO C stdio on top of C++ iostreams.
Copyright (C) 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
-This 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.
-This 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 this library; 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. */
/*
* ISO C Standard: 4.9 INPUT/OUTPUT <stdio.h>
*/
#ifndef _STDIO_H
-#define _STDIO_H
+
+#if !defined __need_FILE
+#define _STDIO_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <gnu/types.h>
+#endif /* Don't need FILE. */
+#undef __need_FILE
+
+
+#ifndef __FILE_defined
+
+/* The opaque type of streams. */
+typedef struct _IO_FILE FILE;
+
+#define __FILE_defined 1
+#endif /* FILE not defined. */
+
+
+#ifdef _STDIO_H
#define _STDIO_USES_IOSTREAM
#include <libio.h>
-#ifndef NULL
-#ifdef __cplusplus
-#define NULL 0
-#else
-#define NULL (void*)0
-#endif
-#endif
+/* The type of the second argument to `fgetpos' and `fsetpos'. */
+typedef _G_fpos_t fpos_t;
-#ifndef EOF
-#define EOF (-1)
-#endif
+
+/* Generate a unique file name (and possibly open it with mode "w+b"). */
+extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
+ __const char *__dir,
+ __const char *__pfx,
+ int __dir_search,
+ size_t *__lenptr,
+ FILE **__streamptr));
+
+
+/* Print out MESSAGE on the error output and abort. */
+extern void __libc_fatal __P ((__const char *__message))
+ __attribute__ ((__noreturn__));
+
+
+/* The possibilities for the third argument to `setvbuf'. */
+#define _IOFBF 0 /* Fully buffered. */
+#define _IOLBF 1 /* Line buffered. */
+#define _IONBF 2 /* No buffering. */
+
+
+/* Default buffer size. */
#ifndef BUFSIZ
#define BUFSIZ _IO_BUFSIZ
#endif
-#define _IOFBF 0 /* Fully buffered. */
-#define _IOLBF 1 /* Line buffered. */
-#define _IONBF 2 /* No buffering. */
-
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-
- /* define size_t. Crud in case <sys/types.h> has defined it. */
-#if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE)
-#if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h)
-#if !defined(_GCC_SIZE_T) && !defined(_SIZET_)
-#define _SIZE_T
-#define _T_SIZE_
-#define _T_SIZE
-#define __SIZE_T
-#define _SIZE_T_
-#define ___int_size_t_h
-#define _GCC_SIZE_T
-#define _SIZET_
-typedef _IO_size_t size_t;
-#endif
-#endif
+
+/* End of file character.
+ Some things throughout the library rely on this being -1. */
+#ifndef EOF
+#define EOF (-1)
#endif
-typedef struct _IO_FILE FILE;
-typedef _IO_fpos_t fpos_t;
-#include <stdio_lim.h>
+/* The possibilities for the third argument to `fseek'.
+ These values should not be changed. */
+#define SEEK_SET 0 /* Seek from beginning of file. */
+#define SEEK_CUR 1 /* Seek from current position. */
+#define SEEK_END 2 /* Seek from end of file. */
+
#ifdef __USE_SVID
/* Default path prefix for `tempnam' and `tmpnam'. */
#define P_tmpdir "/tmp"
#endif
-/* For use by debuggers. These are linked in if printf or fprintf are used. */
-extern FILE *stdin, *stdout, *stderr; /* TODO */
+/* Get the values:
+ L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
+ TMP_MAX The minimum number of unique filenames generated by tmpnam
+ (and tempnam when it uses tmpnam's name space),
+ or tempnam (the two are separate).
+ L_ctermid How long an array to pass to `ctermid'.
+ L_cuserid How long an array to pass to `cuserid'.
+ FOPEN_MAX Minimum number of files that can be open at once.
+ FILENAME_MAX Maximum length of a filename. */
+#include <stdio_lim.h>
+
+
+/* Standard streams. */
+extern FILE *stdin, *stdout, *stderr;
+/* Refer to the real names by default. */
#define stdin _IO_stdin
#define stdout _IO_stdout
#define stderr _IO_stderr
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifndef __P
-#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif
-#endif /*!__P*/
-
-extern void clearerr __P ((FILE*));
-extern int fclose __P ((FILE*));
-extern int feof __P ((FILE*));
-extern int ferror __P ((FILE*));
-extern int fflush __P ((FILE*));
-extern int fgetc __P ((FILE *));
-extern int fgetpos __P ((FILE* fp, fpos_t *pos));
-extern char* fgets __P ((char*, int, FILE*));
-extern FILE* fopen __P ((__const char*, __const char*));
-extern FILE* fopencookie __P ((void *cookie, __const char *mode,
- _IO_cookie_io_functions_t io_functions));
-extern int fprintf __P ((FILE*, __const char* format, ...));
-extern int fputc __P ((int, FILE*));
-extern int fputs __P ((__const char *str, FILE *fp));
-extern size_t fread __P ((void*, size_t, size_t, FILE*));
-extern FILE* freopen __P ((__const char*, __const char*, FILE*));
-extern int fscanf __P ((FILE *fp, __const char* format, ...));
-extern int fseek __P ((FILE* fp, long int offset, int whence));
-extern int fsetpos __P ((FILE* fp, __const fpos_t *pos));
-extern long int ftell __P ((FILE* fp));
-extern size_t fwrite __P ((__const void*, size_t, size_t, FILE*));
-extern int getc __P ((FILE *));
-extern int getchar __P ((void));
-extern char* gets __P ((char*));
-extern void perror __P ((__const char *));
-extern int printf __P ((__const char* format, ...));
-extern int putc __P ((int, FILE *));
-extern int putchar __P ((int));
-extern int puts __P ((__const char *str));
-extern int remove __P ((__const char*));
-extern int rename __P ((__const char* _old, __const char* _new));
-extern void rewind __P ((FILE*));
-extern int scanf __P ((__const char* format, ...));
-extern void setbuf __P ((FILE*, char*));
-extern void setlinebuf __P ((FILE*));
-extern void setbuffer __P ((FILE*, char*, int));
-extern int setvbuf __P ((FILE*, char*, int mode, size_t size));
-extern int sprintf __P ((char*, __const char* format, ...));
-extern int sscanf __P ((__const char* string, __const char* format, ...));
-extern FILE* tmpfile __P ((void));
-extern char* tmpnam __P ((char*));
-#ifdef __USE_MISC
-extern char* tmpnam_r __P ((char*));
+/* Remove file FILENAME. */
+extern int remove __P ((__const char *__filename));
+/* Rename file OLD to NEW. */
+extern int rename __P ((__const char *__old, __const char *__new));
+
+
+/* Create a temporary file and open it read/write. */
+extern FILE *tmpfile __P ((void));
+/* Generate a temporary filename. */
+extern char *tmpnam __P ((char *__s));
+
+#ifdef __USE_MISC
+/* This is the reentrant variant of `tmpnam'. The only difference is
+ that it does not allow S to be NULL. */
+extern char *tmpnam_r __P ((char *__s));
#endif
-#if defined(__USE_SVID) || defined(__USE_XOPEN)
+
+
+#if defined __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.
+ If it contains the name of a writable directory, that directory is used.
+ If not and if DIR is not NULL, that value is checked. If that fails,
+ P_tmpdir is tried and finally "/tmp". The storage for the filename
+ is allocated by `malloc'. */
extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
#endif
-extern char *__stdio_gen_tempname __P ((char *__buf, size_t bufsize,
- __const char *dir, __const char *pfx,
- int dir_search, size_t *lenptr,
- FILE **streamptr));
-extern int ungetc __P ((int c, FILE* fp));
-extern int vfprintf __P ((FILE *fp, char __const *fmt0, _G_va_list));
-extern int vprintf __P ((char __const *fmt, _G_va_list));
-extern int vsprintf __P ((char* string, __const char* format, _G_va_list));
-extern void __libc_fatal __P ((__const char *__message))
- __attribute__ ((__noreturn__));
-#ifndef __STRICT_ANSI__
-extern int dprintf __P ((int, __const char *, ...));
-extern int vdprintf __P ((int, __const char *, _G_va_list));
-extern int vfscanf __P ((FILE*, __const char *, _G_va_list));
-extern int __vfscanf __P ((FILE*, __const char *, _G_va_list));
-extern int vscanf __P ((__const char *, _G_va_list));
-extern int vsscanf __P ((__const char *, __const char *, _G_va_list));
-extern int __vsscanf __P ((__const char *, __const char *, _G_va_list));
+
+/* Close STREAM. */
+extern int fclose __P ((FILE *__stream));
+/* Flush STREAM, or all streams if STREAM is NULL. */
+extern int fflush __P ((FILE *__stream));
+
+#ifdef __USE_MISC
+/* Faster versions when locking is not required. */
+extern int fclose_unlocked __P ((FILE *__stream));
+extern int fflush_unlocked __P ((FILE *__stream));
#endif
#ifdef __USE_GNU
+/* Close all streams. */
extern int __fcloseall __P ((void));
extern int fcloseall __P ((void));
-
-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*));
-extern FILE* popen __P ((__const char*, __const char*));
-extern int pclose __P ((FILE*));
-
-#define L_ctermid 9
-#define L_cuserid 9
-/* Return the name of the controlling terminal. */
-extern char *ctermid __P ((char *__buf));
+/* Open a file and create a new stream for it. */
+extern FILE *fopen __P ((__const char *__filename, __const char *__modes));
+/* Open a file, replacing an existing stream with it. */
+extern FILE *freopen __P ((__const char *__restrict __filename,
+ __const char *__restrict __modes,
+ FILE *__restrict __stream));
-/* Get character login name of the user. */
-extern char *cuserid __P ((char * __buf));
+#ifdef __USE_POSIX
+/* Create a new stream that refers to an existing system file descriptor. */
+extern FILE *fdopen __P ((int __fd, __const char *__modes));
#endif
-#ifdef __USE_GNU
-extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*));
-extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
-extern _IO_ssize_t __getline __P ((char **, size_t *, FILE *));
-
-extern int snprintf __P ((char *, size_t, __const char *, ...));
-extern int __snprintf __P ((char *, size_t, __const char *, ...));
-extern int vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
-extern int __vsnprintf __P ((char *, size_t, __const char *, _G_va_list));
-
-extern int asprintf __P ((char **, const char *, ...));
-extern int vasprintf __P ((char **, const char *, _G_va_list));
+#ifdef __USE_GNU
+/* Create a new stream that refers to the given magic cookie,
+ and uses the given functions for input and output. */
+extern FILE *fopencookie __P ((void *__magic_cookie, __const char *__modes,
+ _IO_cookie_io_functions_t __io_funcs));
/* Open a stream that writes into a malloc'd buffer that is expanded as
necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
@@ -211,77 +193,409 @@ extern int vasprintf __P ((char **, const char *, _G_va_list));
extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
#endif
-extern int __underflow __P ((struct _IO_FILE*));
-extern int __overflow __P ((struct _IO_FILE*, int));
-#ifdef __USE_BSD
-extern int sys_nerr;
-extern const char *const sys_errlist[];
-#endif
-#ifdef __USE_GNU
-extern int _sys_nerr;
-extern const char *const _sys_errlist[];
+/* If BUF is NULL, make STREAM unbuffered.
+ Else make it use buffer BUF, of size BUFSIZ. */
+extern void setbuf __P ((FILE *__restrict __stream, char *__restrict __buf));
+/* Make STREAM use buffering mode MODE.
+ If BUF is not NULL, use N bytes of it for buffering;
+ else allocate an internal buffer N bytes long. */
+extern int setvbuf __P ((FILE *__restrict __stream, char *__restrict __buf,
+ int __modes, size_t __n));
+
+#ifdef __USE_BSD
+/* If BUF is NULL, make STREAM unbuffered.
+ Else make it use SIZE bytes of BUF for buffering. */
+extern void setbuffer __P ((FILE *__stream, char *__buf, size_t __size));
+
+/* Make STREAM line-buffered. */
+extern void setlinebuf __P ((FILE *__stream));
#endif
-/* Handle locking of streams. */
-#ifdef __USE_MISC
-extern void clearerr_locked __P ((FILE *));
-extern void clearerr_unlocked __P ((FILE *));
-extern int feof_locked __P ((FILE *));
-extern int feof_unlocked __P ((FILE *));
-extern int ferror_locked __P ((FILE*));
-extern int ferror_unlocked __P ((FILE*));
-extern int fileno_locked __P ((FILE *));
-extern int fileno_unlocked __P ((FILE *));
-extern int fclose_unlocked __P ((FILE *));
-extern int fflush_locked __P ((FILE *));
-extern int fflush_unlocked __P ((FILE *));
-extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *));
-extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *));
-
-extern int fputc_locked __P ((int, FILE*));
-extern int fputc_unlocked __P ((int, FILE*));
-extern int getc_locked __P ((FILE *));
-extern int getchar_locked __P ((void));
-extern int putc_locked __P ((int, FILE *));
-extern int putchar_locked __P ((int));
-
-# ifndef _LIBC
-# define getc_locked(fp) _IO_getc (fp)
-# define getchar_locked() _IO_getc (stdin)
-# define putchar_locked(c) _IO_putc (c, stdout)
-# endif
+
+/* Write formatted output to STREAM. */
+extern int fprintf __P ((FILE *__restrict __stream,
+ __const char *__restrict __format, ...));
+/* Write formatted output to stdout. */
+extern int printf __P ((__const char *__restrict __format, ...));
+/* Write formatted output to S. */
+extern int sprintf __P ((char *__restrict __s,
+ __const char *__restrict __format, ...));
+
+/* Write formatted output to S from argument list ARG. */
+extern int vfprintf __P ((FILE *__restrict __s,
+ __const char *__restrict __format,
+ _G_va_list __arg));
+/* Write formatted output to stdout from argument list ARG. */
+extern int vprintf __P ((__const char *__restrict __format,
+ _G_va_list __arg));
+/* Write formatted output to S from argument list ARG. */
+extern int vsprintf __P ((char *__restrict __s,
+ __const char *__restrict __format,
+ _G_va_list __arg));
+
+#ifdef __OPTIMIZE__
+extern __inline int
+vprintf (const char *__restrict __fmt, _G_va_list __arg)
+{
+ return vfprintf (stdout, __fmt, __arg);
+}
+#endif /* Optimizing. */
+
+#ifdef __USE_GNU
+/* Maximum chars of output to write in MAXLEN. */
+extern int __snprintf __P ((char *__s, size_t __maxlen,
+ __const char *__format, ...));
+extern int snprintf __P ((char *__s, size_t __maxlen,
+ __const char *__format, ...));
+
+extern int __vsnprintf __P ((char *__s, size_t __maxlen,
+ __const char *__format, _G_va_list __arg));
+extern int vsnprintf __P ((char *__s, size_t __maxlen,
+ __const char *__format, _G_va_list __arg));
+
+/* Write formatted output to a string dynamically allocated with `malloc'.
+ Store the address of the string in *PTR. */
+extern int vasprintf __P ((char **__ptr, __const char *__f,
+ _G_va_list __arg));
+extern int asprintf __P ((char **__ptr, __const char *__fmt, ...));
+
+/* Write formatted output to a file descriptor. */
+extern int vdprintf __P ((int __fd, __const char *__fmt, _G_va_list __arg));
+extern int dprintf __P ((int __fd, __const char *__fmt, ...));
#endif
+
+/* Read formatted input from STREAM. */
+extern int fscanf __P ((FILE *__restrict __stream,
+ __const char *__restrict __format, ...));
+/* Read formatted input from stdin. */
+extern int scanf __P ((__const char *__restrict __format, ...));
+/* Read formatted input from S. */
+extern int sscanf __P ((__const char *__restrict __s,
+ __const char *__restrict __format, ...));
+
+#ifdef __USE_GNU
+/* Read formatted input from S into argument list ARG. */
+extern int __vfscanf __P ((FILE *__s, __const char *__format,
+ _G_va_list __arg));
+extern int vfscanf __P ((FILE *__s, __const char *__format,
+ _G_va_list __arg));
+
+/* Read formatted input from stdin into argument list ARG. */
+extern int __vscanf __P ((__const char *__format, _G_va_list __arg));
+extern int vscanf __P ((__const char *__format, _G_va_list __arg));
+
+/* Read formatted input from S into argument list ARG. */
+extern int __vsscanf __P ((__const char *__s, __const char *__format,
+ _G_va_list __arg));
+extern int vsscanf __P ((__const char *__s, __const char *__format,
+ _G_va_list __arg));
+
+
+#ifdef __OPTIMIZE__
+extern __inline int
+vfscanf (FILE *__s, const char *__fmt, _G_va_list __arg)
+{
+ return __vfscanf (__s, __fmt, __arg);
+}
+extern __inline int
+vscanf (const char *__fmt, _G_va_list __arg)
+{
+ return __vfscanf (stdin, __fmt, __arg);
+}
+extern __inline int
+vsscanf (const char *__s, const char *__fmt, _G_va_list __arg)
+{
+ return __vsscanf (__s, __fmt, __arg);
+}
+#endif /* Optimizing. */
+#endif /* Use GNU. */
+
+
+/* Read a character from STREAM. */
+extern int fgetc __P ((FILE *__stream));
+extern int getc __P ((FILE *__stream));
+
+/* Read a character from stdin. */
+extern int getchar __P ((void));
+
+/* The C standard explicitly says this is a macro, so we always do the
+ optimization for it. */
+#define getc(_fp) _IO_getc (_fp)
+
+#ifdef __OPTIMIZE__
+extern __inline int
+getchar (void)
+{
+ return _IO_getc (stdin);
+}
+#endif /* Optimizing. */
+
#if defined __USE_POSIX || defined __USE_MISC
/* These are defined in POSIX.1:1996. */
-extern void flockfile __P ((FILE *));
-extern void funlockfile __P ((FILE *));
-extern int ftrylockfile __P ((FILE *));
-
-extern int getc_unlocked __P ((FILE *));
+extern int getc_unlocked __P ((FILE *__stream));
extern int getchar_unlocked __P ((void));
-extern int putc_unlocked __P ((int, FILE *));
-extern int putchar_unlocked __P ((int));
-
-# ifndef _LIBC
-# define getc_unlocked(fp) _IO_getc_unlocked (fp)
-# define getchar_unlocked() _IO_getc_unlocked (stdin)
-# define putc_unlocked(c, fp) _IO_putc_unlocked ((c), (fp))
-# define putchar_unlocked(c) _IO_putc_unlocked ((c), stdout)
-# endif
-#endif /* POSIX || misc */
-#define getc(_fp) _IO_getc (_fp)
+#ifdef __OPTIMIZE__
+extern __inline int
+getc_unlocked (FILE *__fp)
+{
+ return _IO_getc_unlocked (__fp);
+}
+
+extern __inline int
+getchar_unlocked (void)
+{
+ return _IO_getc_unlocked (stdin);
+}
+#endif /* Optimizing. */
+#endif /* Use POSIX or MISC. */
+
+
+/* Write a character to STREAM. */
+extern int fputc __P ((int __c, FILE *__stream));
+extern int putc __P ((int __c, FILE *__stream));
+
+/* Write a character to stdout. */
+extern int putchar __P ((int __c));
+
+/* The C standard explicitly says this can be a macro,
+ so we always do the optimization for it. */
#define putc(_ch, _fp) _IO_putc (_ch, _fp)
-#define putchar(_ch) _IO_putc (_ch, stdout)
-#define getchar() _IO_getc (stdin)
+#ifdef __OPTIMIZE__
+extern __inline int
+putchar (int __c)
+{
+ return _IO_putc (__c, stdout);
+}
+#endif
-#ifdef __cplusplus
+#ifdef __USE_MISC
+/* Faster version when locking is not necessary. */
+extern int fputc_unlocked __P ((int __c, FILE *__stream));
+
+#ifdef __OPTIMIZE__
+extern __inline int
+fputc_unlocked (int __c, FILE *__stream)
+{
+ return _IO_putc_unlocked (__c, __stream);
}
+#endif /* Optimizing. */
+#endif /* Use MISC. */
+
+#if defined __USE_POSIX || defined __USE_MISC
+/* These are defined in POSIX.1:1996. */
+extern int putc_unlocked __P ((int __c, FILE *__stream));
+extern int putchar_unlocked __P ((int __c));
+
+#ifdef __OPTIMIZE__
+extern __inline int
+putc_unlocked (int __c, FILE *__stream)
+{
+ return _IO_putc_unlocked (__c, __stream);
+}
+
+extern __inline int
+putchar_unlocked (int __c)
+{
+ return _IO_putc_unlocked (__c, stdout);
+}
+#endif /* Optimizing. */
+#endif /* Use POSIX or MISc. */
+
+
+#if defined __USE_SVID || defined __USE_MISC
+/* Get a word (int) from STREAM. */
+extern int getw __P ((FILE *__stream));
+
+/* Write a word (int) to STREAM. */
+extern int putw __P ((int __w, FILE *__stream));
#endif
+/* Get a newline-terminated string of finite length from STREAM. */
+extern char *fgets __P ((char *__restrict __s, int __n,
+ FILE *__restrict __stream));
+
+/* Get a newline-terminated string from stdin, removing the newline.
+ DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
+extern char *gets __P ((char *__s));
+
+
+#ifdef __USE_GNU
+/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
+ (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
+ NULL), pointing to *N characters of space. It is realloc'd as
+ necessary. Returns the number of characters read (not including the
+ null terminator), or -1 on error or EOF. */
+_IO_ssize_t __getdelim __P ((char **__lineptr, size_t *__n,
+ int __delimiter, FILE *__stream));
+_IO_ssize_t getdelim __P ((char **__lineptr, size_t *__n,
+ int __delimiter, FILE *__stream));
+
+/* Like `getdelim', but reads up to a newline. */
+_IO_ssize_t __getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
+_IO_ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
+
+#ifdef __OPTIMIZE__
+extern __inline _IO_ssize_t
+getline (char **__lineptr, size_t *__n, FILE *__stream)
+{
+ return __getdelim (__lineptr, __n, '\n', __stream);
+}
+#endif /* Optimizing. */
+#endif
+
+
+/* Write a string to STREAM. */
+extern int fputs __P ((__const char *__restrict __s,
+ FILE *__restrict __stream));
+/* Write a string, followed by a newline, to stdout. */
+extern int puts __P ((__const char *__s));
+
+
+/* Push a character back onto the input buffer of STREAM. */
+extern int ungetc __P ((int __c, FILE *__stream));
+
+
+/* Read chunks of generic data from STREAM. */
+extern size_t fread __P ((void *__restrict __ptr, size_t __size,
+ size_t __n, FILE *__restrict __stream));
+/* Write chunks of generic data to STREAM. */
+extern size_t fwrite __P ((__const void *__restrict __ptr, size_t __size,
+ size_t __n, FILE *__restrict __s));
+
+#ifdef __USE_MISC
+/* Faster versions when locking is not necessary. */
+extern size_t fread_unlocked __P ((void *__restrict __ptr, size_t __size,
+ size_t __n, FILE *__restrict __stream));
+extern size_t fwrite_unlocked __P ((__const void *__restrict __ptr,
+ size_t __size, size_t __n,
+ FILE *__restrict __stream));
+#endif
+
+
+/* Seek to a certain position on STREAM. */
+extern int fseek __P ((FILE *__stream, long int __off, int __whence));
+/* Return the current position of STREAM. */
+extern long int ftell __P ((FILE *__stream));
+/* Rewind to the beginning of STREAM. */
+extern void rewind __P ((FILE *__stream));
+
+/* Get STREAM's position. */
+extern int fgetpos __P ((FILE *__restrict __stream,
+ fpos_t *__restrict __pos));
+/* Set STREAM's position. */
+extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
+
+
+/* Clear the error and EOF indicators for STREAM. */
+extern void clearerr __P ((FILE *__stream));
+/* Return the EOF indicator for STREAM. */
+extern int feof __P ((FILE *__stream));
+/* Return the error indicator for STREAM. */
+extern int ferror __P ((FILE *__stream));
+
+#ifdef __USE_MISC
+/* Faster versions when locking is not required. */
+extern void clearerr_unlocked __P ((FILE *__stream));
+extern int feof_unlocked __P ((FILE *__stream));
+extern int ferror_unlocked __P ((FILE *__stream));
+
+#ifdef __OPTIMIZE__
+extern __inline int
+feof_unlocked (FILE *__stream)
+{
+ return _IO_feof_unlocked (__stream);
+}
+
+extern __inline int
+ferror_unlocked (FILE *__stream)
+{
+ return _IO_ferror_unlocked (__stream);
+}
+#endif /* Optimizing. */
+#endif
+
+
+/* Print a message describing the meaning of the value of errno. */
+extern void perror __P ((__const char *__s));
+
+/* These variables normally should not be used directly. The `strftime'
+ function provides all the needed functionality. */
+#ifdef __USE_BSD
+extern int sys_nerr;
+extern __const char *__const sys_errlist[];
+#endif
+#ifdef __USE_GNU
+extern int _sys_nerr;
+extern __const char *__const _sys_errlist[];
+#endif
+
+
+#ifdef __USE_POSIX
+/* Return the system file descriptor for STREAM. */
+extern int fileno __P ((FILE *__stream));
+#endif /* Use POSIX. */
+
+#ifdef __USE_MISC
+/* Faster version when locking is not required. */
+extern int fileno_unlocked __P ((FILE *__stream));
+#endif
+
+
+#if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
+ defined __USE_MISC)
+/* Create a new stream connected to a pipe running the given command. */
+extern FILE *popen __P ((__const char *__command, __const char *__modes));
+
+/* Close a stream opened by popen and return the status of its child. */
+extern int pclose __P ((FILE *__stream));
+#endif
+
+
+#ifdef __USE_POSIX
+/* Return the name of the controlling terminal. */
+extern char *ctermid __P ((char *__s));
+#endif /* Use POSIX. */
+
+
+#ifdef __USE_XOPEN
+/* Return the name of the current user. */
+extern char *cuserid __P ((char *__s));
+#endif /* Use X/Open. */
+
+
+#ifdef __USE_GNU
+struct obstack; /* See <obstack.h>. */
+
+/* Write formatted output to an obstack. */
+extern int obstack_printf __P ((struct obstack *__obstack,
+ __const char *__format, ...));
+extern int obstack_vprintf __P ((struct obstack *__obstack,
+ __const char *__format,
+ _G_va_list __args));
+#endif /* Use GNU. */
+
+
+#if defined __USE_POSIX || defined __USE_MISC
+/* These are defined in POSIX.1:1996. */
+
+/* Acquire ownership of STREAM. */
+extern void flockfile __P ((FILE *__stream));
+
+/* Try to acquire ownership of STREAM but do not block if it is not
+ possible. */
+extern int ftrylockfile __P ((FILE *__stream));
+
+/* Relinquish the ownership granted for STREAM. */
+extern void funlockfile __P ((FILE *__stream));
+#endif /* POSIX || misc */
+
+__END_DECLS
+
+#endif /* <stdio.h> included. */
#endif /* !_STDIO_H */
diff --git a/locale/C-time.c b/locale/C-time.c
index 70ee89a192..095d097e2b 100644
--- a/locale/C-time.c
+++ b/locale/C-time.c
@@ -27,7 +27,7 @@ const struct locale_data _nl_C_LC_TIME =
_nl_C_name,
NULL, 0, 0, /* no file mapped */
MAX_USAGE_COUNT,
- 53,
+ 54,
{
{ string: "Sun" },
{ string: "Mon" },
@@ -80,6 +80,7 @@ const struct locale_data _nl_C_LC_TIME =
{ string: "" },
{ string: "" },
{ word: 0 },
+ { word: 0 },
{ string: "" },
{ string: "" },
}
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index e2157311c1..7b0aaaa60f 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -166,6 +166,8 @@ static void show_info (const char *name);
int
main (int argc, char *argv[])
{
+ int remaining;
+
/* Set initial values for global variables. */
show_category_name = 0;
show_keyword_name = 0;
@@ -179,7 +181,7 @@ main (int argc, char *argv[])
textdomain (PACKAGE);
/* Parse and process arguments. */
- argp_parse (&argp, argc, argv, 0, 0, NULL);
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
/* `-a' requests the names of all available locales. */
if (do_all != 0)
@@ -203,15 +205,15 @@ main (int argc, char *argv[])
/* If no real argument is given we have to print the contents of the
current locale definition variables. These are LANG and the LC_*. */
- if (optind == argc && show_keyword_name == 0 && show_category_name == 0)
+ if (remaining == argc && show_keyword_name == 0 && show_category_name == 0)
{
show_locale_vars ();
exit (EXIT_SUCCESS);
}
/* Process all given names. */
- while (optind < argc)
- show_info (argv[optind++]);
+ while (remaining < argc)
+ show_info (argv[remaining++]);
exit (EXIT_SUCCESS);
}
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 656377f9df..e8f0d3bc54 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -148,6 +148,7 @@ main (int argc, char *argv[])
struct charset_t *charset;
struct localedef_t *localedef;
struct copy_def_list_t *act_add_locdef;
+ int remaining;
/* Set initial values for global variables. */
copy_list = NULL;
@@ -163,7 +164,7 @@ main (int argc, char *argv[])
textdomain (_libc_intl_domainname);
/* Parse and process arguments. */
- argp_parse (&argp, argc, argv, 0, 0, NULL);
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
/* XXX POSIX is violated since for unknown option a exit value > 3
must be used. */
@@ -172,7 +173,7 @@ main (int argc, char *argv[])
character map. */
verbose |= posix_conformance;
- if (argc - optind != 1)
+ if (argc - remaining != 1)
{
/* We need exactly one non-option parameter. */
argp_help (&argp, stdout, ARGP_HELP_SEE,
@@ -185,7 +186,7 @@ main (int argc, char *argv[])
/* The parameter describes the output path of the constructed files.
If the described files cannot be written return a NULL pointer. */
- output_path = construct_output_path (argv[optind]);
+ output_path = construct_output_path (argv[remaining]);
cannot_write_why = errno;
/* Now that the parameters are processed we have to reset the local
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0380527f64..6b4fc72b20 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -19,7 +19,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* V2.6.4-pt2 Sat Dec 14 1996
+/* V2.6.4-pt3 Thu Feb 20 1997
This work is mainly derived from malloc-2.6.4 by Doug Lea
<dl@cs.oswego.edu>, which is available from:
@@ -874,6 +874,8 @@ extern Void_t* sbrk();
#define mALLOC_STATs __malloc_stats
#define mALLOC_USABLE_SIZe __malloc_usable_size
#define mALLOC_TRIm __malloc_trim
+#define mALLOC_GET_STATe __malloc_get_state
+#define mALLOC_SET_STATe __malloc_set_state
#else
@@ -889,6 +891,8 @@ extern Void_t* sbrk();
#define mALLOC_STATs malloc_stats
#define mALLOC_USABLE_SIZe malloc_usable_size
#define mALLOC_TRIm malloc_trim
+#define mALLOC_GET_STATe malloc_get_state
+#define mALLOC_SET_STATe malloc_set_state
#endif
@@ -912,7 +916,11 @@ size_t mALLOC_USABLE_SIZe(Void_t*);
void mALLOC_STATs(void);
int mALLOPt(int, int);
struct mallinfo mALLINFo(void);
-#else
+Void_t* mALLOC_GET_STATe(void);
+int mALLOC_SET_STATe(Void_t*);
+
+#else /* !__STD_C */
+
#ifndef _LIBC
void ptmalloc_init();
#endif
@@ -929,7 +937,10 @@ size_t mALLOC_USABLE_SIZe();
void mALLOC_STATs();
int mALLOPt();
struct mallinfo mALLINFo();
-#endif
+Void_t* mALLOC_GET_STATe();
+int mALLOC_SET_STATe();
+
+#endif /* __STD_C */
#ifdef __cplusplus
@@ -3775,6 +3786,144 @@ int mALLOPt(param_number, value) int param_number; int value;
+/* Get/set state: malloc_get_state() records the current state of all
+ malloc variables (_except_ for the actual heap contents and `hook'
+ function pointers) in a system dependent, opaque data structure.
+ This data structure is dynamically allocated and can be free()d
+ after use. malloc_set_state() restores the state of all malloc
+ variables to the previously obtained state. This is especially
+ useful when using this malloc as part of a shared library, and when
+ the heap contents are saved/restored via some other method. The
+ primary example for this is GNU Emacs with its `dumping' procedure.
+ `Hook' function pointers are never saved or restored by these
+ functions. */
+
+#define MALLOC_STATE_MAGIC 0x444c4541l
+#define MALLOC_STATE_VERSION (0*0x100l + 0l) /* major*0x100 + minor */
+
+struct malloc_state {
+ long magic;
+ long version;
+ mbinptr av[NAV * 2 + 2];
+ char* sbrk_base;
+ int sbrked_mem_bytes;
+ unsigned long trim_threshold;
+ unsigned long top_pad;
+ unsigned int n_mmaps_max;
+ unsigned long mmap_threshold;
+ int check_action;
+ unsigned long max_sbrked_mem;
+ unsigned long max_total_mem;
+ unsigned int n_mmaps;
+ unsigned int max_n_mmaps;
+ unsigned long mmapped_mem;
+ unsigned long max_mmapped_mem;
+};
+
+Void_t*
+mALLOC_GET_STATe()
+{
+ mchunkptr victim;
+ struct malloc_state* ms;
+ int i;
+ mbinptr b;
+
+ ptmalloc_init();
+ (void)mutex_lock(&main_arena.mutex);
+ victim = chunk_alloc(&main_arena, request2size(sizeof(*ms)));
+ if(!victim) {
+ (void)mutex_unlock(&main_arena.mutex);
+ return 0;
+ }
+ ms = (struct malloc_state*)chunk2mem(victim);
+ ms->magic = MALLOC_STATE_MAGIC;
+ ms->version = MALLOC_STATE_VERSION;
+ ms->av[0] = main_arena.av[0];
+ ms->av[1] = main_arena.av[1];
+ for(i=0; i<NAV; i++) {
+ b = bin_at(&main_arena, i);
+ if(first(b) == b)
+ ms->av[2*i+2] = ms->av[2*i+3] = 0; /* empty bin (or initial top) */
+ else {
+ ms->av[2*i+2] = first(b);
+ ms->av[2*i+3] = last(b);
+ }
+ }
+ ms->sbrk_base = sbrk_base;
+ ms->sbrked_mem_bytes = sbrked_mem;
+ ms->trim_threshold = trim_threshold;
+ ms->top_pad = top_pad;
+ ms->n_mmaps_max = n_mmaps_max;
+ ms->mmap_threshold = mmap_threshold;
+ ms->check_action = check_action;
+ ms->max_sbrked_mem = max_sbrked_mem;
+#ifdef NO_THREADS
+ ms->max_total_mem = max_total_mem;
+#else
+ ms->max_total_mem = 0;
+#endif
+ ms->n_mmaps = n_mmaps;
+ ms->max_n_mmaps = max_n_mmaps;
+ ms->mmapped_mem = mmapped_mem;
+ ms->max_mmapped_mem = max_mmapped_mem;
+ (void)mutex_unlock(&main_arena.mutex);
+ return (Void_t*)ms;
+}
+
+int
+#if __STD_C
+mALLOC_SET_STATe(Void_t* msptr)
+#else
+mALLOC_SET_STATe(msptr) Void_t* msptr;
+#endif
+{
+ struct malloc_state* ms = (struct malloc_state*)msptr;
+ int i;
+ mbinptr b;
+
+ ptmalloc_init();
+ if(ms->magic != MALLOC_STATE_MAGIC) return -1;
+ /* Must fail if the major version is too high. */
+ if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2;
+ (void)mutex_lock(&main_arena.mutex);
+ main_arena.av[0] = ms->av[0];
+ main_arena.av[1] = ms->av[1];
+ for(i=0; i<NAV; i++) {
+ b = bin_at(&main_arena, i);
+ if(ms->av[2*i+2] == 0)
+ first(b) = last(b) = b;
+ else {
+ first(b) = ms->av[2*i+2];
+ last(b) = ms->av[2*i+3];
+ if(i > 0) {
+ /* Make sure the links to the `av'-bins in the heap are correct. */
+ first(b)->bk = b;
+ last(b)->fd = b;
+ }
+ }
+ }
+ sbrk_base = ms->sbrk_base;
+ sbrked_mem = ms->sbrked_mem_bytes;
+ trim_threshold = ms->trim_threshold;
+ top_pad = ms->top_pad;
+ n_mmaps_max = ms->n_mmaps_max;
+ mmap_threshold = ms->mmap_threshold;
+ check_action = ms->check_action;
+ max_sbrked_mem = ms->max_sbrked_mem;
+#ifdef NO_THREADS
+ max_total_mem = ms->max_total_mem;
+#endif
+ n_mmaps = ms->n_mmaps;
+ max_n_mmaps = ms->max_n_mmaps;
+ mmapped_mem = ms->mmapped_mem;
+ max_mmapped_mem = ms->max_mmapped_mem;
+ /* add version-dependent code here */
+ (void)mutex_unlock(&main_arena.mutex);
+ return 0;
+}
+
+
+
#if defined(_LIBC) || defined(MALLOC_HOOKS)
/* A simple, standard set of debugging hooks. Overhead is `only' one
@@ -4048,12 +4197,19 @@ weak_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
weak_alias (__malloc_stats, malloc_stats)
weak_alias (__malloc_usable_size, malloc_usable_size)
weak_alias (__malloc_trim, malloc_trim)
+weak_alias (__malloc_get_state, malloc_get_state)
+weak_alias (__malloc_set_state, malloc_set_state)
#endif
/*
History:
+ V2.6.4-pt3 Thu Feb 20 1997 Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
+ * Added malloc_get/set_state() (mainly for use in GNU emacs),
+ using interface from Marcus Daniels
+ * All parameters are now adjustable via environment variables
+
V2.6.4-pt2 Sat Dec 14 1996 Wolfram Gloger (wmglo@dent.med.uni-muenchen.de)
* Added debugging hooks
* Fixed possible deadlock in realloc() when out of memory
diff --git a/malloc/malloc.h b/malloc/malloc.h
index b27d06252c..53b9d1b206 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -171,6 +171,13 @@ extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr));
/* Prints brief summary statistics on stderr. */
extern void malloc_stats __MALLOC_P ((void));
+/* Record the state of all malloc variables in an opaque data structure. */
+extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void));
+
+/* Restore the state of all malloc variables from data obtained with
+ malloc_get_state(). */
+extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr));
+
#if defined(__GLIBC__) || defined(MALLOC_HOOKS)
/* Hooks for debugging versions. */
diff --git a/malloc/thread-m.h b/malloc/thread-m.h
index 10da26ba32..8307f256ff 100644
--- a/malloc/thread-m.h
+++ b/malloc/thread-m.h
@@ -1,6 +1,6 @@
/* Basic platform-independent macro definitions for mutexes and
thread-specific data.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>, 1996.
@@ -66,19 +66,37 @@ static Void_t *malloc_key_data;
(__pthread_mutex_unlock != NULL ? __pthread_mutex_unlock (m) : 0)
#elif defined(MUTEX_INITIALIZER)
+/* Assume hurd, with cthreads */
-typedef thread_t thread_id;
+/* Cthreads `mutex_t' is a pointer to a mutex, and malloc wants just the
+ mutex itself. */
+#undef mutex_t
+#define mutex_t struct mutex
-/* mutex */
-typedef mutex_t mutex_t;
+#undef mutex_lock
+#define mutex_lock(m) (__mutex_lock(m), 0)
+
+#undef mutex_unlock
+#define mutex_unlock(m) (__mutex_unlock(m), 0)
+
+#define mutex_trylock(m) (!__mutex_trylock(m))
+
+#include <hurd/threadvar.h>
/* thread specific data */
-typedef pthread_key_t tsd_key_t;
+typedef int tsd_key_t;
+
+static int tsd_keys_alloced = 0;
+
+#define tsd_key_create(key, destr) \
+ (assert (tsd_keys_alloced == 0), tsd_keys_alloced++)
+#define tsd_setspecific(key, data) \
+ (*__hurd_threadvar_location (_HURD_THREADVAR_MALLOC) = (unsigned long)(data))
+#define tsd_getspecific(key, vptr) \
+ ((vptr) = (void *)*__hurd_threadvar_location (_HURD_THREADVAR_MALLOC))
-#define mutex_init(m) __mutex_init (m)
-#define mutex_lock(m) __mutex_lock (m)
-#define mutex_trylock(m) __mutex_trylock (m)
-#define mutex_unlock(m) __mutex_unlock (m)
+/* No we're *not* using pthreads. */
+#define __pthread_initialize ((void (*)(void))0)
#else
diff --git a/manual/stdio-fp.c b/manual/stdio-fp.c
new file mode 100644
index 0000000000..db9480782d
--- /dev/null
+++ b/manual/stdio-fp.c
@@ -0,0 +1,28 @@
+/* This program is to generate one of the examples in stdio.texi. */
+
+#include <stdio.h>
+
+
+static void
+print (double v)
+{
+ printf ("|%13.4a|%13.4f|%13.4e|%13.4g|\n", v, v, v, v);
+}
+
+
+int
+main (void)
+{
+ print (0.0);
+ print (0.5);
+ print (1.0);
+ print (-1.0);
+ print (100.0);
+ print (1000.0);
+ print (10000.0);
+ print (12345.0);
+ print (100000.0);
+ print (123456.0);
+
+ return 0;
+}
diff --git a/manual/stdio.texi b/manual/stdio.texi
index e922fd17d8..04c635b054 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -1007,6 +1007,12 @@ whichever is more appropriate for its magnitude. @samp{%g} uses
lower-case letters and @samp{%G} uses upper-case. @xref{Floating-Point
Conversions}, for details.
+@item @samp{%a}, @samp{%A}
+Print a floating-point number in a hexadecimal fractional notation which
+the exponent to base 2 represented in decimal digits. @samp{%a} uses
+lower-case letters and @samp{%A} uses upper-case. @xref{Floating-Point
+Conversions}, for details.
+
@item @samp{%c}
Print a single character. @xref{Other Output Conversions}.
@@ -1194,6 +1200,34 @@ than -4 or greater than or equal to the precision; otherwise they use the
of the result and a decimal-point character appears only if it is
followed by a digit.
+The @samp{%a} and @samp{%A} conversions are meant for representing
+floating-point number exactly in textual form so that they can be
+exchanged as texts between different programs and/or machines. The
+numbers are represented is the form
+@w{[@code{-}]@code{0x}@var{h}@code{.}@var{hhh}@code{p}[@code{+}|@code{-}]@var{dd}}.
+At the left of the decimal-point character exactly one digit is print.
+This character is only @code{0} is the number is denormalized.
+Otherwise the value is unspecifed; it is implemention dependent how many
+bits are used. The number of hexadecimal digits on the right side of
+the decimal-point character is equal to the precision. If the precision
+is zero it is determined to be large enough to provide an exact
+representation of the number (or it is large enough to distinguish two
+adjacent values if the @code{FLT_RADIX} is not a power of 2,
+@pxref{Floating Point Parameters}) For the @samp{%a} conversion
+lower-case characters are used to represent the hexadecimal number and
+the prefix and exponent sign are printed as @code{0x} and @code{p}
+respectively. Otherwise upper-case characters are used and @code{0X}
+and @code{P} are used for the representation of prefix and exponent
+string. The exponent to the base of two is printed as a decimal number
+using at least one digit but at most as many digits as necessary to
+represent the value exactly.
+
+If the value to be printed represents infinity or a NaN, the output is
+@w{[@code{-}]@code{inf}} or @code{nan} respectively if the conversion
+specifier is @samp{%a}, @samp{%e}, @samp{%f}, or @samp{%g} and it is
+@w{[@code{-}]@code{INF}} or @code{NAN} respectively if the conversion is
+@samp{%A}, @samp{%E}, or @samp{%G}.
+
The following flags can be used to modify the behavior:
@comment We use @asis instead of @samp so we can have ` ' as an item.
@@ -1255,21 +1289,22 @@ floating-point conversions. All of the numbers were printed using
this template string:
@smallexample
-"|%12.4f|%12.4e|%12.4g|\n"
+"|%13.4a|%13.4f|%13.4e|%13.4g|\n"
@end smallexample
Here is the output:
@smallexample
-| 0.0000| 0.0000e+00| 0|
-| 1.0000| 1.0000e+00| 1|
-| -1.0000| -1.0000e+00| -1|
-| 100.0000| 1.0000e+02| 100|
-| 1000.0000| 1.0000e+03| 1000|
-| 10000.0000| 1.0000e+04| 1e+04|
-| 12345.0000| 1.2345e+04| 1.234e+04|
-| 100000.0000| 1.0000e+05| 1e+05|
-| 123456.0000| 1.2346e+05| 1.234e+05|
+| 0x0.0000p+0| 0.0000| 0.0000e+00| 0|
+| 0x1.0000p-1| 0.5000| 5.0000e-01| 0.5|
+| 0x1.0000p+0| 1.0000| 1.0000e+00| 1|
+| -0x1.0000p+0| -1.0000| -1.0000e+00| -1|
+| 0x1.9000p+6| 100.0000| 1.0000e+02| 100|
+| 0x1.f400p+9| 1000.0000| 1.0000e+03| 1000|
+| 0x1.3880p+13| 10000.0000| 1.0000e+04| 1e+04|
+| 0x1.81c8p+13| 12345.0000| 1.2345e+04| 1.234e+04|
+| 0x1.86a0p+16| 100000.0000| 1.0000e+05| 1e+05|
+| 0x1.e240p+16| 123456.0000| 1.2346e+05| 1.235e+05|
@end smallexample
Notice how the @samp{%g} conversion drops trailing zeros.
diff --git a/math/math.h b/math/math.h
index b713163f76..eb8a4f202d 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1,5 +1,5 @@
/* Declarations for math functions.
- Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc.
+ Copyright (C) 1991, 92, 93, 95, 96, 97 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
@@ -99,9 +99,12 @@ extern _LIB_VERSION_TYPE _LIB_VERSION;
#endif
-#ifdef __USE_SVID
+#if defined __USE_SVID && !defined __cplusplus
/* In SVID error handling, `matherr' is called with this description
- of the exceptional condition. */
+ of the exceptional condition.
+
+ We have a problem when using C++ since `exception' is reserved in
+ C++. */
struct exception
{
int type;
@@ -128,7 +131,7 @@ extern int matherr __P ((struct exception *));
#define HUGE FLT_MAX
#include <float.h> /* Defines FLT_MAX. */
-#endif
+#endif /* SVID && !C++ */
#ifdef __USE_BSD
diff --git a/misc/error.c b/misc/error.c
index 2a7df0210d..f49e4a7983 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -71,6 +71,11 @@ unsigned int error_message_count;
#define program_name program_invocation_name
#include <errno.h>
+/* In GNU libc we want do not want to use the common name `error' directly.
+ Instead make it a weak alias. */
+#define error __error
+#define error_at_line __error_at_line
+
#else
/* The calling program should define program_name and set it to the
@@ -230,3 +235,11 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist)
if (status)
exit (status);
}
+
+#ifdef _LIBC
+/* Make the weak alias. */
+#undef error
+#undef error_at_line
+weak_alias (__error, error)
+weak_alias (__error_at_line, error_at_line)
+#endif
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index e90dd0f220..f9dcce4c8d 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 93, 94, 95, 96, 97 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
@@ -102,4 +102,9 @@
#define __attribute__(xyz) /* Ignore. */
#endif
+
+/* For now no version of gcc knows the `restrict' keyword. Define it
+ for now unconditionally to the empty string. */
+#define __restrict
+
#endif /* sys/cdefs.h */
diff --git a/rellns-sh b/rellns-sh
index 61f18c4146..abe758a997 100755
--- a/rellns-sh
+++ b/rellns-sh
@@ -1,6 +1,6 @@
#! /bin/sh
# rellns-sh - Simplified ln program to generate relative symbolic link.
-# Copyright (C) 1996 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Written by Ulrich Drepper <drepper@cygnus.com>, October 1996
#
# This program is free software; you can redistribute it and/or modify
@@ -22,12 +22,6 @@ if test $# -ne 2; then
exit 1
fi
-# We only handle the case where SOURCE is the name of an existing file
-if test ! -f $1; then
- echo "rellns: $1 must name an existing file" >&2
- exit 1
-fi
-
case $1 in
/*)
# Make both paths absolute.
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 814374b8ae..d1d922ed36 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -25,7 +25,7 @@ headers := stdio_lim.h printf.h
routines := \
ctermid cuserid \
- vfprintf vprintf printf_fp reg-printf printf-prs _itoa \
+ vfprintf vprintf printf_fp reg-printf printf-prs _itoa printf_fphex \
fprintf printf snprintf sprintf asprintf dprintf \
vfscanf \
fscanf scanf sscanf \
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index dede144b8d..8cff7a4d66 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -1,5 +1,5 @@
/* Floating point output for `printf'.
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
@@ -291,12 +291,12 @@ __printf_fp (FILE *fp,
/* Check for special values: not a number or infinity. */
if (__isnanl (fpnum.ldbl))
{
- special = "NaN";
+ special = isupper (info->spec) ? "NAN" : "nan";
is_neg = 0;
}
else if (__isinfl (fpnum.ldbl))
{
- special = "Inf";
+ special = isupper (info->spec) ? "INF" : "inf";
is_neg = fpnum.ldbl < 0;
}
else
@@ -316,12 +316,12 @@ __printf_fp (FILE *fp,
/* Check for special values: not a number or infinity. */
if (__isnan (fpnum.dbl))
{
- special = "NaN";
+ special = isupper (info->spec) ? "NAN" : "nan";
is_neg = 0;
}
else if (__isinf (fpnum.dbl))
{
- special = "Inf";
+ special = isupper (info->spec) ? "INF" : "inf";
is_neg = fpnum.dbl < 0;
}
else
diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c
new file mode 100644
index 0000000000..d442b56099
--- /dev/null
+++ b/stdio-common/printf_fphex.c
@@ -0,0 +1,440 @@
+/* Print floating point number in hexadecimal notation according to
+ ISO C 9X.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ 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 <ctype.h>
+#include <ieee754.h>
+#include <math.h>
+#include <printf.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "_itoa.h"
+#include "../locale/localeinfo.h"
+
+/* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */
+#include <assert.h>
+
+/* This defines make it possible to use the same code for GNU C library and
+ the GNU I/O library. */
+#ifdef USE_IN_LIBIO
+# include <libioP.h>
+# define PUT(f, s, n) _IO_sputn (f, s, n)
+# define PAD(f, c, n) _IO_padn (f, c, n)
+/* We use this file GNU C library and GNU I/O library. So make
+ names equal. */
+# undef putc
+# define putc(c, f) _IO_putc_unlocked (c, f)
+# define size_t _IO_size_t
+# define FILE _IO_FILE
+#else /* ! USE_IN_LIBIO */
+# define PUT(f, s, n) fwrite (s, 1, n, f)
+# define PAD(f, c, n) __printf_pad (f, c, n)
+ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
+#endif /* USE_IN_LIBIO */
+
+/* Macros for doing the actual output. */
+
+#define outchar(ch) \
+ do \
+ { \
+ register const int outc = (ch); \
+ if (putc (outc, fp) == EOF) \
+ return -1; \
+ ++done; \
+ } while (0)
+
+#define PRINT(ptr, len) \
+ do \
+ { \
+ int outlen = (len); \
+ const char *cp = (ptr); \
+ while (outlen-- > 0) \
+ outchar (*cp++); \
+ } while (0)
+
+#define PADN(ch, len) \
+ do \
+ { \
+ if (PAD (fp, ch, len) != len) \
+ return -1; \
+ done += len; \
+ } \
+ while (0)
+
+
+int
+__printf_fphex (FILE *fp,
+ const struct printf_info *info,
+ const void *const *args)
+{
+ /* The floating-point value to output. */
+ union
+ {
+ union ieee754_double dbl;
+ union ieee854_long_double ldbl;
+ }
+ fpnum;
+
+ /* Locale-dependent representation of decimal point. */
+ wchar_t decimal;
+
+ /* "NaN" or "Inf" for the special cases. */
+ const char *special = NULL;
+
+ /* Buffer for the generated number string for the mantissa. The
+ maximal size for the mantissa is 64 bits. */
+ char numbuf[16];
+ char *numstr;
+ char *numend;
+ int negative;
+
+ /* The maximal exponent of two in decimal notation has 5 digits. */
+ char expbuf[5];
+ char *expstr;
+ int expnegative;
+ int exponent;
+
+ /* Non-zero is mantissa is zero. */
+ int zero_mantissa;
+
+ /* The leading digit before the decimal point. */
+ char leading;
+
+ /* Precision. */
+ int precision = info->prec;
+
+ /* Width. */
+ int width = info->width;
+
+ /* Number of characters written. */
+ int done = 0;
+
+
+ /* Figure out the decimal point character. */
+ if (info->extra == 0)
+ {
+ if (mbtowc (&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
+ strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0)
+ decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
+ }
+ else
+ {
+ if (mbtowc (&decimal, _NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT),
+ strlen (_NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT))) <= 0)
+ decimal = (wchar_t) *_NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT);
+ }
+ /* Give default value. */
+ if (decimal == L'\0')
+ decimal = L'.';
+
+
+ /* Fetch the argument value. */
+ if (info->is_long_double && sizeof (long double) > sizeof (double))
+ {
+ fpnum.ldbl.d = *(const long double *) args[0];
+
+ /* Check for special values: not a number or infinity. */
+ if (__isnanl (fpnum.ldbl.d))
+ {
+ special = isupper (info->spec) ? "NAN" : "nan";
+ negative = 0;
+ }
+ else
+ {
+ if (__isinfl (fpnum.ldbl.d))
+ special = isupper (info->spec) ? "INF" : "inf";
+
+ negative = fpnum.ldbl.d < 0;
+ }
+ }
+ else
+ {
+ fpnum.dbl.d = *(const double *) args[0];
+
+ /* Check for special values: not a number or infinity. */
+ if (__isnan (fpnum.dbl.d))
+ {
+ special = isupper (info->spec) ? "NAN" : "nan";
+ negative = 0;
+ }
+ else
+ {
+ if (__isinf (fpnum.dbl.d))
+ special = isupper (info->spec) ? "INF" : "inf";
+
+ negative = fpnum.dbl.d < 0;
+ }
+ }
+
+ if (special)
+ {
+ int width = info->prec > info->width ? info->prec : info->width;
+
+ if (negative || info->showsign || info->space)
+ --width;
+ width -= 3;
+
+ if (!info->left && width > 0)
+ PADN (' ', width);
+
+ if (negative)
+ outchar ('-');
+ else if (info->showsign)
+ outchar ('+');
+ else if (info->space)
+ outchar (' ');
+
+ PRINT (special, 3);
+
+ if (info->left && width > 0)
+ PADN (' ', width);
+
+ return done;
+ }
+
+ /* We are handling here only 64 and 80 bit IEEE foating point
+ numbers. */
+ if (info->is_long_double == 0 || sizeof (double) == sizeof (long double))
+ {
+ /* We have 52 bits of mantissa plus one implicit digit. Since
+ 52 bits are representable without rest using hexadecimal
+ digits we use only the implicit digits for the number before
+ the decimal point. */
+ if (sizeof (unsigned long int) > 6)
+ {
+ unsigned long int num;
+
+ num = (((unsigned long int) fpnum.dbl.ieee.mantissa0) << 32
+ | fpnum.dbl.ieee.mantissa1);
+
+ zero_mantissa = num == 0;
+
+ numstr = _itoa_word (num, numbuf + sizeof numbuf, 16,
+ info->spec == 'A');
+ }
+ else
+ {
+ unsigned long long int num;
+
+ num = (((unsigned long long int) fpnum.dbl.ieee.mantissa0) << 32
+ | fpnum.dbl.ieee.mantissa1);
+
+ zero_mantissa = num == 0;
+
+ numstr = _itoa (num, numbuf + sizeof numbuf, 16, info->spec == 'A');
+ }
+
+ /* Fill with zeroes. */
+ while (numstr > numbuf + (sizeof numbuf - 13)) /* 52 ÷ 4 = 13 */
+ *--numstr = '0';
+
+ leading = fpnum.dbl.ieee.exponent == 0 ? '0' : '1';
+
+ exponent = fpnum.dbl.ieee.exponent;
+
+ if (exponent != 0 && exponent < IEEE754_DOUBLE_BIAS)
+ {
+ expnegative = 1;
+ exponent = abs (exponent - IEEE754_DOUBLE_BIAS);
+ }
+ else
+ {
+ expnegative = 0;
+ if (exponent != 0)
+ exponent -= IEEE754_DOUBLE_BIAS;
+ }
+ }
+ else
+ {
+ /* The "strange" 80 bit format on ix86 and m68k has an explicit
+ leading digit in the 64 bit mantissa. */
+ assert (sizeof (long double) == 12);
+
+ if (sizeof (unsigned long int) > 6)
+ {
+ unsigned long int num;
+
+ num = (((unsigned long int) fpnum.dbl.ieee.mantissa0) << 32
+ | fpnum.dbl.ieee.mantissa1);
+
+ zero_mantissa = num == 0;
+
+ numstr = _itoa_word (num, numbuf + sizeof numbuf, 16,
+ info->spec == 'A');
+ }
+ else
+ {
+ unsigned long long int num;
+
+ num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32
+ | fpnum.ldbl.ieee.mantissa1);
+
+ zero_mantissa = num == 0;
+
+ numstr = _itoa (num, numbuf + sizeof numbuf, 16, info->spec == 'A');
+ }
+
+ /* We use a full nibble for the leading digit. */
+ leading = *numstr++;
+
+ /* Fill with zeroes. */
+ while (numstr > numbuf + (sizeof numbuf - 15)) /* 60 ÷ 4 = 15 */
+ *--numstr = '0';
+
+ /* We have 3 bits from the mantissa in the leading nibble. */
+ exponent = fpnum.ldbl.ieee.exponent - 3;
+
+ if (exponent != 0 && exponent < IEEE854_LONG_DOUBLE_BIAS)
+ {
+ expnegative = 1;
+ exponent = abs (exponent - IEEE854_LONG_DOUBLE_BIAS);
+ }
+ else
+ {
+ expnegative = 0;
+ if (exponent != 0)
+ exponent -= IEEE854_LONG_DOUBLE_BIAS;
+ }
+ }
+
+ /* Look for trailing zeroes. */
+ if (! zero_mantissa)
+ {
+ numend = numbuf + sizeof numbuf;
+ while (numend[-1] == '0')
+ --numend;
+
+ if (precision == -1)
+ precision = numend - numstr;
+ else if (precision < numend - numstr
+ && (numstr[precision] > 5
+ || (numstr[precision] == 5
+ && (precision + 1 < numend - numstr
+ /* Round to even. */
+ || (precision > 0
+ && ((numstr[precision - 1] & 1)
+ ^ (isdigit (numstr[precision - 1]) == 0)))
+ || (precision == 0
+ && ((leading & 1)
+ ^ (isdigit (leading) == 0)))))))
+ {
+ /* Round up. */
+ int cnt = precision;
+ while (--cnt >= 0)
+ {
+ char ch = numstr[cnt];
+ /* We assume that the digits and the letters are ordered
+ like in ASCII. This is true for the rest of GNU, too. */
+ if (ch == '9')
+ {
+ numstr[cnt] = info->spec; /* This is tricky,
+ think about it! */
+ break;
+ }
+ else if (tolower (ch) < 'f')
+ {
+ ++numstr[cnt];
+ break;
+ }
+ else
+ numstr[cnt] = '0';
+ }
+ if (cnt < 0)
+ {
+ /* The mantissa so far was fff...f Now increment the
+ leading digit. Here it is again possible that we
+ get an overflow. */
+ if (leading == '9')
+ leading = info->spec;
+ else if (tolower (leading) < 'f')
+ ++leading;
+ else
+ {
+ leading = 1;
+ if (expnegative)
+ {
+ exponent += 4;
+ if (exponent >= 0)
+ expnegative = 0;
+ }
+ else
+ exponent += 4;
+ }
+ }
+ }
+ }
+ else
+ numend = numstr;
+
+ /* Now we can compute the exponent string. */
+ expstr = _itoa_word (exponent, expbuf + sizeof expbuf, 10, 0);
+
+ /* Now we have all information to compute the size. */
+ width -= ((negative || info->showsign || info->space)
+ /* Sign. */
+ + 2 + 1 + 1 + precision + 1 + 1
+ /* 0x h . hhh P ExpoSign. */
+ + ((expbuf + sizeof expbuf) - expstr));
+ /* Exponent. */
+
+ /* A special case if when the mantissa is zero and the `#' is not
+ given. In this case we must not print the decimal point. */
+ if (zero_mantissa && precision == 0 && !info->alt)
+ ++width; /* This nihilates the +1 for the decimal-point
+ character in the following equation. */
+
+ if (!info->left && width > 0)
+ PADN (' ', width);
+
+ if (negative)
+ outchar ('-');
+ else if (info->showsign)
+ outchar ('+');
+ else if (info->space)
+ outchar (' ');
+
+ outchar ('0');
+ outchar (info->spec == 'A' ? 'X' : 'x');
+ outchar (leading);
+
+ if (!zero_mantissa || precision != 0 || info->alt)
+ outchar (decimal);
+
+ if (!zero_mantissa || precision != 0)
+ {
+ PRINT (numstr, MIN (numend - numstr, precision));
+ if (precision > numend - numstr)
+ PADN ('0', precision - (numend - numstr));
+ }
+
+ if (info->left && info->pad == '0' && width > 0)
+ PADN ('0', width);
+
+ outchar (info->spec == 'A' ? 'P' : 'p');
+
+ outchar (expnegative ? '-' : '+');
+
+ PRINT (expstr, (expbuf + sizeof expbuf) - expstr);
+
+ if (info->left && info->pad != '0' && width > 0)
+ PADN (info->pad, width);
+
+ return done;
+}
diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c
index d76d95b1b7..85be441b5b 100644
--- a/stdio-common/tstscanf.c
+++ b/stdio-common/tstscanf.c
@@ -140,5 +140,15 @@ main (int argc, char **argv)
if (out != stdout)
pclose (out);
+ fputs ("Test 3:\n", out);
+ {
+ int res, val, n;
+
+ res = sscanf ("-242", "%3o%n", &val, &n);
+ printf ("res = %d, val = %d, n = %d\n", res, val, n);
+ if (res != 1 || val != -20 || n != 3)
+ return 1;
+ }
+
exit(EXIT_SUCCESS);
}
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index eda0d7bd8e..c206c2f0ac 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -238,7 +238,7 @@ 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, /* 'C' */ 25,
+ 0, /* 'A' */ 26, 0, /* 'C' */ 25,
0, /* 'E' */ 19, 0, /* 'G' */ 19,
0, 0, 0, 0,
/* 'L' */ 12, 0, 0, 0,
@@ -246,7 +246,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
0, 0, 0, 0,
/* 'X' */ 18, 0, /* 'Z' */ 13, 0,
0, 0, 0, 0,
- 0, 0, 0, /* 'c' */ 20,
+ 0, /* 'a' */ 26, 0, /* 'c' */ 20,
/* 'd' */ 15, /* 'e' */ 19, /* 'f' */ 19, /* 'g' */ 19,
/* 'h' */ 10, /* 'i' */ 15, 0, 0,
/* 'l' */ 11, /* 'm' */ 24, /* 'n' */ 23, /* 'o' */ 17,
@@ -270,7 +270,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[26] = \
+ static const void *step0_jumps[27] = \
{ \
REF (form_unknown), \
REF (flag_space), /* for ' ' */ \
@@ -297,10 +297,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
REF (form_strerror), /* for 'm' */ \
- REF (form_wcharacter) /* for 'C' */ \
+ REF (form_wcharacter), /* for 'C' */ \
+ REF (form_floathex) /* for 'A', 'a' */ \
}; \
/* Step 1: after processing width. */ \
- static const void *step1_jumps[26] = \
+ static const void *step1_jumps[27] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -327,10 +328,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
REF (form_strerror), /* for 'm' */ \
- REF (form_wcharacter) /* for 'C' */ \
+ REF (form_wcharacter), /* for 'C' */ \
+ REF (form_floathex) /* for 'A', 'a' */ \
}; \
/* Step 2: after processing precision. */ \
- static const void *step2_jumps[26] = \
+ static const void *step2_jumps[27] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -357,10 +359,11 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
REF (form_strerror), /* for 'm' */ \
- REF (form_wcharacter) /* for 'C' */ \
+ REF (form_wcharacter), /* for 'C' */ \
+ REF (form_floathex) /* for 'A', 'a' */ \
}; \
/* Step 3: after processing first 'l' modifier. */ \
- static const void *step3_jumps[26] = \
+ static const void *step3_jumps[27] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -387,12 +390,13 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
REF (form_strerror), /* for 'm' */ \
- REF (form_wcharacter) /* for 'C' */ \
+ REF (form_wcharacter), /* for 'C' */ \
+ REF (form_floathex) /* for 'A', 'a' */ \
}
#define STEP4_TABLE \
/* Step 4: processing format specifier. */ \
- static const void *step4_jumps[26] = \
+ static const void *step4_jumps[27] = \
{ \
REF (form_unknown), \
REF (form_unknown), /* for ' ' */ \
@@ -419,7 +423,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
REF (form_pointer), /* for 'p' */ \
REF (form_number), /* for 'n' */ \
REF (form_strerror), /* for 'm' */ \
- REF (form_wcharacter) /* for 'C' */ \
+ REF (form_wcharacter), /* for 'C' */ \
+ REF (form_floathex) /* for 'A', 'a' */ \
}
@@ -702,6 +707,53 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
} \
break; \
\
+ LABEL (form_floathex): \
+ { \
+ /* FLoating point number printed as hexadecimal number. */ \
+ extern int __printf_fphex __P ((FILE *, const struct printf_info *, \
+ const void **const)); \
+ const void *ptr; \
+ int function_done; \
+ \
+ if (fspec == NULL) \
+ { \
+ struct printf_info info = { prec: prec, \
+ width: width, \
+ spec: spec, \
+ is_long_double: is_long_double, \
+ is_short: is_short, \
+ is_long: is_long, \
+ alt: alt, \
+ space: space, \
+ left: left, \
+ showsign: showsign, \
+ group: group, \
+ pad: pad, \
+ extra: 0 }; \
+ \
+ if (is_long_double) \
+ the_arg.pa_long_double = va_arg (ap, long double); \
+ else \
+ the_arg.pa_double = va_arg (ap, double); \
+ ptr = (const void *) &the_arg; \
+ \
+ function_done = __printf_fphex (s, &info, &ptr); \
+ } \
+ else \
+ { \
+ ptr = (const void *) &args_value[fspec->data_arg]; \
+ \
+ function_done = __printf_fphex (s, &fspec->info, &ptr); \
+ } \
+ \
+ if (function_done < 0) \
+ /* Error in print handler. */ \
+ return -1; \
+ \
+ done += function_done; \
+ } \
+ break; \
+ \
LABEL (form_character): \
/* Character. */ \
if (is_long) \
@@ -881,7 +933,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
done = 0;
grouping = (const char *) -1;
#ifdef __va_copy
- /* This macro will be available soon in gcc's <stdarg.h>. Me need it
+ /* This macro will be available soon in gcc's <stdarg.h>. We need it
since on some systems `va_list' is not an integral type. */
__va_copy (ap_save, ap);
#else
@@ -1405,16 +1457,16 @@ printf_unknown (FILE *s, const struct printf_info *info,
if (info->width != 0)
{
w = _itoa_word (info->width, workend + 1, 10, 0);
- while (++w <= workend)
- outchar (*w);
+ while (w <= workend)
+ outchar (*w++);
}
if (info->prec != -1)
{
outchar ('.');
w = _itoa_word (info->prec, workend + 1, 10, 0);
- while (++w <= workend)
- outchar (*w);
+ while (w <= workend)
+ outchar (*w++);
}
if (info->spec != '\0')
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index f201c46775..8653088751 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -841,9 +841,9 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
if (flags & LONGDBL)
{
if (number_signed)
- num.q = __strtoq_internal (wp, &tw, base, flags & GROUP);
+ num.q = __strtoll_internal (wp, &tw, base, flags & GROUP);
else
- num.uq = __strtouq_internal (wp, &tw, base, flags & GROUP);
+ num.uq = __strtoull_internal (wp, &tw, base, flags & GROUP);
}
else
{
diff --git a/stdio/stdio.h b/stdio/stdio.h
index bd2ffa8eb5..b2d064483b 100644
--- a/stdio/stdio.h
+++ b/stdio/stdio.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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
@@ -307,7 +307,7 @@ extern char *tmpnam_r __P ((char *__s));
#endif
-#if defined(__USE_SVID) || defined(__USE_XOPEN)
+#if defined __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.
@@ -339,8 +339,9 @@ extern int fcloseall __P ((void));
/* Open a file and create a new stream for it. */
extern FILE *fopen __P ((__const char *__filename, __const char *__modes));
/* Open a file, replacing an existing stream with it. */
-extern FILE *freopen __P ((__const char *__filename,
- __const char *__modes, FILE *__stream));
+extern FILE *freopen __P ((__const char *__restrict __filename,
+ __const char *__rstrict __modes,
+ FILE *__restrict __stream));
/* Return a new, zeroed, stream.
You must set its cookie and io_mode.
@@ -376,11 +377,11 @@ extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
/* If BUF is NULL, make STREAM unbuffered.
Else make it use buffer BUF, of size BUFSIZ. */
-extern void setbuf __P ((FILE *__stream, char *__buf));
+extern void setbuf __P ((FILE *__restrict __stream, char *__restrict __buf));
/* Make STREAM use buffering mode MODE.
If BUF is not NULL, use N bytes of it for buffering;
else allocate an internal buffer N bytes long. */
-extern int setvbuf __P ((FILE *__stream, char *__buf,
+extern int setvbuf __P ((FILE *__restrict __stream, char *__restrict __buf,
int __modes, size_t __n));
#ifdef __USE_BSD
@@ -394,24 +395,29 @@ extern void setlinebuf __P ((FILE *__stream));
/* Write formatted output to STREAM. */
-extern int fprintf __P ((FILE *__stream, __const char *__format, ...));
+extern int fprintf __P ((FILE *__restrict __stream,
+ __const char *__restrict __format, ...));
/* Write formatted output to stdout. */
-extern int printf __P ((__const char *__format, ...));
+extern int printf __P ((__const char *__restrict __format, ...));
/* Write formatted output to S. */
-extern int sprintf __P ((char *__s, __const char *__format, ...));
+extern int sprintf __P ((char *__restrict __s,
+ __const char *__restrict __format, ...));
/* Write formatted output to S from argument list ARG. */
-extern int vfprintf __P ((FILE *__s, __const char *__format,
+extern int vfprintf __P ((FILE *__restrict __s,
+ __const char *__restrict __format,
__gnuc_va_list __arg));
/* Write formatted output to stdout from argument list ARG. */
-extern int vprintf __P ((__const char *__format, __gnuc_va_list __arg));
+extern int vprintf __P ((__const char *__restrict __format,
+ __gnuc_va_list __arg));
/* Write formatted output to S from argument list ARG. */
-extern int vsprintf __P ((char *__s, __const char *__format,
+extern int vsprintf __P ((char *__restrict __s,
+ __const char *__restrict __format,
__gnuc_va_list __arg));
#ifdef __OPTIMIZE__
extern __inline int
-vprintf (const char *__fmt, __gnuc_va_list __arg)
+vprintf (const char *__restrict __fmt, __gnuc_va_list __arg)
{
return vfprintf (stdout, __fmt, __arg);
}
@@ -443,11 +449,13 @@ extern int dprintf __P ((int __fd, __const char *__fmt, ...));
/* Read formatted input from STREAM. */
-extern int fscanf __P ((FILE *__stream, __const char *__format, ...));
+extern int fscanf __P ((FILE *__restrict __stream,
+ __const char *__restrict __format, ...));
/* Read formatted input from stdin. */
-extern int scanf __P ((__const char *__format, ...));
+extern int scanf __P ((__const char *__restrict __format, ...));
/* Read formatted input from S. */
-extern int sscanf __P ((__const char *__s, __const char *__format, ...));
+extern int sscanf __P ((__const char *__restrict __s,
+ __const char *__restrict __format, ...));
#ifdef __USE_GNU
/* Read formatted input from S into argument list ARG. */
@@ -556,7 +564,8 @@ extern int putw __P ((int __w, FILE *__stream));
/* Get a newline-terminated string of finite length from STREAM. */
-extern char *fgets __P ((char *__s, int __n, FILE *__stream));
+extern char *fgets __P ((char *__restrict __s, int __n,
+ FILE *__restrict __stream));
/* Get a newline-terminated string from stdin, removing the newline.
DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. */
@@ -582,27 +591,17 @@ ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
#ifdef __OPTIMIZE__
extern __inline ssize_t
-__getline (char **__lineptr, size_t *__n, FILE *__stream)
-{
- return __getdelim (__lineptr, __n, '\n', __stream);
-}
-
-extern __inline ssize_t
-getdelim (char **__lineptr, size_t *__n, int __delimiter, FILE *__stream)
-{
- return __getdelim (__lineptr, __n, __delimiter, __stream);
-}
-extern __inline ssize_t
getline (char **__lineptr, size_t *__n, FILE *__stream)
{
- return __getline (__lineptr, __n, __stream);
+ return __getdelim (__lineptr, __n, '\n', __stream);
}
#endif /* Optimizing. */
#endif
/* Write a string to STREAM. */
-extern int fputs __P ((__const char *__s, FILE *__stream));
+extern int fputs __P ((__const char *__restrict __s,
+ FILE *__restrict __stream));
/* Write a string, followed by a newline, to stdout. */
extern int puts __P ((__const char *__s));
@@ -612,11 +611,11 @@ extern int ungetc __P ((int __c, FILE *__stream));
/* Read chunks of generic data from STREAM. */
-extern size_t fread __P ((__ptr_t __ptr, size_t __size,
- size_t __n, FILE *__stream));
+extern size_t fread __P ((__ptr_t __restrict __ptr, size_t __size,
+ size_t __n, FILE *__restrict __stream));
/* Write chunks of generic data to STREAM. */
-extern size_t fwrite __P ((__const __ptr_t __ptr, size_t __size,
- size_t __n, FILE *__s));
+extern size_t fwrite __P ((__const __ptr_t __restrict __ptr, size_t __size,
+ size_t __n, FILE *__restrict __s));
/* Seek to a certain position on STREAM. */
@@ -627,7 +626,7 @@ extern long int ftell __P ((FILE *__stream));
extern void rewind __P ((FILE *__stream));
/* Get STREAM's position. */
-extern int fgetpos __P ((FILE *__stream, fpos_t *__pos));
+extern int fgetpos __P ((FILE *__restrict __stream, fpos_t *__restrict __pos));
/* Set STREAM's position. */
extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
diff --git a/stdlib/Makefile b/stdlib/Makefile
index b2641e4ba8..af80c0b3d8 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -38,7 +38,7 @@ routines := \
drand48_r erand48_r lrand48_r nrand48_r mrand48_r jrand48_r \
srand48_r seed48_r lcong48_r \
drand48-iter \
- strtol strtoul strtoq strtouq \
+ strtol strtoul strtoll strtoull \
strtof strtod strtold \
system canonicalize \
a64l l64a \
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 758241ee43..aaabbc8edc 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -79,108 +79,129 @@ extern int atoi __P ((__const char *__nptr));
/* Convert a string to a long integer. */
extern long int atol __P ((__const char *__nptr));
-#if defined (__GNUC__) && defined (__USE_MISC)
+#if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
/* These functions will part of the standard C library in ISO C 9X. */
extern long long int atoll __P ((__const char *__nptr));
#endif
/* Convert a string to a floating-point number. */
-extern double strtod __P ((__const char *__nptr, char **__endptr));
+extern double strtod __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr));
#ifdef __USE_GNU
/* Likewise for `float' and `long double' sizes of floating-point numbers. */
-extern float strtof __P ((__const char *__nptr, char **__endptr));
-extern __long_double_t strtold __P ((__const char *__nptr, char **__endptr));
+extern float strtof __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr));
+
+extern __long_double_t strtold __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr));
#endif
/* Convert a string to a long integer. */
-extern long int strtol __P ((__const char *__nptr, char **__endptr,
- int __base));
+extern long int strtol __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base));
/* Convert a string to an unsigned long integer. */
-extern unsigned long int strtoul __P ((__const char *__nptr,
- char **__endptr, int __base));
+extern unsigned long int strtoul __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base));
-#if defined (__GNUC__) && defined (__USE_BSD)
+#if defined __GNUC__ && defined __USE_BSD
/* Convert a string to a quadword integer. */
-extern long long int strtoq __P ((__const char *__nptr, char **__endptr,
- int __base));
+extern long long int strtoq __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base));
/* Convert a string to an unsigned quadword integer. */
-extern unsigned long long int strtouq __P ((__const char *__nptr,
- char **__endptr, int __base));
+extern unsigned long long int strtouq __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base));
#endif /* GCC and use BSD. */
-#if defined (__GNUC__) && defined (__USE_MISC)
+#if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
/* These functions will part of the standard C library in ISO C 9X. */
/* Convert a string to a quadword integer. */
-extern long long int strtoll __P ((__const char *__nptr, char **__endptr,
- int __base));
+extern long long int strtoll __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base));
/* Convert a string to an unsigned quadword integer. */
-extern unsigned long long int strtoull __P ((__const char *__nptr,
- char **__endptr, int __base));
-#endif /* GCC and use MISC. */
+extern unsigned long long int strtoull __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base));
+#endif /* ISO C 9X or GCC and use MISC. */
/* The internal entry points for `strtoX' take an extra flag argument
saying whether or not to parse locale-dependent number grouping. */
-extern double __strtod_internal __P ((__const char *__nptr,
- char **__endptr, int __group));
-extern float __strtof_internal __P ((__const char *__nptr, char **__endptr,
- int __group));
-extern __long_double_t __strtold_internal __P ((__const char *__nptr,
- char **__endptr, int __group));
-extern long int __strtol_internal __P ((__const char *__nptr, char **__endptr,
+extern double __strtod_internal __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __group));
+extern float __strtof_internal __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr, int __group));
+extern __long_double_t __strtold_internal __P ((__const char *
+ __restrict __nptr,
+ char **__restrict __endptr,
+ int __group));
+extern long int __strtol_internal __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
int __base, int __group));
-extern unsigned long int __strtoul_internal __P ((__const char *__nptr,
- char **__endptr, int __base,
- int __group));
+extern unsigned long int __strtoul_internal __P ((__const char *
+ __restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group));
#ifdef __GNUC__
-extern long long int __strtoq_internal __P ((__const char *__nptr,
- char **__endptr, int __base,
- int __group));
-extern unsigned long long int __strtouq_internal __P ((__const char *__nptr,
- char **__endptr,
- int __base,
- int __group));
+extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group));
+extern unsigned long long int __strtoull_internal __P ((__const char *
+ __restrict __nptr,
+ char **
+ __restrict __endptr,
+ int __base,
+ int __group));
#endif /* GCC */
#if defined (__OPTIMIZE__) && __GNUC__ >= 2
/* Define inline functions which call the internal entry points. */
-extern __inline double strtod (__const char *__nptr, char **__endptr)
+extern __inline double strtod (__const char *__restrict __nptr,
+ char **__restrict __endptr)
{ return __strtod_internal (__nptr, __endptr, 0); }
-extern __inline long int strtol (__const char *__nptr,
- char **__endptr, int __base)
+extern __inline long int strtol (__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base)
{ return __strtol_internal (__nptr, __endptr, __base, 0); }
-extern __inline unsigned long int strtoul (__const char *__nptr,
- char **__endptr, int __base)
+extern __inline unsigned long int strtoul (__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base)
{ return __strtoul_internal (__nptr, __endptr, __base, 0); }
#ifdef __USE_GNU
-extern __inline float strtof (__const char *__nptr, char **__endptr)
+extern __inline float strtof (__const char *__restrict __nptr,
+ char **__restrict __endptr)
{ return __strtof_internal (__nptr, __endptr, 0); }
-extern __inline __long_double_t strtold (__const char *__nptr, char **__endptr)
+extern __inline __long_double_t strtold (__const char *__restrict __nptr,
+ char **__restrict __endptr)
{ return __strtold_internal (__nptr, __endptr, 0); }
#endif
#ifdef __USE_BSD
-extern __inline long long int strtoq (__const char *__nptr, char **__endptr,
- int __base)
-{ return __strtoq_internal (__nptr, __endptr, __base, 0); }
-extern __inline unsigned long long int strtouq (__const char *__nptr,
- char **__endptr, int __base)
-{ return __strtouq_internal (__nptr, __endptr, __base, 0); }
+extern __inline long long int strtoq (__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base)
+{ return __strtoll_internal (__nptr, __endptr, __base, 0); }
+extern __inline unsigned long long int strtouq (__const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base)
+{ return __strtoull_internal (__nptr, __endptr, __base, 0); }
#endif
-#ifdef __USE_MISC
-extern __inline long long int strtoll (__const char *__nptr, char **__endptr,
- int __base)
-{ return __strtoq_internal (__nptr, __endptr, __base, 0); }
-extern __inline unsigned long long int strtoull (__const char *__nptr,
- char **__endptr, int __base)
-{ return __strtouq_internal (__nptr, __endptr, __base, 0); }
+#if defined __USE_MISC || defined __USE_ISOC9X
+extern __inline long long int strtoll (__const char *__restrict __nptr,
+ char **__restrict __endptr, int __base)
+{ return __strtoll_internal (__nptr, __endptr, __base, 0); }
+extern __inline unsigned long long int strtoull (__const char *
+ __restrict __nptr,
+ char **__restrict __endptr,
+ int __base)
+{ return __strtoull_internal (__nptr, __endptr, __base, 0); }
#endif
extern __inline double atof (__const char *__nptr)
@@ -483,8 +504,9 @@ extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
/* Return the absolute value of X. */
extern int abs __P ((int __x)) __attribute__ ((__const__));
extern long int labs __P ((long int __x)) __attribute__ ((__const__));
-#ifdef __USE_GNU
-extern long long int llabs __P ((long long int __x)) __attribute__ ((__const__));
+#if defined __USE_ISOC9X
+extern long long int llabs __P ((long long int __x))
+ __attribute__ ((__const__));
#endif
@@ -492,9 +514,11 @@ extern long long int llabs __P ((long long int __x)) __attribute__ ((__const__))
of the value of NUMER over DENOM. */
/* GCC may have built-ins for these someday. */
extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
-extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__));
-#ifdef __USE_GNU
-extern lldiv_t lldiv __P ((long long int __numer, long long int __denom)) __attribute__ ((__const__));
+extern ldiv_t ldiv __P ((long int __numer, long int __denom))
+ __attribute__ ((__const__));
+#ifdef __USE_ISOC9X
+extern lldiv_t lldiv __P ((long long int __numer, long long int __denom))
+ __attribute__ ((__const__));
#endif
@@ -548,7 +572,8 @@ extern int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
extern int mblen __P ((__const char *__s, size_t __n));
/* Return the length of the given multibyte character,
putting its `wchar_t' representation in *PWC. */
-extern int mbtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n));
+extern int mbtowc __P ((wchar_t *__restrict __pwc,
+ __const char *__restrict __s, size_t __n));
/* Put the multibyte character represented
by WCHAR in S, returning its length. */
extern int wctomb __P ((char *__s, wchar_t __wchar));
@@ -560,9 +585,11 @@ extern __inline int mblen (__const char *__s, size_t __n)
/* Convert a multibyte string to a wide char string. */
-extern size_t mbstowcs __P ((wchar_t *__pwcs, __const char *__s, size_t __n));
+extern size_t mbstowcs __P ((wchar_t *__restrict __pwcs,
+ __const char *__restrict __s, size_t __n));
/* Convert a wide char string to multibyte string. */
-extern size_t wcstombs __P ((char *__s, __const wchar_t *__pwcs, size_t __n));
+extern size_t wcstombs __P ((char *__restrict __s,
+ __const wchar_t *__restrict __pwcs, size_t __n));
#ifdef __USE_SVID
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index e5951f01a4..ed24c08f2b 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -41,18 +41,21 @@
# define L_(Ch) L##Ch
# define ISSPACE(Ch) iswspace (Ch)
# define TOLOWER(Ch) towlower (Ch)
+# define STRNCASECMP(S1, S2, N) __wcsncasecmp ((S1), (S2), (N))
#else
# define STRING_TYPE char
# define CHAR_TYPE char
# define L_(Ch) Ch
# define ISSPACE(Ch) isspace (Ch)
# define TOLOWER(Ch) tolower (Ch)
+# define STRNCASECMP(S1, S2, N) __strncasecmp ((S1), (S2), (N))
#endif
/* End of configuration part. */
#include <ctype.h>
#include <errno.h>
#include <float.h>
+#include <ieee754.h>
#include "../locale/localeinfo.h"
#include <math.h>
#include <stdlib.h>
@@ -433,7 +436,54 @@ INTERNAL (STRTOF) (nptr, endptr, group)
No character is used even if a sign was found. */
if ((c < L_('0') || c > L_('9'))
&& ((wint_t) c != decimal || cp[1] < L_('0') || cp[1] > L_('9')))
- RETURN (0.0, nptr);
+ {
+ int matched = 0;
+ /* Check for `INF' or `INFINITY'. */
+ if (TOLOWER (c) == L_('i') && ((STRNCASECMP (cp, L_("nf"), 2) == 0
+ && (matched = 2))
+ || (STRNCASECMP (cp, L_("nfinity"), 7)
+ == 0
+ && (matched = 7))))
+ {
+ /* Return +/- inifity. */
+ if (endptr != NULL)
+ *endptr = (STRING_TYPE *) (cp + matched);
+
+ return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
+ }
+
+ if (TOLOWER (c) == L_('n') && STRNCASECMP (cp, L_("an"), 2) == 0)
+ {
+ /* Return NaN. */
+ if (endptr != NULL)
+ {
+ cp += 2;
+
+ /* Match `(n-char-sequence-digit)'. */
+ if (*cp == L_('('))
+ {
+ const STRING_TYPE *startp = cp;
+ do
+ ++cp;
+ while ((*cp >= '0' && *cp <= '9')
+ || (TOLOWER (*cp) >= 'a' && TOLOWER (*cp) <= 'z')
+ || *cp == L_('_'));
+
+ if (*cp != L_(')'))
+ /* The closing brace is missing. Only match the NAN
+ part. */
+ cp = startp;
+ }
+
+ *endptr = (STRING_TYPE *) cp;
+ }
+
+ return NAN;
+ }
+
+ /* It is really a text we do not recognize. */
+ RETURN (0.0, nptr);
+ }
/* Record the start of the digits, in case we will check their grouping. */
start_of_digits = startp = cp;
diff --git a/stdlib/strtof.c b/stdlib/strtof.c
index 1d1c41f46a..8692a3ac8f 100644
--- a/stdlib/strtof.c
+++ b/stdlib/strtof.c
@@ -5,6 +5,6 @@
#define FLT FLT
#define STRTOF strtof
#define MPN2FLOAT __mpn_construct_float
-#define FLOAT_HUGE_VAL HUGE_VALf
+#define FLOAT_HUGE_VAL HUGE_VALF
#include "strtod.c"
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index 396e2ecd74..6ec096daf6 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -1,4 +1,4 @@
-/* strtol - Convert string representation of a number into an integer value.
+/* Convert string representation of a number into an integer value.
Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -54,7 +54,7 @@ extern int errno;
# include "../locale/localeinfo.h"
#endif
-/* Nonzero if we are defining `strtoul' or `strtouq', operating on
+/* Nonzero if we are defining `strtoul' or `strtoull', operating on
unsigned integers. */
#ifndef UNSIGNED
# define UNSIGNED 0
@@ -67,13 +67,13 @@ extern int errno;
#if UNSIGNED
# ifdef USE_WIDE_CHAR
# ifdef QUAD
-# define strtol wcstouq
+# define strtol wcstoull
# else
# define strtol wcstoul
# endif
# else
# ifdef QUAD
-# define strtol strtouq
+# define strtol strtoull
# else
# define strtol strtoul
# endif
@@ -81,18 +81,18 @@ extern int errno;
#else
# ifdef USE_WIDE_CHAR
# ifdef QUAD
-# define strtol wcstoq
+# define strtol wcstoll
# else
# define strtol wcstol
# endif
# else
# ifdef QUAD
-# define strtol strtoq
+# define strtol strtoll
# endif
# endif
#endif
-/* If QUAD is defined, we are defining `strtoq' or `strtouq',
+/* If QUAD is defined, we are defining `strtoll' or `strtoull',
operating on `long long int's. */
#ifdef QUAD
# define LONG long long
@@ -312,8 +312,6 @@ INTERNAL (strtol) (nptr, endptr, base, group)
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
: (unsigned LONG int) LONG_MAX))
overflow = 1;
-#else
- overflow |= negative;
#endif
if (overflow)
diff --git a/stdlib/strtold.c b/stdlib/strtold.c
index ec2b49b279..9d80543377 100644
--- a/stdlib/strtold.c
+++ b/stdlib/strtold.c
@@ -5,6 +5,6 @@
#define FLT LDBL
#define STRTOF strtold
#define MPN2FLOAT __mpn_construct_long_double
-#define FLOAT_HUGE_VAL HUGE_VALl
+#define FLOAT_HUGE_VAL HUGE_VALL
#include "strtod.c"
diff --git a/stdlib/strtoq.c b/stdlib/strtoll.c
index 259611c3a2..e9487addc7 100644
--- a/stdlib/strtoq.c
+++ b/stdlib/strtoll.c
@@ -21,4 +21,4 @@
#include <strtol.c>
-weak_alias (strtoq, strtoll)
+weak_alias (strtoll, strtoq)
diff --git a/stdlib/strtouq.c b/stdlib/strtoull.c
index 68f293610a..419d28964f 100644
--- a/stdlib/strtouq.c
+++ b/stdlib/strtoull.c
@@ -21,4 +21,4 @@
#include <strtoul.c>
-weak_alias (strtouq, strtoull)
+weak_alias (strtoull, strtouq)
diff --git a/stdlib/tst-strtol.c b/stdlib/tst-strtol.c
index 1d398b4558..e351e97ceb 100644
--- a/stdlib/tst-strtol.c
+++ b/stdlib/tst-strtol.c
@@ -38,7 +38,7 @@ static const struct ltest tests[] =
{ "0xffffffffg", 0xffffffff, 0, 'g', 0 },
{ "0xf1f2f3f4f5", 0xffffffff, 0, 0, ERANGE },
{ "-0x123456789", 0xffffffff, 0, 0, ERANGE },
- { "-0xfedcba98", 0xffffffff, 0, 0, ERANGE },
+ { "-0xfedcba98", 0x01234568, 0, 0, 0 },
{ NULL, 0, 0, 0, 0 },
#else
/* assume 64 bit long... */
@@ -66,7 +66,7 @@ static const struct ltest tests[] =
{ "0xffffffffffffffffg", 0xffffffffffffffff, 0, 'g', 0 },
{ "0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffff, 0, 0, ERANGE },
{ "-0x123456789abcdef01", 0xffffffffffffffff, 0, 0, ERANGE },
- { "-0xfedcba987654321", 0xffffffffffffffff, 0, 0, ERANGE },
+ { "-0xfedcba987654321", 0x0123456789abcdf, 0, 0, 0 },
{ NULL, 0, 0, 0, 0 },
#endif
};
diff --git a/string/string.h b/string/string.h
index 865007ff99..462992dbf3 100644
--- a/string/string.h
+++ b/string/string.h
@@ -34,8 +34,8 @@ __BEGIN_DECLS
/* Copy N bytes of SRC to DEST. */
-extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,
- size_t __n));
+extern __ptr_t memcpy __P ((__ptr_t __restrict __dest,
+ __const __ptr_t __restrict __src, size_t __n));
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
extern __ptr_t memmove __P ((__ptr_t __dest, __const __ptr_t __src,
@@ -64,14 +64,18 @@ extern __ptr_t memchr __P ((__const __ptr_t __s, int __c, size_t __n));
/* Copy SRC to DEST. */
-extern char *strcpy __P ((char *__dest, __const char *__src));
+extern char *strcpy __P ((char *__restrict __dest,
+ __const char *__restrict __src));
/* Copy no more than N characters of SRC to DEST. */
-extern char *strncpy __P ((char *__dest, __const char *__src, size_t __n));
+extern char *strncpy __P ((char *__restrict __dest,
+ __const char *__restrict __src, size_t __n));
/* Append SRC onto DEST. */
-extern char *strcat __P ((char *__dest, __const char *__src));
+extern char *strcat __P ((char *__restrict __dest,
+ __const char *__restrict __src));
/* Append no more than N characters from SRC onto DEST. */
-extern char *strncat __P ((char *__dest, __const char *__src, size_t __n));
+extern char *strncat __P ((char *__restrict __dest,
+ __const char *__restrict __src, size_t __n));
/* Compare S1 and S2. */
extern int strcmp __P ((__const char *__s1, __const char *__s2));
@@ -81,7 +85,8 @@ extern int strncmp __P ((__const char *__s1, __const char *__s2, size_t __n));
/* Compare the collated forms of S1 and S2. */
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));
+extern size_t strxfrm __P ((char *__restrict __dest,
+ __const char *__restrict __src, size_t __n));
#ifdef __USE_GNU
/* The following functions are equivalent to the both above but they
@@ -150,7 +155,8 @@ extern char *strpbrk __P ((__const char *__s, __const char *__accept));
/* Find the first occurrence of NEEDLE in HAYSTACK. */
extern char *strstr __P ((__const char *__haystack, __const char *__needle));
/* Divide S into tokens separated by characters in DELIM. */
-extern char *strtok __P ((char *__s, __const char *__delim));
+extern char *strtok __P ((char *__restrict __s,
+ __const char *__restrict __delim));
#if defined __USE_POSIX || defined __USE_MISC
/* Divide S into tokens separated by characters in DELIM. Information
diff --git a/sysdeps/ieee754/huge_val.h b/sysdeps/ieee754/huge_val.h
index 63a8aad9f5..4f8b0a9574 100644
--- a/sysdeps/ieee754/huge_val.h
+++ b/sysdeps/ieee754/huge_val.h
@@ -1,6 +1,6 @@
-/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
+/* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity).
Used by <stdlib.h> and <math.h> functions for overflow.
- Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,43 +44,49 @@ static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
#endif /* GCC. */
-/* GNU extensions: (float) HUGE_VALf and (long double) HUGE_VALl. */
+/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
-#ifdef __USE_GNU
+#ifdef __USE_ISOC9X
#if __BYTE_ORDER == __BIG_ENDIAN
-#define __HUGE_VALf_bytes { 0x7f, 0x80, 0, 0 }
+#define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 }
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __HUGE_VALf_bytes { 0, 0, 0x80, 0x7f }
+#define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f }
#endif
#define __huge_valf_t union { unsigned char __c[4]; float __f; }
#ifdef __GNUC__
-#define HUGE_VALf (__extension__ \
- ((__huge_valf_t) { __c: __HUGE_VALf_bytes }).__f)
+#define HUGE_VALF (__extension__ \
+ ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f)
#else /* Not GCC. */
-static __huge_valf_t __huge_valf = { __HUGE_VALf_bytes };
-#define HUGE_VALf (__huge_valf.__f)
+static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };
+#define HUGE_VALF (__huge_valf.__f)
#endif /* GCC. */
+
#if __BYTE_ORDER == __BIG_ENDIAN
-#define __HUGE_VALl_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+#define __HUGE_VALL_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __HUGE_VALl_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 }
+#define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 }
#endif
#define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
#ifdef __GNUC__
-#define HUGE_VALl (__extension__ \
- ((__huge_vall_t) { __c: __HUGE_VALl_bytes }).__ld)
+#define HUGE_VALL (__extension__ \
+ ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld)
#else /* Not GCC. */
-static __huge_vall_t __huge_vall = { __HUGE_VALl_bytes };
-#define HUGE_VALl (__huge_vall.__ld)
+static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
+#define HUGE_VALL (__huge_vall.__ld)
#endif /* GCC. */
-#endif /* __USE_GNU. */
+
+/* Expression representing positive infinity. Here it is the same as
+ HUGE_VALF. */
+#define INFINITY HUGE_VALF
+
+#endif /* __USE_ISOC9X. */
#endif /* huge_val.h */
diff --git a/sysdeps/libm-ieee754/s_cbrtl.c b/sysdeps/libm-ieee754/s_cbrtl.c
index 9f45faa00c..21e7727728 100644
--- a/sysdeps/libm-ieee754/s_cbrtl.c
+++ b/sysdeps/libm-ieee754/s_cbrtl.c
@@ -90,7 +90,7 @@ G = 3.57142857142857150787e-01L; /* 5/14 */
{
u_int64_t xxl = ((u_int64_t) se) << 32 | x0;
xxl /= 3;
- xxl += B1_EXP << 16 | B1_MANT;
+ xxl += ((u_int64_t) B1_EXP) << 32 | B1_MANT;
SET_LDOUBLE_MSW(t,xxl&0xffffffffu);
xxl >>= 32;
SET_LDOUBLE_EXP(t,xxl);
diff --git a/sysdeps/posix/gai_strerror.c b/sysdeps/posix/gai_strerror.c
index b89a1f6889..f5b33cb8db 100644
--- a/sysdeps/posix/gai_strerror.c
+++ b/sysdeps/posix/gai_strerror.c
@@ -43,7 +43,7 @@ values[] =
char *
gai_strerror (int code)
{
- int i;
+ size_t i;
for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
if (values[i].code == code)
return (char *) values[i].msg;
diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list
index fba1245730..9a2325c35c 100644
--- a/sysdeps/unix/syscalls.list
+++ b/sysdeps/unix/syscalls.list
@@ -7,7 +7,7 @@ chmod - chmod 2 __chmod chmod
chown - chown 3 __chown chown
chroot - chroot 1 chroot
close - close 1 __libc_close __close close
-dup - dup 2 __dup dup
+dup - dup 1 __dup dup
dup2 - dup2 2 __dup2 dup2
fchdir - fchdir 1 fchdir
fcntl - fcntl 3 __libc_fcntl __fcntl fcntl
diff --git a/sysdeps/unix/sysv/linux/accept.S b/sysdeps/unix/sysv/linux/accept.S
index 5936a0185b..014684c708 100644
--- a/sysdeps/unix/sysv/linux/accept.S
+++ b/sysdeps/unix/sysv/linux/accept.S
@@ -1,2 +1,3 @@
#define socket accept
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/bind.S b/sysdeps/unix/sysv/linux/bind.S
index fc82b65a2f..61fb5ebff8 100644
--- a/sysdeps/unix/sysv/linux/bind.S
+++ b/sysdeps/unix/sysv/linux/bind.S
@@ -1,2 +1,3 @@
#define socket bind
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/connect.S b/sysdeps/unix/sysv/linux/connect.S
index 3433043d8c..93aad35d85 100644
--- a/sysdeps/unix/sysv/linux/connect.S
+++ b/sysdeps/unix/sysv/linux/connect.S
@@ -1,2 +1,3 @@
#define socket connect
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getpeername.S b/sysdeps/unix/sysv/linux/getpeername.S
index 8429fcdf76..a6d8e86d4e 100644
--- a/sysdeps/unix/sysv/linux/getpeername.S
+++ b/sysdeps/unix/sysv/linux/getpeername.S
@@ -1,2 +1,3 @@
#define socket getpeername
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getsockname.S b/sysdeps/unix/sysv/linux/getsockname.S
index 6782707f88..c138be9da5 100644
--- a/sysdeps/unix/sysv/linux/getsockname.S
+++ b/sysdeps/unix/sysv/linux/getsockname.S
@@ -1,2 +1,3 @@
#define socket getsockname
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getsockopt.S b/sysdeps/unix/sysv/linux/getsockopt.S
index 6ce92a6330..6f982082ae 100644
--- a/sysdeps/unix/sysv/linux/getsockopt.S
+++ b/sysdeps/unix/sysv/linux/getsockopt.S
@@ -1,2 +1,3 @@
#define socket getsockopt
+#define NARGS 5
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/i386/socket.S b/sysdeps/unix/sysv/linux/i386/socket.S
index 78e8b03cce..441c143156 100644
--- a/sysdeps/unix/sysv/linux/i386/socket.S
+++ b/sysdeps/unix/sysv/linux/i386/socket.S
@@ -1,20 +1,20 @@
-/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
#include <sysdep.h>
#include <sys/socketcall.h>
diff --git a/sysdeps/unix/sysv/linux/listen.S b/sysdeps/unix/sysv/linux/listen.S
index d2cbec60a0..4c7e435196 100644
--- a/sysdeps/unix/sysv/linux/listen.S
+++ b/sysdeps/unix/sysv/linux/listen.S
@@ -1,2 +1,3 @@
#define socket listen
+#define NARGS 2
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/recv.S b/sysdeps/unix/sysv/linux/recv.S
index f1081cc431..ae17ba3fd3 100644
--- a/sysdeps/unix/sysv/linux/recv.S
+++ b/sysdeps/unix/sysv/linux/recv.S
@@ -1,2 +1,3 @@
#define socket recv
+#define NARGS 4
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/recvfrom.S b/sysdeps/unix/sysv/linux/recvfrom.S
index febaa9ef55..ed03d3c44b 100644
--- a/sysdeps/unix/sysv/linux/recvfrom.S
+++ b/sysdeps/unix/sysv/linux/recvfrom.S
@@ -1,2 +1,3 @@
#define socket recvfrom
+#define NARGS 6
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/recvmsg.S b/sysdeps/unix/sysv/linux/recvmsg.S
index ffadd30195..bb897d2b63 100644
--- a/sysdeps/unix/sysv/linux/recvmsg.S
+++ b/sysdeps/unix/sysv/linux/recvmsg.S
@@ -1,2 +1,3 @@
#define socket recvmsg
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/send.S b/sysdeps/unix/sysv/linux/send.S
index 52293c6524..596135e690 100644
--- a/sysdeps/unix/sysv/linux/send.S
+++ b/sysdeps/unix/sysv/linux/send.S
@@ -1,2 +1,3 @@
#define socket send
+#define NARGS 4
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/sendmsg.S b/sysdeps/unix/sysv/linux/sendmsg.S
index 65f2c3eb98..f0aabb7023 100644
--- a/sysdeps/unix/sysv/linux/sendmsg.S
+++ b/sysdeps/unix/sysv/linux/sendmsg.S
@@ -1,2 +1,3 @@
#define socket sendmsg
+#define NARGS 3
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/sendto.S b/sysdeps/unix/sysv/linux/sendto.S
index aa637ce9c9..3464d46e52 100644
--- a/sysdeps/unix/sysv/linux/sendto.S
+++ b/sysdeps/unix/sysv/linux/sendto.S
@@ -1,2 +1,3 @@
#define socket sendto
+#define NARGS 6
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/setsockopt.S b/sysdeps/unix/sysv/linux/setsockopt.S
index 33d57179ca..01b2799ae8 100644
--- a/sysdeps/unix/sysv/linux/setsockopt.S
+++ b/sysdeps/unix/sysv/linux/setsockopt.S
@@ -1,2 +1,3 @@
#define socket setsockopt
+#define NARGS 5
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/shutdown.S b/sysdeps/unix/sysv/linux/shutdown.S
index 6cc95d50f9..e2462d0eca 100644
--- a/sysdeps/unix/sysv/linux/shutdown.S
+++ b/sysdeps/unix/sysv/linux/shutdown.S
@@ -1,2 +1,3 @@
#define socket shutdown
+#define NARGS 2
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/socketpair.S b/sysdeps/unix/sysv/linux/socketpair.S
index da71c57dea..c954ad1a4b 100644
--- a/sysdeps/unix/sysv/linux/socketpair.S
+++ b/sysdeps/unix/sysv/linux/socketpair.S
@@ -1,2 +1,3 @@
#define socket socketpair
+#define NARGS 4
#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/timebits.h b/sysdeps/unix/sysv/linux/timebits.h
index f2f73a48d4..de30a6f348 100644
--- a/sysdeps/unix/sysv/linux/timebits.h
+++ b/sysdeps/unix/sysv/linux/timebits.h
@@ -1,5 +1,5 @@
/* System-dependent timing definitions. Linux version.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -43,8 +43,10 @@ struct timeval
XSI-conformant systems. */
# define CLOCKS_PER_SEC 1000000
+# ifndef __STRICT_ANSI__
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
-# define CLK_TCK 100
+# define CLK_TCK 100
+# endif
#endif /* timebits.h */
diff --git a/time/time.h b/time/time.h
index 8c1aeaace6..5cd8975d44 100644
--- a/time/time.h
+++ b/time/time.h
@@ -152,8 +152,9 @@ extern time_t __mktime_internal __P ((struct tm *__tp,
/* Format TP into S according to FORMAT.
Write no more than MAXSIZE characters and return the number
of characters written, or 0 if it would exceed MAXSIZE. */
-extern size_t strftime __P ((char *__s, size_t __maxsize,
- __const char *__format, __const struct tm *__tp));
+extern size_t strftime __P ((char *__restrict __s, size_t __maxsize,
+ __const char *__restrict __format,
+ __const struct tm *__restrict __tp));
#ifdef __USE_XOPEN
/* Parse S according to FORMAT and store binary time information in TP.
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index 929798da42..76f0fd03b9 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -30,10 +30,11 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
btowc wctob mbsinit \
mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \
mbsnrtowcs wcsnrtombs \
- wcstol wcstoul wcstoq wcstouq wcstod wcstold wcstof \
+ wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \
wcscoll wcsxfrm \
wcwidth wcswidth \
- wcscoll_l wcsxfrm_l
+ wcscoll_l wcsxfrm_l \
+ wcscasecmp wcsncase
include ../Rules
@@ -42,8 +43,8 @@ CFLAGS-wcswidth.c = -I../wctype
CFLAGS-wcstol.c = -I../stdlib
CFLAGS-wcstoul.c = -I../stdlib
-CFLAGS-wcstoq.c = -I../stdlib
-CFLAGS-wcstouq.c = -I../stdlib
+CFLAGS-wcstoll.c = -I../stdlib
+CFLAGS-wcstoull.c = -I../stdlib
CFLAGS-wcstod.c = -I../stdlib
CFLAGS-wcstold.c = -I../stdlib
CFLAGS-wcstof.c = -I../stdlib
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 597a03d735..5247a866d3 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -64,16 +64,18 @@ typedef struct
/* Copy SRC to DEST. */
-extern wchar_t *wcscpy __P ((wchar_t *__dest, __const wchar_t *__src));
+extern wchar_t *wcscpy __P ((wchar_t *__restrict __dest,
+ __const wchar_t *__restrict __src));
/* Copy no more than N wide-characters of SRC to DEST. */
-extern wchar_t *wcsncpy __P ((wchar_t *__dest, __const wchar_t *__src,
- size_t __n));
+extern wchar_t *wcsncpy __P ((wchar_t *__restrict __dest,
+ __const wchar_t *__restrict __src, size_t __n));
/* Append SRC onto DEST. */
-extern wchar_t *wcscat __P ((wchar_t *__dest, __const wchar_t *__src));
+extern wchar_t *wcscat __P ((wchar_t *__restrict __dest,
+ __const wchar_t *__restrict __src));
/* Append no more than N wide-characters of SRC onto DEST. */
-extern wchar_t *wcsncat __P ((wchar_t *__dest, __const wchar_t *__src,
- size_t __n));
+extern wchar_t *wcsncat __P ((wchar_t *__restrict __dest,
+ __const wchar_t *__restrict __src, size_t __n));
/* Compare S1 and S2. */
extern int wcscmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
@@ -81,13 +83,26 @@ extern int wcscmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
extern int wcsncmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
size_t __n));
+#ifdef __USE_GNU
+/* Compare S1 and S2, ignoring case. */
+extern int __wcscasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
+extern int wcscasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2));
+
+/* Compare no more than N chars of S1 and S2, ignoring case. */
+extern int __wcsncasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
+ size_t __n));
+extern int wcsncasecmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
+ size_t __n));
+#endif
+
/* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the current locale. */
extern int wcscoll __P ((__const wchar_t *__s1, __const wchar_t *__s2));
/* Transform S2 into array pointed to by S1 such that if wcscmp is
applied to two transformed strings the result is the as applying
`wcscoll' to the original strings. */
-extern size_t wcsxfrm __P ((wchar_t *__s1, __const wchar_t *__s2, size_t __n));
+extern size_t wcsxfrm __P ((wchar_t *__restrict __s1,
+ __const wchar_t *__restrict __s2, size_t __n));
#ifdef __USE_GNU
/* Similar to the two functions above but take the information from
@@ -97,12 +112,12 @@ extern size_t wcsxfrm __P ((wchar_t *__s1, __const wchar_t *__s2, size_t __n));
/* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the given locale. */
extern int __wcscoll_l __P ((__const wchar_t *__s1, __const wchar_t *__s2,
- __locale_t loc));
+ __locale_t __loc));
/* Transform S2 into array pointed to by S1 such that if wcscmp is
applied to two transformed strings the result is the as applying
`wcscoll' to the original strings. */
extern size_t __wcsxfrm_l __P ((wchar_t *__s1, __const wchar_t *__s2,
- size_t __n, __locale_t loc));
+ size_t __n, __locale_t __loc));
#endif
/* Duplicate S, returning an identical malloc'd string. */
@@ -127,8 +142,9 @@ extern wchar_t *wcspbrk __P ((__const wchar_t *__wcs,
extern wchar_t *wcsstr __P ((__const wchar_t *__haystack,
__const wchar_t *__needle));
/* Divide WCS into tokens separated by characters in DELIM. */
-extern wchar_t *wcstok __P ((wchar_t *__s, __const wchar_t *__delim,
- wchar_t **ptr));
+extern wchar_t *wcstok __P ((wchar_t *__restrict __s,
+ __const wchar_t *__restrict __delim,
+ wchar_t **__restrict __ptr));
/* Return the number of wide-characters in S. */
extern size_t wcslen __P ((__const wchar_t *__s));
@@ -138,12 +154,12 @@ extern size_t wcslen __P ((__const wchar_t *__s));
extern wchar_t *wmemchr __P ((__const wchar_t *__s, wchar_t __c, size_t __n));
/* Compare N bytes of S1 and S2. */
-extern int wmemcmp __P ((__const wchar_t *__s1, __const wchar_t *__s2,
- size_t __n));
+extern int wmemcmp __P ((__const wchar_t *__restrict __s1,
+ __const wchar_t *__restrict __s2, size_t __n));
/* Copy N bytes of SRC to DEST. */
-extern wchar_t *wmemcpy __P ((wchar_t *__s1, __const wchar_t *__s2,
- size_t __n));
+extern wchar_t *wmemcpy __P ((wchar_t *__restrict __s1,
+ __const wchar_t *__restrict __s2, size_t __n));
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
@@ -168,55 +184,73 @@ extern int mbsinit __P ((__const mbstate_t *__ps));
/* Write wide character representation of multibyte character pointed
to by S to PWC. */
-extern size_t __mbrtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n,
- mbstate_t *__p));
-extern size_t mbrtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n,
+extern size_t __mbrtowc __P ((wchar_t *__restrict __pwc,
+ __const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __p));
+extern size_t mbrtowc __P ((wchar_t *__restrict __pwc,
+ __const char *__restrict __s, size_t __n,
mbstate_t *__p));
/* Write multibyte representation of wide character WC to S. */
-extern size_t __wcrtomb __P ((char *__s, wchar_t __wc, mbstate_t *__ps));
-extern size_t wcrtomb __P ((char *__s, wchar_t __wc, mbstate_t *__ps));
+extern size_t __wcrtomb __P ((char *__restrict __s, wchar_t __wc,
+ mbstate_t *__restrict __ps));
+extern size_t wcrtomb __P ((char *__restrict __s, wchar_t __wc,
+ mbstate_t *__restrict __ps));
/* Return number of bytes in multibyte character pointed to by S. */
-extern size_t __mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
-extern size_t mbrlen __P ((__const char *__s, size_t __n, mbstate_t *__ps));
+extern size_t __mbrlen __P ((__const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __ps));
+extern size_t mbrlen __P ((__const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __ps));
#if defined (__OPTIMIZE__) \
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
/* Define inline function as optimization. */
-extern __inline size_t mbrlen (__const char *s, size_t n, mbstate_t *ps)
-{ return ps != NULL ? __mbrtowc (NULL, s, n, ps) : __mbrlen (s, n, NULL); }
+extern __inline size_t mbrlen (__const char *__restrict __s, size_t __n,
+ mbstate_t *__restrict __ps)
+{ return (__ps != NULL
+ ? __mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
#endif
/* Write wide character representation of multibyte character string
SRC to DST. */
-extern size_t __mbsrtowcs __P ((wchar_t *__dst, __const char **__src,
- size_t __len, mbstate_t *__ps));
-extern size_t mbsrtowcs __P ((wchar_t *__dst, __const char **__src,
- size_t __len, mbstate_t *__ps));
+extern size_t __mbsrtowcs __P ((wchar_t *__restrict __dst,
+ __const char **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps));
+extern size_t mbsrtowcs __P ((wchar_t *__restrict __dst,
+ __const char **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps));
/* Write multibyte character representation of wide character string
SRC to DST. */
-extern size_t __wcsrtombs __P ((char *__dst, __const wchar_t **__src,
- size_t __len, mbstate_t *__ps));
-extern size_t wcsrtombs __P ((char *__dst, __const wchar_t **__src,
- size_t __len, mbstate_t *__ps));
+extern size_t __wcsrtombs __P ((char *__restrict __dst,
+ __const wchar_t **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps));
+extern size_t wcsrtombs __P ((char *__restrict __dst,
+ __const wchar_t **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps));
#ifdef __USE_GNU
/* Write wide character representation of at most NMC bytes of the
multibyte character string SRC to DST. */
-extern size_t __mbsnrtowcs __P ((wchar_t *__dst, __const char **__src,
- size_t __nmc, size_t __len, mbstate_t *__ps));
-extern size_t mbsnrtowcs __P ((wchar_t *__dst, __const char **__src,
- size_t __nmc, size_t __len, mbstate_t *__ps));
+extern size_t __mbsnrtowcs __P ((wchar_t *__restrict __dst,
+ __const char **__restrict __src, size_t __nmc,
+ size_t __len, mbstate_t *__restrict __ps));
+extern size_t mbsnrtowcs __P ((wchar_t *__restrict __dst,
+ __const char **__restrict __src, size_t __nmc,
+ size_t __len, mbstate_t *__restrict __ps));
/* Write multibyte character representation of at most NWC characters
from the wide character string SRC to DST. */
-extern size_t __wcsnrtombs __P ((char *__dst, __const wchar_t **__src,
- size_t __nwc, size_t __len, mbstate_t *__ps));
-extern size_t wcsnrtombs __P ((char *__dst, __const wchar_t **__src,
- size_t __nwc, size_t __len, mbstate_t *__ps));
+extern size_t __wcsnrtombs __P ((char *__restrict __dst,
+ __const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len,
+ mbstate_t *__restrict __ps));
+extern size_t wcsnrtombs __P ((char *__restrict __dst,
+ __const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len,
+ mbstate_t *__restrict __ps));
/* The following functions are extensions found in X/Open CAE. */
@@ -232,92 +266,124 @@ extern int wcswidth __P ((__const wchar_t *__s, size_t __n));
/* Convert initial portion of the wide string NPTR to `double'
representation. */
-extern double wcstod __P ((__const wchar_t *__nptr, wchar_t **__endptr));
+extern double wcstod __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr));
#ifdef __USE_GNU
/* Likewise for `float' and `long double' sizes of floating-point numbers. */
-extern float wcstof __P ((__const wchar_t *__nptr, wchar_t **__endptr));
-extern __long_double_t wcstold __P ((__const wchar_t *__nptr,
- wchar_t **__endptr));
+extern float wcstof __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr));
+extern __long_double_t wcstold __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr));
#endif /* GNU */
/* Convert initial portion of wide string NPTR to `long int'
representation. */
-extern long int wcstol __P ((__const wchar_t *__nptr, wchar_t **__endptr,
- int __base));
+extern long int wcstol __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr, int __base));
/* Convert initial portion of wide string NPTR to `unsigned long int'
representation. */
-extern unsigned long int wcstoul __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __base));
+extern unsigned long int wcstoul __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base));
-#if defined (__GNUC__) && defined (__USE_GNU)
+#if defined __GNUC__ && defined __USE_GNU
/* Convert initial portion of wide string NPTR to `long int'
representation. */
-extern long long int wcstoq __P ((__const wchar_t *__nptr, wchar_t **__endptr,
- int __base));
+extern long long int wcstoq __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr, int __base));
/* Convert initial portion of wide string NPTR to `unsigned long long int'
representation. */
-extern unsigned long long int wcstouq __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __base));
+extern unsigned long long int wcstouq __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base));
#endif /* GCC and use GNU. */
+#if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_GNU)
+/* Convert initial portion of wide string NPTR to `long int'
+ representation. */
+extern long long int wcstoll __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr, int __base));
+
+/* Convert initial portion of wide string NPTR to `unsigned long long int'
+ representation. */
+extern unsigned long long int wcstoull __P ((__const wchar_t *
+ __restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base));
+#endif /* ISO C 9X or GCC and GNU. */
+
/* The internal entry points for `wcstoX' take an extra flag argument
saying whether or not to parse locale-dependent number grouping. */
-extern double __wcstod_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __group));
-extern float __wcstof_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __group));
-extern __long_double_t __wcstold_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr,
+extern double __wcstod_internal __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __group));
+extern float __wcstof_internal __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __group));
+extern __long_double_t __wcstold_internal __P ((__const wchar_t *
+ __restrict __nptr,
+ wchar_t **__restrict __endptr,
int __group));
-extern long int __wcstol_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __base,
- int __group));
-extern unsigned long int __wcstoul_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr,
+extern long int __wcstol_internal __P ((__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base, int __group));
+extern unsigned long int __wcstoul_internal __P ((__const wchar_t *
+ __restrict __nptr,
+ wchar_t **
+ __restrict __endptr,
int __base, int __group));
#if defined __GNUC__ && defined __USE_GNU
-extern long long int __wcstoq_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr, int __base,
- int __group));
-extern unsigned long long int __wcstouq_internal __P ((__const wchar_t *__nptr,
- wchar_t **__endptr,
- int __base,
- int __group));
+extern long long int __wcstoll_internal __P ((__const wchar_t *
+ __restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base, int __group));
+extern unsigned long long int __wcstoull_internal __P ((__const wchar_t *
+ __restrict __nptr,
+ wchar_t **
+ __restrict __endptr,
+ int __base,
+ int __group));
#endif /* GCC and use GNU. */
#if defined (__OPTIMIZE__) && __GNUC__ >= 2
/* Define inline functions which call the internal entry points. */
-extern __inline double wcstod (__const wchar_t *__nptr, wchar_t **__endptr)
+extern __inline double wcstod (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr)
{ return __wcstod_internal (__nptr, __endptr, 0); }
-extern __inline long int wcstol (__const wchar_t *__nptr,
- wchar_t **__endptr, int __base)
+extern __inline long int wcstol (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr, int __base)
{ return __wcstol_internal (__nptr, __endptr, __base, 0); }
-extern __inline unsigned long int wcstoul (__const wchar_t *__nptr,
- wchar_t **__endptr, int __base)
+extern __inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base)
{ return __wcstoul_internal (__nptr, __endptr, __base, 0); }
#ifdef __USE_GNU
-extern __inline float wcstof (__const wchar_t *__nptr, wchar_t **__endptr)
+extern __inline float wcstof (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr)
{ return __wcstof_internal (__nptr, __endptr, 0); }
-extern __inline __long_double_t wcstold (__const wchar_t *__nptr,
- wchar_t **__endptr)
+extern __inline __long_double_t wcstold (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr)
{ return __wcstold_internal (__nptr, __endptr, 0); }
-extern __inline long long int wcstoq (__const wchar_t *__nptr,
- wchar_t **__endptr, int __base)
-{ return __wcstoq_internal (__nptr, __endptr, __base, 0); }
-extern __inline unsigned long long int wcstouq (__const wchar_t *__nptr,
- wchar_t **__endptr, int __base)
-{ return __wcstouq_internal (__nptr, __endptr, __base, 0); }
+extern __inline long long int wcstoq (__const wchar_t *__restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base)
+{ return __wcstoll_internal (__nptr, __endptr, __base, 0); }
+extern __inline unsigned long long int wcstouq (__const wchar_t *
+ __restrict __nptr,
+ wchar_t **__restrict __endptr,
+ int __base)
+{ return __wcstoull_internal (__nptr, __endptr, __base, 0); }
#endif /* Use GNU. */
#endif /* Optimizing GCC >=2. */
diff --git a/wcsmbs/wcscasecmp.c b/wcsmbs/wcscasecmp.c
new file mode 100644
index 0000000000..74908229a0
--- /dev/null
+++ b/wcsmbs/wcscasecmp.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <wctype.h>
+#include <wchar.h>
+
+#ifndef weak_alias
+# define __wcscasecmp wcscasecmp
+#endif
+
+/* Compare S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less than,
+ equal to or greater than S2. */
+int
+__wcscasecmp (s1, s2)
+ const wchar_t *s1;
+ const wchar_t *s2;
+{
+ wint_t c1, c2;
+
+ if (s1 == s2)
+ return 0;
+
+ do
+ {
+ c1 = towlower (*s1++);
+ c2 = towlower (*s2++);
+ if (c1 == '\0')
+ break;
+ }
+ while (c1 == c2);
+
+ return c1 - c2;
+}
+#ifdef weak_alias
+weak_alias (__wcscasecmp, wcscasecmp)
+#endif
diff --git a/wcsmbs/wcsncase.c b/wcsmbs/wcsncase.c
new file mode 100644
index 0000000000..c5b10c57a4
--- /dev/null
+++ b/wcsmbs/wcsncase.c
@@ -0,0 +1,55 @@
+/* Compare at most N wide characters of two strings without taking care
+ for the case.
+ Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <wchar.h>
+#include <wctype.h>
+
+#ifndef weak_alias
+# define __wcsncasecmp wcsncasecmp
+#endif
+
+/* Compare no more than N wide characters of S1 and S2,
+ ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less
+ than, equal to or greater than S2. */
+int
+__wcsncasecmp (s1, s2, n)
+ const wchar_t *s1;
+ const wchar_t *s2;
+ size_t n;
+{
+ wint_t c1, c2;
+
+ if (s1 == s2 || n == 0)
+ return 0;
+
+ do
+ {
+ c1 = (wint_t) towlower (*s1++);
+ c2 = (wint_t) towlower (*s2++);
+ if (c1 == L'\0' || c1 != c2)
+ return c1 - c2;
+ } while (--n > 0);
+
+ return c1 - c2;
+}
+#ifdef weak_alias
+weak_alias (__wcsncasecmp, wcsncasecmp)
+#endif
diff --git a/wcsmbs/wcstof.c b/wcsmbs/wcstof.c
index 01a8950ed4..7d91cf33d6 100644
--- a/wcsmbs/wcstof.c
+++ b/wcsmbs/wcstof.c
@@ -25,7 +25,7 @@
#define FLT LDBL
#define STRTOF wcstof
#define MPN2FLOAT __mpn_construct_float
-#define FLOAT_HUGE_VAL HUGE_VALf
+#define FLOAT_HUGE_VAL HUGE_VALF
#define USE_WIDE_CHAR 1
#include "../stdlib/strtod.c"
diff --git a/wcsmbs/wcstold.c b/wcsmbs/wcstold.c
index 1da8062b80..4cb68af1f8 100644
--- a/wcsmbs/wcstold.c
+++ b/wcsmbs/wcstold.c
@@ -25,7 +25,7 @@
#define FLT LDBL
#define STRTOF wcstold
#define MPN2FLOAT __mpn_construct_long_double
-#define FLOAT_HUGE_VAL HUGE_VALl
+#define FLOAT_HUGE_VAL HUGE_VALL
#define USE_WIDE_CHAR 1
#include "../stdlib/strtod.c"
diff --git a/wcsmbs/wcstoq.c b/wcsmbs/wcstoll.c
index a765ca6985..b3e9ac0093 100644
--- a/wcsmbs/wcstoq.c
+++ b/wcsmbs/wcstoll.c
@@ -21,3 +21,5 @@
#define QUAD 1
#include "wcstol.c"
+
+weak_alias (wcstoll, wcstoq)
diff --git a/wcsmbs/wcstouq.c b/wcsmbs/wcstoull.c
index 49a5daa4db..a33d3aed6b 100644
--- a/wcsmbs/wcstouq.c
+++ b/wcsmbs/wcstoull.c
@@ -21,3 +21,5 @@
#define QUAD 1
#include "wcstoul.c"
+
+weak_alias (wcstoull, wcstouq)