diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-04-28 23:13:52 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-04-28 23:13:52 +0000 |
commit | c4563d2d668675c2d5083f6ad01c801d6ccbe013 (patch) | |
tree | 1e6af86f8c33743c81080dffb17a8e8209825c06 | |
parent | Update. (diff) | |
download | glibc-c4563d2d668675c2d5083f6ad01c801d6ccbe013.tar.gz glibc-c4563d2d668675c2d5083f6ad01c801d6ccbe013.tar.bz2 glibc-c4563d2d668675c2d5083f6ad01c801d6ccbe013.zip |
Update.
1999-04-28 Ulrich Drepper <drepper@cygnus.com>
* argp/argp-ba.c (argp_program_bug_address): Don't initialize with 0.
* argp/argp-parse.c (_argp_hang): Likewise.
* argp/argp-pv.c (argp_program_version): Likewise.
* argp/argp-pvh.c (argp_program_version_hook): Likewise.
* inet/ether_hton.c (ether_hton, startp): Likewise.
* inet/ether_ntoh.c (ether_ntoh, startp): Likewise.
* inet/getnetgrent_r.c (setup, startp): Likewise.
* intl/loadmsgcat.c (_nl_msg_cat_cntr): Likewise.
* intl/localealias.c (string_space, string_space_act, string_space_max,
nmap, maxmap): Likewise.
* libio/iopopen.c (proc_file_chain): Likewise.
* libio/oldiopopen.c (old_proc_file_chain): Likewise.
* locale/lc-collate.c (__collate_table, __collate_extra,
__collate_element_hash, __collate_element_strings,
__collate_element_values): Likewise.
* malloc/mcheck.c (mcheck_used): Likewise.
* malloc/mtrace.c (added_atexit_handler): Likewise.
* malloc/set-freeres.c (already_called): Likewise.
* misc/getpass.c (getpass) [buf, bufsize]: Likewise.
* misc/syslog.c (LogStat, LogTag): Likewise.
* nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise.
* nss/getXXbyYY_r.c (startp): Likewise.
* posix/getopt.c (optarg, __getopt_initialized): Likewise.
* posix/regex.c (init_syntax_once) [done]: Likewise.
(debug): Likewise.
* string/strfry.c (init): Likewise.
* sunrpc/svc_run.c (svc_top): Likewise.
* posix/euidaccess.c (have_ids): Likewise.
* sysdeps/unix/sysv/linux/poll.c (must_emulate): Likewise.
* sysdeps/unix/sysv/linux/ttyname.c (__ttyname, namelen): Likewise.
* time/getdate.c (getdate_err): Likewise.
* time/tzfile.c (transitions, type_idxs, types, zone_names, leaps):
Likewise.
* time/tzset.c (old_tz, is_initialized): Likewise.
* inet/getnameinfo.c (nrl_domainname): Rewrite to allow initialization
of static data with zero.
* signal/allocrtsig.c (init): Likewise.
* string/Makefile (routines): Add strchrnul.
* string/Versions [GLIBC_2.1.1]: Add strchrnul.
* string/string.c: Add strchrnul prototype.
* include/string.h: Add __strchrnul prototype.
* sysdeps/generic/strchrnul.c: New file.
* sysdeps/i386/strchrnul.S: New file.
* sysdeps/i386/bits/string.c: Add strchrnul optimization.
* sysdeps/i386/i486/bits/string.c: Likewise.
* argp/argp-help.c (argp_args_usage): Use __strchrnul.
* inet/ether_line.c (ether_line): Likewise.
* nscd/nscd_conf.c (nscd_parse_file): Likewise.
* nss/nsswitch.c (nss_parse_file): Likewise.
* posix/execvp.c (execvp): Likewise.
* posix/fnmatch.c (internal_fnmatch): Likewise.
* resolv/res_hconf.c (_res_hconv_init): Likewise.
* resolv/res_init.c (res_init): Likewise.
* stdlib/fmtmsg.c (init): Likewise.
* stdlib/getsubopt.c (getsubopt): Likewise.
* catgets/catgets.c (catopen): Only allocate one memory block.
(catclose): Only one free call necessary.
* catgets/open_catalog.c (__open_catalog): Simplify handling of
file descriptor.
* ctype/ctype-extn.c: Make __toascii_l and __isascii_l alias instead
of real functions. Simplify _tolower and _toupper.
* grp/initgroups.c (compat_call): Remove unnecessary use of pointer
variable.
* iconv/gconv.h (struct gconv_info): Change data element from pointer
to array of size 0.
* iconv/gconv_open.c (__gconv_open): Allocate structures accordingly.
* iconv/gconv_close.c (__gconv_close): Don't free data.
* iconv/gconv_conf.c (add_alias): Avoid searching in tree twice to
insert new alias.
* iconv/gconv_db.c (add_derivation): More efficient copying. Check
for error while inserting in tree.
* include/time.h: Pretty print.
* inet/ruserpass.c: Rewrite use of toktab to avoid string pointers
in table and lots of relocations.
* posix/regex.c (regerror): Rewrite use of re_error_msgid to avoid
string pointers in table and lots of relocations.
* intl/finddomain.c: Remove definition of strchr macro.
* io/ftw.c (nftw_arr, ftw_arr): Make const.
* locale/loadlocale.c (_nl_load_locale): Optimize string copying.
* locale/localeinfo.h (_nl_category_names): Change into an array with
fixed width char string elements.
* locale/setlocale.c (_nl_category_names): Likewise.
(_nl_current): Make global.
* locale/nl_langinfo.c (nldata): Removed. Use _nl_current now.
* malloc/Makefile (distribute): Add stackinfo.h.
* sysdeps/generic/stackinfo.h: New file.
* sysdeps/i386/stackinfo.h: New file.
* posix/execl.c: Use stackinfo.h in optimizing alloca use.
* posix/execle.c: Likewise.
* posix/execlp.c: Likewise.
* nis/nis_table.c (__create_ib_request): Always use realloc.
* posix/execvp.c (execute): Rename to script_execute and keep only
code to execute using shell.
(execvp): Call execv directly and only fall back on script_execute.
* resolv/inet_net_pton.c (inet_net_pton_ipv4): Remove digits define
and always use xdigits instead.
* resolv/res_init.c (res_init): Use rawmemchr instead of strchr
where appropriate.
* stdlib/fpioconst.h (__tens): New declaration.
(struct mp_power): Remove array, add arrayoff element.
* stdlib/fpioconst.c: Replace definitions of _ten_p* arrays by one
__tens array and add in _fpioconst_pow10 offsets into __tens.
* stdio-common/printf_fp.c: Rewrite to use new __tens array.
* stdlib/strtod.c: Likewise.
* stdlib/a64l.c (a64l_table): Avoid unnecessary elements.
* stdlib/exit.c: Rewrite to use __exit_funcs being as sign for end
of the list.
* stdlib/atexit.c (__exit_funcs): Don't initialize.
* stdlib/fmtmsg.c (keywords): Make name element fixed width array.
* sunrpc/clnt_perr.c: Rewrite clnt_sperrno and auth_errmsg to use
a single and an array with offsets.
* sunrpc/des_soft.c (partab): Make it const.
* sunrpc/key_call.c (trytimeout, tottimeout): Make const.
(__key_encryptsession_pk_LOCAL): Don't initialize with 0.
(__key_decryptsession_pk_LOCAL): Likewise.
(__key_gendes_LOCAL): Likewise.
(MESSENGER): Mark const.
(key_call_private_main): Don't initialize with 0.
(use_keyenvoy): Don't initialize with 0.
(key_call): Rewrite to reverse logic of use_doors variable.
* sunrpc/netname.c (OPSYS): Define as array, not pointer.
(startp): Don't initialize with zero.
* sunrpc/openchild.c (_openchild): Make first argument const.
* sunrpc/pmap_rmt.c (timeout): Mark const.
* sunrpc/xcrypt.c (hex): Likewise.
* sysdeps/unix/sysv/linux/getcwd.c: Rewrite to allow omitting
initialization of global variables.
* sysdeps/unix/sysv/linux/getpt.c: Likewise.
* sysdeps/unix/sysv/linux/if_index.c: Likewise.
* termios/tcgetsid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-procinfo.h (x86_cap_flags): Change
fxsr to osfxsr.
* time/tzfile.c (__tzfile_read): Rewrite to allocate only one memory
block. Add function to free memory if wanted.
* time/tzset.c (tzset_internal): Pass extra argument to __tzfile_read.
* wcsmbs/wcsmbsload.c (to_wc, to_mb): Correct initializers.
* wcsmbs/wmemset.c: Little code optimization.
69 files changed, 1790 insertions, 777 deletions
@@ -1,3 +1,178 @@ +1999-04-28 Ulrich Drepper <drepper@cygnus.com> + + * argp/argp-ba.c (argp_program_bug_address): Don't initialize with 0. + * argp/argp-parse.c (_argp_hang): Likewise. + * argp/argp-pv.c (argp_program_version): Likewise. + * argp/argp-pvh.c (argp_program_version_hook): Likewise. + * inet/ether_hton.c (ether_hton, startp): Likewise. + * inet/ether_ntoh.c (ether_ntoh, startp): Likewise. + * inet/getnetgrent_r.c (setup, startp): Likewise. + * intl/loadmsgcat.c (_nl_msg_cat_cntr): Likewise. + * intl/localealias.c (string_space, string_space_act, string_space_max, + nmap, maxmap): Likewise. + * libio/iopopen.c (proc_file_chain): Likewise. + * libio/oldiopopen.c (old_proc_file_chain): Likewise. + * locale/lc-collate.c (__collate_table, __collate_extra, + __collate_element_hash, __collate_element_strings, + __collate_element_values): Likewise. + * malloc/mcheck.c (mcheck_used): Likewise. + * malloc/mtrace.c (added_atexit_handler): Likewise. + * malloc/set-freeres.c (already_called): Likewise. + * misc/getpass.c (getpass) [buf, bufsize]: Likewise. + * misc/syslog.c (LogStat, LogTag): Likewise. + * nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise. + * nss/getXXbyYY_r.c (startp): Likewise. + * posix/getopt.c (optarg, __getopt_initialized): Likewise. + * posix/regex.c (init_syntax_once) [done]: Likewise. + (debug): Likewise. + * string/strfry.c (init): Likewise. + * sunrpc/svc_run.c (svc_top): Likewise. + * posix/euidaccess.c (have_ids): Likewise. + * sysdeps/unix/sysv/linux/poll.c (must_emulate): Likewise. + * sysdeps/unix/sysv/linux/ttyname.c (__ttyname, namelen): Likewise. + * time/getdate.c (getdate_err): Likewise. + * time/tzfile.c (transitions, type_idxs, types, zone_names, leaps): + Likewise. + * time/tzset.c (old_tz, is_initialized): Likewise. + + * inet/getnameinfo.c (nrl_domainname): Rewrite to allow initialization + of static data with zero. + * signal/allocrtsig.c (init): Likewise. + + * string/Makefile (routines): Add strchrnul. + * string/Versions [GLIBC_2.1.1]: Add strchrnul. + * string/string.c: Add strchrnul prototype. + * include/string.h: Add __strchrnul prototype. + * sysdeps/generic/strchrnul.c: New file. + * sysdeps/i386/strchrnul.S: New file. + * sysdeps/i386/bits/string.c: Add strchrnul optimization. + * sysdeps/i386/i486/bits/string.c: Likewise. + * argp/argp-help.c (argp_args_usage): Use __strchrnul. + * inet/ether_line.c (ether_line): Likewise. + * nscd/nscd_conf.c (nscd_parse_file): Likewise. + * nss/nsswitch.c (nss_parse_file): Likewise. + * posix/execvp.c (execvp): Likewise. + * posix/fnmatch.c (internal_fnmatch): Likewise. + * resolv/res_hconf.c (_res_hconv_init): Likewise. + * resolv/res_init.c (res_init): Likewise. + * stdlib/fmtmsg.c (init): Likewise. + * stdlib/getsubopt.c (getsubopt): Likewise. + + * catgets/catgets.c (catopen): Only allocate one memory block. + (catclose): Only one free call necessary. + + * catgets/open_catalog.c (__open_catalog): Simplify handling of + file descriptor. + + * ctype/ctype-extn.c: Make __toascii_l and __isascii_l alias instead + of real functions. Simplify _tolower and _toupper. + + * grp/initgroups.c (compat_call): Remove unnecessary use of pointer + variable. + + * iconv/gconv.h (struct gconv_info): Change data element from pointer + to array of size 0. + * iconv/gconv_open.c (__gconv_open): Allocate structures accordingly. + * iconv/gconv_close.c (__gconv_close): Don't free data. + + * iconv/gconv_conf.c (add_alias): Avoid searching in tree twice to + insert new alias. + + * iconv/gconv_db.c (add_derivation): More efficient copying. Check + for error while inserting in tree. + + * include/time.h: Pretty print. + + * inet/ruserpass.c: Rewrite use of toktab to avoid string pointers + in table and lots of relocations. + * posix/regex.c (regerror): Rewrite use of re_error_msgid to avoid + string pointers in table and lots of relocations. + + * intl/finddomain.c: Remove definition of strchr macro. + + * io/ftw.c (nftw_arr, ftw_arr): Make const. + + * locale/loadlocale.c (_nl_load_locale): Optimize string copying. + + * locale/localeinfo.h (_nl_category_names): Change into an array with + fixed width char string elements. + * locale/setlocale.c (_nl_category_names): Likewise. + (_nl_current): Make global. + * locale/nl_langinfo.c (nldata): Removed. Use _nl_current now. + + * malloc/Makefile (distribute): Add stackinfo.h. + * sysdeps/generic/stackinfo.h: New file. + * sysdeps/i386/stackinfo.h: New file. + * posix/execl.c: Use stackinfo.h in optimizing alloca use. + * posix/execle.c: Likewise. + * posix/execlp.c: Likewise. + + * nis/nis_table.c (__create_ib_request): Always use realloc. + + * posix/execvp.c (execute): Rename to script_execute and keep only + code to execute using shell. + (execvp): Call execv directly and only fall back on script_execute. + + * resolv/inet_net_pton.c (inet_net_pton_ipv4): Remove digits define + and always use xdigits instead. + + * resolv/res_init.c (res_init): Use rawmemchr instead of strchr + where appropriate. + + * stdlib/fpioconst.h (__tens): New declaration. + (struct mp_power): Remove array, add arrayoff element. + * stdlib/fpioconst.c: Replace definitions of _ten_p* arrays by one + __tens array and add in _fpioconst_pow10 offsets into __tens. + * stdio-common/printf_fp.c: Rewrite to use new __tens array. + * stdlib/strtod.c: Likewise. + + * stdlib/a64l.c (a64l_table): Avoid unnecessary elements. + + * stdlib/exit.c: Rewrite to use __exit_funcs being as sign for end + of the list. + * stdlib/atexit.c (__exit_funcs): Don't initialize. + + * stdlib/fmtmsg.c (keywords): Make name element fixed width array. + + * sunrpc/clnt_perr.c: Rewrite clnt_sperrno and auth_errmsg to use + a single and an array with offsets. + + * sunrpc/des_soft.c (partab): Make it const. + + * sunrpc/key_call.c (trytimeout, tottimeout): Make const. + (__key_encryptsession_pk_LOCAL): Don't initialize with 0. + (__key_decryptsession_pk_LOCAL): Likewise. + (__key_gendes_LOCAL): Likewise. + (MESSENGER): Mark const. + (key_call_private_main): Don't initialize with 0. + (use_keyenvoy): Don't initialize with 0. + (key_call): Rewrite to reverse logic of use_doors variable. + + * sunrpc/netname.c (OPSYS): Define as array, not pointer. + (startp): Don't initialize with zero. + + * sunrpc/openchild.c (_openchild): Make first argument const. + + * sunrpc/pmap_rmt.c (timeout): Mark const. + * sunrpc/xcrypt.c (hex): Likewise. + + * sysdeps/unix/sysv/linux/getcwd.c: Rewrite to allow omitting + initialization of global variables. + * sysdeps/unix/sysv/linux/getpt.c: Likewise. + * sysdeps/unix/sysv/linux/if_index.c: Likewise. + * termios/tcgetsid.c: Likewise. + + * sysdeps/unix/sysv/linux/i386/dl-procinfo.h (x86_cap_flags): Change + fxsr to osfxsr. + + * time/tzfile.c (__tzfile_read): Rewrite to allocate only one memory + block. Add function to free memory if wanted. + * time/tzset.c (tzset_internal): Pass extra argument to __tzfile_read. + + * wcsmbs/wcsmbsload.c (to_wc, to_mb): Correct initializers. + + * wcsmbs/wmemset.c: Little code optimization. + 1999-04-23 Paul Eggert <eggert@twinsun.com> * stdlib/strtoull.c: Surround strong_alias and weak_alias with diff --git a/locale/lc-collate.c b/locale/lc-collate.c index 7052db3062..4376286812 100644 --- a/locale/lc-collate.c +++ b/locale/lc-collate.c @@ -1,5 +1,5 @@ /* Define current locale data for LC_COLLATE category. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999 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,12 +28,12 @@ extern const u_int32_t _nl_C_LC_COLLATE_symbol_classes[]; _NL_CURRENT_DEFINE (LC_COLLATE); -const u_int32_t *__collate_table = NULL; -const u_int32_t *__collate_extra = NULL; +const u_int32_t *__collate_table; +const u_int32_t *__collate_extra; -const u_int32_t *__collate_element_hash = NULL; -const char *__collate_element_strings = NULL; -const wchar_t *__collate_element_values = NULL; +const u_int32_t *__collate_element_hash; +const char *__collate_element_strings; +const wchar_t *__collate_element_values; const u_int32_t *__collate_symbol_hash = _nl_C_LC_COLLATE_symbol_hash; const char *__collate_symbol_strings = _nl_C_LC_COLLATE_symbol_strings; diff --git a/locale/loadlocale.c b/locale/loadlocale.c index c762b77ed1..24d0c3a67d 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -97,13 +97,17 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) /* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo instead. */ char *newp; + size_t filenamelen; __close (fd); - newp = (char *) alloca (strlen (file->filename) + filenamelen = strlen (file->filename); + newp = (char *) alloca (filenamelen + 5 + _nl_category_name_sizes[category] + 1); - __stpcpy (__stpcpy (__stpcpy (newp, file->filename), "/SYS_"), - _nl_category_names[category]); + __mempcpy (__mempcpy (__mempcpy (newp, file->filename, filenamelen), + "/SYS_", 5), + _nl_category_names[category], + _nl_category_name_sizes[category] + 1); fd = __open (newp, O_RDONLY); if (fd < 0) diff --git a/locale/localeinfo.h b/locale/localeinfo.h index f50565c54a..9f58a743c8 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -1,5 +1,5 @@ /* localeinfo.h -- declarations for internal libc locale interfaces - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999 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 @@ -104,7 +104,7 @@ extern struct locale_data *_nl_current_##category; #include "categories.def" #undef DEFINE_CATEGORY -extern const char *const _nl_category_names[LC_ALL + 1]; +extern const char _nl_category_names[LC_ALL + 1][12]; extern const size_t _nl_category_name_sizes[LC_ALL + 1]; extern struct locale_data * *const _nl_current[LC_ALL + 1]; diff --git a/locale/nl_langinfo.c b/locale/nl_langinfo.c index df2b3e9fb9..4c8e6285d3 100644 --- a/locale/nl_langinfo.c +++ b/locale/nl_langinfo.c @@ -1,5 +1,5 @@ /* User interface for extracting locale-dependent parameters. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,18 +22,6 @@ #include <stddef.h> #include "localeinfo.h" -/* This array duplicates `_nl_current' defined in setlocale.c; but since - the references here are not weak references, this guarantees that the - data for all the categories will be linked in. */ - -static struct locale_data * *const nldata[] = -{ -#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \ - [category] = &_nl_current_##category, -#include "categories.def" -#undef DEFINE_CATEGORY -}; - /* Return a string with the data for locale-dependent parameter ITEM. */ @@ -52,7 +40,7 @@ nl_langinfo (item) return NULL; } - data = *nldata[category]; + data = *_nl_current[category]; if (index >= data->nstrings) { diff --git a/locale/setlocale.c b/locale/setlocale.c index dee83d7fb4..1bcc4d5375 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -40,9 +40,8 @@ extern struct locale_data _nl_C_##category; #include "categories.def" #undef DEFINE_CATEGORY -/* Array indexed by category of pointers to _nl_current_CATEGORY slots. - Elements are zero for categories whose data is never used. */ -static struct locale_data * *const _nl_current[] = +/* Array indexed by category of pointers to _nl_current_CATEGORY slots. */ +struct locale_data * *const _nl_current[] = { #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \ [category] = &_nl_current_##category, @@ -65,8 +64,12 @@ struct locale_data *const _nl_C[] = /* Define an array of category names (also the environment variable names), - indexed by integral category. */ -const char *const _nl_category_names[] = + indexed by integral category. + + We have entries of fixed width (12 for now) do avoid an array of + pointers. Update the size of the outer array if new, longer locale + names are introduced. */ +const char _nl_category_names[][12] = { #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \ [category] = category_name, diff --git a/malloc/Makefile b/malloc/Makefile index 53251ba58a..9fd4e2c9f0 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +# Copyright (C) 1991,92,93,94,95,96,97,98,99 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 @@ -27,7 +27,7 @@ dist-headers := malloc.h headers := $(dist-headers) obstack.h mcheck.h tests := mallocbug -distribute = thread-m.h mtrace.pl mcheck-init.c +distribute = thread-m.h mtrace.pl mcheck-init.c stackinfo.h # Things which get pasted together into gmalloc.c. gmalloc-routines := malloc morecore diff --git a/malloc/mcheck.c b/malloc/mcheck.c index c5baa3d4a7..53575a7677 100644 --- a/malloc/mcheck.c +++ b/malloc/mcheck.c @@ -1,5 +1,5 @@ /* Standard debugging hooks for `malloc'. - Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc. + Copyright (C) 1990,91,92,93,94,95,96,97,99 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or @@ -220,7 +220,7 @@ mabort (status) #endif } -static int mcheck_used = 0; +static int mcheck_used; int mcheck (func) diff --git a/malloc/mtrace.c b/malloc/mtrace.c index d15569c9d6..6af064c6ce 100644 --- a/malloc/mtrace.c +++ b/malloc/mtrace.c @@ -1,5 +1,5 @@ /* More debugging hooks for `malloc'. - Copyright (C) 1991, 92, 93, 94, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1991,92,93,94,96,97,98,99 Free Software Foundation, Inc. Written April 2, 1991 by John Gilmore of Cygnus Support. Based on mcheck.c by Mike Haertel. @@ -243,7 +243,7 @@ void mtrace () { #ifdef _LIBC - static int added_atexit_handler = 0; + static int added_atexit_handler; #endif char *mallfile; diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c index 7efd06e33c..e73da87bf7 100644 --- a/malloc/set-freeres.c +++ b/malloc/set-freeres.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999 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 @@ -26,7 +26,7 @@ __libc_freeres (void) { /* This function might be called from different places. So better protect for multiple executions since these are fatal. */ - static int already_called = 0; + static int already_called; if (!already_called) RUN_HOOK (__libc_subfreeres, ()); diff --git a/misc/getpass.c b/misc/getpass.c index 8c6cf568a5..7c4120a64c 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1992,93,94,95,96,97,98,99 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 @@ -41,8 +41,8 @@ getpass (prompt) FILE *in, *out; struct termios s, t; int tty_changed; - static char *buf = NULL; - static size_t bufsize = 0; + static char *buf; + static size_t bufsize; ssize_t nread; /* Try to write to and read from the terminal if we can. diff --git a/misc/syslog.c b/misc/syslog.c index bba9492bdc..1cc0e8f9a3 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -66,8 +66,8 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; static int LogType = SOCK_DGRAM; /* type of socket connection */ static int LogFile = -1; /* fd for log */ static int connected; /* have done connect */ -static int LogStat = 0; /* status bits, set by openlog() */ -static const char *LogTag = NULL; /* string to tag the entry with */ +static int LogStat; /* status bits, set by openlog() */ +static const char *LogTag; /* string to tag the entry with */ static int LogFacility = LOG_USER; /* default facility code */ static int LogMask = 0xff; /* mask of priorities to be logged */ extern char *__progname; /* Program name, from crt0. */ diff --git a/nis/nis_table.c b/nis/nis_table.c index d5b8f35a55..2cb21d4fda 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -78,10 +78,7 @@ __create_ib_request (const_nis_name name, unsigned int flags) if ((search_len + 1) >= size) { size += 1; - if (size == 1) - search_val = malloc (size * sizeof (nis_attr)); - else - search_val = realloc (search_val, size * sizeof (nis_attr)); + search_val = realloc (search_val, size * sizeof (nis_attr)); if (search_val == NULL) { nis_free_request (ibreq); diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c index 6ac1677a8b..d31e2bde3a 100644 --- a/nscd/nscd_conf.c +++ b/nscd/nscd_conf.c @@ -63,9 +63,7 @@ nscd_parse_file (const char *fname, struct database dbs[lastdb]) /* Because the file format does not know any form of quoting we can search forward for the next '#' character and if found make it terminating the line. */ - cp = strchr (line, '#'); - if (cp != NULL) - *cp = '\0'; + *strchrnul (line, '#') = '\0'; /* If the line is blank it is ignored. */ if (line[0] == '\0') diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c index 900bc307b9..dc7a663abd 100644 --- a/nss/XXX-lookup.c +++ b/nss/XXX-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -53,7 +53,7 @@ #define DEFAULT_CONFIG NULL #endif -service_user *DATABASE_NAME_SYMBOL = NULL; +service_user *DATABASE_NAME_SYMBOL; int DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp) diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c index 3c7f2a14bb..33b4fc94e8 100644 --- a/nss/getXXbyYY_r.c +++ b/nss/getXXbyYY_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -104,7 +104,7 @@ int INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM) { - static service_user *startp = NULL; + static service_user *startp; static lookup_function start_fct; service_user *nip; lookup_function fct; diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 5bce1f5af3..1a6c16e3ae 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -505,7 +505,6 @@ nss_parse_file (const char *fname) { name_database_entry *this; ssize_t n; - char *cp; n = __getline (&line, &len, fp); if (n < 0) @@ -516,9 +515,7 @@ nss_parse_file (const char *fname) /* Because the file format does not know any form of quoting we can search forward for the next '#' character and if found make it terminating the line. */ - cp = strchr (line, '#'); - if (cp != NULL) - *cp = '\0'; + *__strchrnul (line, '#') = '\0'; /* If the line is blank it is ignored. */ if (line[0] == '\0') diff --git a/posix/execl.c b/posix/execl.c index 13f8b393d5..5ea1c4ebf0 100644 --- a/posix/execl.c +++ b/posix/execl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1994, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 94, 97, 98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,8 @@ #include <stddef.h> #include <string.h> +#include <stackinfo.h> + #ifndef HAVE_GNU_LD # define __environ environ #endif @@ -46,16 +48,21 @@ execl (const char *path, const char *arg, ...) { const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *)); +#ifndef _STACK_GROWS_UP if ((char *) nptr + argv_max == (char *) argv) { /* Stack grows down. */ argv = (const char **) memcpy (nptr, argv, i); argv_max += i; } - else if ((char *) argv + i == (char *) nptr) + else +#endif +#ifndef _STACK_GROWS_DOWN + if ((char *) argv + i == (char *) nptr) /* Stack grows up. */ argv_max += i; else +#endif /* We have a hole in the stack. */ argv = (const char **) memcpy (nptr, argv, i); } diff --git a/posix/execle.c b/posix/execle.c index dc150a4702..a8a016ee69 100644 --- a/posix/execle.c +++ b/posix/execle.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,8 @@ #include <stddef.h> #include <string.h> +#include <stackinfo.h> + /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ int @@ -34,7 +36,7 @@ execle (const char *path, const char *arg, ...) va_list args; argv[0] = arg; - va_start(args, arg); + va_start (args, arg); i = 0; while (argv[i++] != NULL) { @@ -42,16 +44,21 @@ execle (const char *path, const char *arg, ...) { const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *)); +#ifndef _STACK_GROWS_UP if ((char *) nptr + argv_max == (char *) argv) { /* Stack grows down. */ argv = (const char **) memcpy (nptr, argv, i); argv_max += i; } - else if ((char *) argv + i == (char *) nptr) + else +#endif +#ifndef _STACK_GROWS_DOWN + if ((char *) argv + i == (char *) nptr) /* Stack grows up. */ argv_max += i; else +#endif /* We have a hole in the stack. */ argv = (const char **) memcpy (nptr, argv, i); } @@ -59,8 +66,8 @@ execle (const char *path, const char *arg, ...) argv[i] = va_arg (args, const char *); } - envp = va_arg(args, const char *const *); - va_end(args); + envp = va_arg (args, const char *const *); + va_end (args); - return __execve(path, (char *const *) argv, (char *const *) envp); + return __execve (path, (char *const *) argv, (char *const *) envp); } diff --git a/posix/execlp.c b/posix/execlp.c index 6cad6402ec..40456f7817 100644 --- a/posix/execlp.c +++ b/posix/execlp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 93, 96, 97, 98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,8 @@ #include <stddef.h> #include <string.h> +#include <stackinfo.h> + /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with all arguments after FILE until a NULL pointer and environment from `environ'. */ @@ -43,16 +45,21 @@ execlp (const char *file, const char *arg, ...) { const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *)); +#ifndef _STACK_GROWS_UP if ((char *) nptr + argv_max == (char *) argv) { /* Stack grows down. */ argv = (const char **) memcpy (nptr, argv, i); argv_max += i; } - else if ((char *) argv + i == (char *) nptr) + else +#endif +#ifndef _STACK_GROWS_DOWN + if ((char *) argv + i == (char *) nptr) /* Stack grows up. */ argv_max += i; else +#endif /* We have a hole in the stack. */ argv = (const char **) memcpy (nptr, argv, i); } diff --git a/posix/execvp.c b/posix/execvp.c index 7afb01d11f..3f93357af8 100644 --- a/posix/execvp.c +++ b/posix/execvp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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 @@ -24,37 +24,31 @@ #include <paths.h> +/* The file is accessible but it is not an executable file. Invoke + the shell to interpret it as a script. */ static void internal_function -execute (const char *file, char *const argv[]) +script_execute (const char *file, char *const argv[]) { - execv (file, argv); - - if (errno == ENOEXEC) - { - /* The file is accessible but it is not an executable file. - Invoke the shell to interpret it as a script. */ - - /* Count the arguments. */ - int argc = 0; - while (argv[argc++]) - ; - - /* Construct an argument list for the shell. */ + /* Count the arguments. */ + int argc = 0; + while (argv[argc++]) + ; + + /* Construct an argument list for the shell. */ + { + char *new_argv[argc + 1]; + new_argv[0] = (char *) _PATH_BSHELL; + new_argv[1] = (char *) file; + while (argc > 1) { - char *new_argv[argc + 1]; - new_argv[0] = (char *) _PATH_BSHELL; - new_argv[1] = (char *) file; - while (argc > 1) - { - new_argv[argc] = argv[argc - 1]; - --argc; - } - - /* Execute the shell. */ - execv (new_argv[0], new_argv); + new_argv[argc] = argv[argc - 1]; + --argc; } - } + + /* Execute the shell. */ + execv (new_argv[0], new_argv); + } } @@ -65,8 +59,6 @@ execvp (file, argv) const char *file; char *const argv[]; { - int got_eacces = 0; - if (*file == '\0') { /* We check the simple case first. */ @@ -75,10 +67,16 @@ execvp (file, argv) } if (strchr (file, '/') != NULL) - /* Don't search when it contains a slash. */ - execute (file, argv); + { + /* Don't search when it contains a slash. */ + execv (file, argv); + + if (errno == ENOEXEC) + script_execute (file, argv); + } else { + int got_eacces = 0; char *path, *p, *name; size_t len; @@ -100,9 +98,7 @@ execvp (file, argv) do { path = p; - p = strchr (path, ':'); - if (p == NULL) - p = strchr (path, '\0'); + p = __strchrnul (path, ':'); if (p == path) /* Two adjacent colons, or a colon at the beginning or the end @@ -113,11 +109,14 @@ execvp (file, argv) /* Construct the pathname to try. */ char *tmp = __mempcpy (name, path, p - path); *tmp++ = '/'; - (void) __mempcpy (tmp, file, len); + memcpy (tmp, file, len); } /* Try to execute this name. If it works, execv will not return. */ - execute (name, argv); + execv (name, argv); + + if (errno == ENOEXEC) + script_execute (name, argv); switch (errno) { @@ -142,13 +141,13 @@ execvp (file, argv) } } while (*p++ != '\0'); - } - - /* We tried every element and none of them worked. */ - if (got_eacces) - /* At least one failure was due to permissions, so report that error. */ - __set_errno (EACCES); + /* We tried every element and none of them worked. */ + if (got_eacces) + /* At least one failure was due to permissions, so report that + error. */ + __set_errno (EACCES); + } /* Return the error from the last attempt (probably ENOENT). */ return -1; diff --git a/posix/fnmatch.c b/posix/fnmatch.c index eb3f1cc2d4..9617d336f4 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -211,8 +211,7 @@ internal_fnmatch (const char *pattern, const char *string, { const char *endp; - if (!(flags & FNM_FILE_NAME) || (endp = strchr (n, '/')) == NULL) - endp = strchr (n, '\0'); + endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0'); if (c == '[') { diff --git a/posix/getopt.c b/posix/getopt.c index 81cef23f9b..efd822358f 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -3,7 +3,7 @@ "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or @@ -109,7 +109,7 @@ Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -char *optarg = NULL; +char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -130,7 +130,7 @@ int optind = 1; causes problems with re-calling getopt as programs generally don't know that. */ -int __getopt_initialized = 0; +int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. diff --git a/posix/regex.c b/posix/regex.c index 74fcf9c45e..5cbc046c70 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -179,7 +179,7 @@ static void init_syntax_once () { register int c; - static int done = 0; + static int done; if (done) return; @@ -615,7 +615,7 @@ extract_number_and_incr (destination, source) /* It is useful to test things that ``must'' be true when debugging. */ # include <assert.h> -static int debug = 0; +static int debug; # define DEBUG_STATEMENT(e) e # define DEBUG_PRINT1(x) if (debug) printf (x) @@ -1013,26 +1013,80 @@ weak_alias (__re_set_syntax, re_set_syntax) POSIX doesn't require that we do anything for REG_NOERROR, but why not be nice? */ -static const char *re_error_msgid[] = +static const char re_error_msgid[] = { - gettext_noop ("Success"), /* REG_NOERROR */ - gettext_noop ("No match"), /* REG_NOMATCH */ - gettext_noop ("Invalid regular expression"), /* REG_BADPAT */ +#define REG_NOERROR_IDX 0 + gettext_noop ("Success") /* REG_NOERROR */ + "\0" +#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") + gettext_noop ("No match") /* REG_NOMATCH */ + "\0" +#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") + gettext_noop ("Invalid regular expression") /* REG_BADPAT */ + "\0" +#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") gettext_noop ("Invalid collation character"), /* REG_ECOLLATE */ - gettext_noop ("Invalid character class name"), /* REG_ECTYPE */ - gettext_noop ("Trailing backslash"), /* REG_EESCAPE */ - gettext_noop ("Invalid back reference"), /* REG_ESUBREG */ - gettext_noop ("Unmatched [ or [^"), /* REG_EBRACK */ - gettext_noop ("Unmatched ( or \\("), /* REG_EPAREN */ - gettext_noop ("Unmatched \\{"), /* REG_EBRACE */ - gettext_noop ("Invalid content of \\{\\}"), /* REG_BADBR */ - gettext_noop ("Invalid range end"), /* REG_ERANGE */ - gettext_noop ("Memory exhausted"), /* REG_ESPACE */ - gettext_noop ("Invalid preceding regular expression"), /* REG_BADRPT */ - gettext_noop ("Premature end of regular expression"), /* REG_EEND */ - gettext_noop ("Regular expression too big"), /* REG_ESIZE */ + "\0" +#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") + gettext_noop ("Invalid character class name") /* REG_ECTYPE */ + "\0" +#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") + gettext_noop ("Trailing backslash") /* REG_EESCAPE */ + "\0" +#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") + gettext_noop ("Invalid back reference") /* REG_ESUBREG */ + "\0" +#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") + gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ + "\0" +#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") + gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ + "\0" +#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") + gettext_noop ("Unmatched \\{") /* REG_EBRACE */ + "\0" +#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") + gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ + "\0" +#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") + gettext_noop ("Invalid range end") /* REG_ERANGE */ + "\0" +#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") + gettext_noop ("Memory exhausted") /* REG_ESPACE */ + "\0" +#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") + gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ + "\0" +#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") + gettext_noop ("Premature end of regular expression") /* REG_EEND */ + "\0" +#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") + gettext_noop ("Regular expression too big") /* REG_ESIZE */ + "\0" +#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */ }; + +static const size_t re_error_msgid_idx[] = + { + REG_NOERROR_IDX, + REG_NOMATCH_IDX, + REG_BADPAT_IDX, + REG_ECOLLATE_IDX, + REG_ECTYPE_IDX, + REG_EESCAPE_IDX, + REG_ESUBREG_IDX, + REG_EBRACK_IDX, + REG_EPAREN_IDX, + REG_EBRACE_IDX, + REG_BADBR_IDX, + REG_ERANGE_IDX, + REG_ESPACE_IDX, + REG_BADRPT_IDX, + REG_EEND_IDX, + REG_ESIZE_IDX, + REG_ERPAREN_IDX + }; /* Avoiding alloca during matching, to placate r_alloc. */ @@ -3848,7 +3902,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) fail_stack_type fail_stack; #endif #ifdef DEBUG - static unsigned failure_id = 0; + static unsigned failure_id; unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif @@ -5489,7 +5543,7 @@ re_compile_pattern (pattern, length, bufp) if (!ret) return NULL; - return gettext (re_error_msgid[(int) ret]); + return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]); } #ifdef _LIBC weak_alias (__re_compile_pattern, re_compile_pattern) @@ -5526,12 +5580,14 @@ re_comp (s) { re_comp_buf.buffer = (unsigned char *) malloc (200); if (re_comp_buf.buffer == NULL) - return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); + return (char *) gettext (re_error_msgid + + re_error_msgid_idx[(int) REG_ESPACE]); re_comp_buf.allocated = 200; re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (re_comp_buf.fastmap == NULL) - return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); + return (char *) gettext (re_error_msgid + + re_error_msgid_idx[(int) REG_ESPACE]); } /* Since `re_exec' always passes NULL for the `regs' argument, we @@ -5546,7 +5602,7 @@ re_comp (s) return NULL; /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ - return (char *) gettext (re_error_msgid[(int) ret]); + return (char *) gettext (re_error_msgid + re_error_msgid_idx[(int) ret]); } @@ -5772,15 +5828,15 @@ regerror (errcode, preg, errbuf, errbuf_size) size_t msg_size; if (errcode < 0 - || errcode >= (int) (sizeof (re_error_msgid) - / sizeof (re_error_msgid[0]))) + || errcode >= (int) (sizeof (re_error_msgid_idx) + / sizeof (re_error_msgid_idx[0]))) /* Only error codes returned by the rest of the code should be passed to this routine. If we are given anything else, or if other regex code generates an invalid error code, then the program has a bug. Dump core so we can fix it. */ abort (); - msg = gettext (re_error_msgid[errcode]); + msg = gettext (re_error_msgid + re_error_msgid_idx[errcode]); msg_size = strlen (msg) + 1; /* Includes the null. */ diff --git a/resolv/inet_net_pton.c b/resolv/inet_net_pton.c index d3f1350312..2f06c6803f 100644 --- a/resolv/inet_net_pton.c +++ b/resolv/inet_net_pton.c @@ -91,9 +91,7 @@ inet_net_pton_ipv4(src, dst, size) u_char *dst; size_t size; { - static const char - xdigits[] = "0123456789abcdef", - digits[] = "0123456789"; + static const char xdigits[] = "0123456789abcdef"; int n, ch, tmp, dirty, bits; const u_char *odst = dst; @@ -125,7 +123,7 @@ inet_net_pton_ipv4(src, dst, size) for (;;) { tmp = 0; do { - n = strchr(digits, ch) - digits; + n = strchr(xdigits, ch) - xdigits; assert(n >= 0 && n <= 9); tmp *= 10; tmp += n; @@ -153,7 +151,7 @@ inet_net_pton_ipv4(src, dst, size) ch = *src++; /* Skip over the /. */ bits = 0; do { - n = strchr(digits, ch) - digits; + n = strchr(xdigits, ch) - xdigits; assert(n >= 0 && n <= 9); bits *= 10; bits += n; diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c index 06306f7726..ab49ccf9d6 100644 --- a/resolv/res_hconf.c +++ b/resolv/res_hconf.c @@ -334,9 +334,7 @@ _res_hconf_init (void) while (fgets_unlocked (buf, sizeof (buf), fp)) { ++line_num; - end = strchr (buf, '\n'); - if (end) - *end = '\0'; + *__strchrnul (buf, '\n') = '\0'; parse_line (hconf_name, line_num, buf); } fclose (fp); diff --git a/resolv/res_init.c b/resolv/res_init.c index 893072f24e..de053c4993 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -289,8 +289,7 @@ res_init() if ((*cp == '\0') || (*cp == '\n')) continue; strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); - if ((cp = strchr(_res.defdname, '\n')) != NULL) - *cp = '\0'; + *__strchrnul (_res.defdname, '\n') = '\0'; /* * Set search list to be blank-separated strings * on rest of line. @@ -406,7 +405,7 @@ res_init() while (pp < _res.dnsrch + MAXDFLSRCH) { if (dots < LOCALDOMAINPARTS) break; - cp = strchr(cp, '.') + 1; /* we know there is one */ + cp = __rawmemchr(cp, '.') + 1; /* we know there is one */ *pp++ = cp; dots--; } diff --git a/signal/allocrtsig.c b/signal/allocrtsig.c index e1dde79b66..6f49c8ef12 100644 --- a/signal/allocrtsig.c +++ b/signal/allocrtsig.c @@ -1,5 +1,5 @@ /* Handle real-time signal allocation. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -28,8 +28,8 @@ static int current_rtmin = -1; static int current_rtmax = -1; #else -static int current_rtmin = __SIGRTMIN; -static int current_rtmax = __SIGRTMAX; +static int current_rtmin; +static int current_rtmax; static int initialized; @@ -43,6 +43,11 @@ init (void) current_rtmin = -1; current_rtmax = -1; } + else + { + current_rtmin = __SIGRTMIN; + current_rtmax = __SIGRTMAX; + } initialized = 1; } #endif diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index a179e0dbf6..c75289a3a9 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -404,7 +404,7 @@ __printf_fp (FILE *fp, int scaleexpo = 0; int explog = LDBL_MAX_10_EXP_LOG; int exp10 = 0; - const struct mp_power *tens = &_fpioconst_pow10[explog + 1]; + const struct mp_power *powers = &_fpioconst_pow10[explog + 1]; int cnt_h, cnt_l, i; if ((exponent + to_shift) % BITS_PER_MP_LIMB == 0) @@ -424,23 +424,28 @@ __printf_fp (FILE *fp, } MPN_ZERO (frac, (exponent + to_shift) / BITS_PER_MP_LIMB); - assert (tens > &_fpioconst_pow10[0]); + assert (powers > &_fpioconst_pow10[0]); do { - --tens; + --powers; /* The number of the product of two binary numbers with n and m bits respectively has m+n or m+n-1 bits. */ - if (exponent >= scaleexpo + tens->p_expo - 1) + if (exponent >= scaleexpo + powers->p_expo - 1) { if (scalesize == 0) - MPN_ASSIGN (tmp, tens->array); + { + tmpsize = powers->arraysize; + memcpy (tmp, &__tens[powers->arrayoff], + tmpsize * sizeof (mp_limb_t)); + } else { cy = __mpn_mul (tmp, scale, scalesize, - &tens->array[_FPIO_CONST_OFFSET], - tens->arraysize - _FPIO_CONST_OFFSET); - tmpsize = scalesize + tens->arraysize - _FPIO_CONST_OFFSET; + &__tens[powers->arrayoff + + _FPIO_CONST_OFFSET], + powers->arraysize - _FPIO_CONST_OFFSET); + tmpsize = scalesize + powers->arraysize - _FPIO_CONST_OFFSET; if (cy == 0) --tmpsize; } @@ -456,7 +461,7 @@ __printf_fp (FILE *fp, } --explog; } - while (tens > &_fpioconst_pow10[0]); + while (powers > &_fpioconst_pow10[0]); exponent = exp10; /* Optimize number representations. We want to represent the numbers @@ -547,7 +552,7 @@ __printf_fp (FILE *fp, /* |FP| < 1.0. */ int exp10 = 0; int explog = LDBL_MAX_10_EXP_LOG; - const struct mp_power *tens = &_fpioconst_pow10[explog + 1]; + const struct mp_power *powers = &_fpioconst_pow10[explog + 1]; mp_size_t used_limbs = fracsize - 1; /* Now shift the input value to its right place. */ @@ -558,27 +563,28 @@ __printf_fp (FILE *fp, expsign = 1; exponent = -exponent; - assert (tens != &_fpioconst_pow10[0]); + assert (powers != &_fpioconst_pow10[0]); do { - --tens; + --powers; - if (exponent >= tens->m_expo) + if (exponent >= powers->m_expo) { int i, incr, cnt_h, cnt_l; mp_limb_t topval[2]; /* The __mpn_mul function expects the first argument to be bigger than the second. */ - if (fracsize < tens->arraysize - _FPIO_CONST_OFFSET) - cy = __mpn_mul (tmp, &tens->array[_FPIO_CONST_OFFSET], - tens->arraysize - _FPIO_CONST_OFFSET, + if (fracsize < powers->arraysize - _FPIO_CONST_OFFSET) + cy = __mpn_mul (tmp, &__tens[powers->arrayoff + + _FPIO_CONST_OFFSET], + powers->arraysize - _FPIO_CONST_OFFSET, frac, fracsize); else cy = __mpn_mul (tmp, frac, fracsize, - &tens->array[_FPIO_CONST_OFFSET], - tens->arraysize - _FPIO_CONST_OFFSET); - tmpsize = fracsize + tens->arraysize - _FPIO_CONST_OFFSET; + &__tens[powers->arrayoff + _FPIO_CONST_OFFSET], + powers->arraysize - _FPIO_CONST_OFFSET); + tmpsize = fracsize + powers->arraysize - _FPIO_CONST_OFFSET; if (cy == 0) --tmpsize; @@ -586,7 +592,7 @@ __printf_fp (FILE *fp, incr = (tmpsize - fracsize) * BITS_PER_MP_LIMB + BITS_PER_MP_LIMB - 1 - cnt_h; - assert (incr <= tens->p_expo); + assert (incr <= powers->p_expo); /* If we increased the exponent by exactly 3 we have to test for overflow. This is done by comparing with 10 shifted @@ -674,7 +680,7 @@ __printf_fp (FILE *fp, } --explog; } - while (tens != &_fpioconst_pow10[1] && exponent > 0); + while (powers != &_fpioconst_pow10[1] && exponent > 0); /* All factors but 10^-1 are tested now. */ if (exponent > 0) { diff --git a/stdlib/a64l.c b/stdlib/a64l.c index eb1eef5cbf..a29c712e7d 100644 --- a/stdlib/a64l.c +++ b/stdlib/a64l.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. + Contributed by Ulrich Drepper <drepper@gnu.org>, August 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -19,20 +19,20 @@ #include <stdlib.h> -#define TABLE_BASE 0x20 -#define TABLE_SIZE 0x60 +#define TABLE_BASE 0x2e +#define TABLE_SIZE 0x4d #define XX ((char)0x40) static const char a64l_table[TABLE_SIZE] = { - /* 0x20 */ XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, 0, 1, + /* 0x2e */ 0, 1, /* 0x30 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, XX, XX, XX, XX, XX, XX, /* 0x40 */ XX, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, /* 0x50 */ 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, XX, XX, XX, XX, XX, /* 0x60 */ XX, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 0x70 */ 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, XX, XX, XX, XX, XX + /* 0x70 */ 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 }; diff --git a/stdlib/atexit.c b/stdlib/atexit.c index 7205f50dc0..80cd79ff6a 100644 --- a/stdlib/atexit.c +++ b/stdlib/atexit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1999 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 @@ -40,8 +40,7 @@ atexit (void (*func) (void)) __libc_lock_define_initialized (static, lock) -static struct exit_function_list fnlist = { NULL, 0, }; -struct exit_function_list *__exit_funcs = &fnlist; +struct exit_function_list *__exit_funcs; struct exit_function * __new_exitfn (void) diff --git a/stdlib/exit.c b/stdlib/exit.c index 1ed1e2521b..dc189556b4 100644 --- a/stdlib/exit.c +++ b/stdlib/exit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1996, 1997, 1999 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 @@ -37,12 +37,14 @@ exit (int status) the functions registered with `atexit' and `on_exit'. We call everyone on the list and use the status value in the last exit (). */ - for (; __exit_funcs; __exit_funcs = __exit_funcs->next) + while (__exit_funcs != NULL) { - while ((__exit_funcs->idx)-- > 0) + struct exit_function_list *old; + + do { const struct exit_function *const f = - &__exit_funcs->fns[__exit_funcs->idx]; + &__exit_funcs->fns[--__exit_funcs->idx]; switch (f->flavor) { case ef_free: @@ -56,6 +58,11 @@ exit (int status) break; } } + while (__exit_funcs->idx > 0); + + old = __exit_funcs; + __exit_funcs = __exit_funcs->next; + free (old); } #ifdef HAVE_GNU_LD diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c index 69ed9034a9..082839a956 100644 --- a/stdlib/fmtmsg.c +++ b/stdlib/fmtmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -39,17 +39,18 @@ enum all_mask = label_mask | severity_mask | text_mask | action_mask | tag_mask }; -static struct +static const struct { - const char *name; size_t len; + /* Adjust the size if new elements are added. */ + const char name[9]; } keywords[] = { - { "label", 5 }, - { "severity", 8 }, - { "text", 4 }, - { "action", 6}, - { "tag", 3 } + { 5, "label" }, + { 8, "severity" }, + { 4, "text" }, + { 6, "action"}, + { 3, "tag" } }; #define NKEYWORDS (sizeof( keywords) / sizeof (keywords[0])) @@ -234,12 +235,9 @@ init (void) while (sevlevel_var[0] != '\0') { - const char *end = strchr (sevlevel_var, ':'); + const char *end = __strchrnul (sevlevel_var, ':'); int level; - if (end == NULL) - end = strchr (sevlevel_var, '\0'); - /* First field: keyword. This is not used here but it must be present. */ while (sevlevel_var < end) diff --git a/stdlib/fpioconst.c b/stdlib/fpioconst.c index 925d21cb28..1d9eba96ad 100644 --- a/stdlib/fpioconst.c +++ b/stdlib/fpioconst.c @@ -1,5 +1,5 @@ /* Table of MP integer constants 10^(2^i), used for floating point <-> decimal. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999 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 @@ -29,380 +29,429 @@ /* Table with constants of 10^(2^i), i=0..12 for 32-bit limbs. */ -static const mp_limb_t _ten_p0[] = - { 0x00000000, 0x00000000, 0x0000000a }; -static const mp_limb_t _ten_p1[] = - { 0x00000000, 0x00000000, 0x00000064 }; -static const mp_limb_t _ten_p2[] = - { 0x00000000, 0x00000000, 0x00002710 }; -static const mp_limb_t _ten_p3[] = - { 0x00000000, 0x00000000, 0x05f5e100 }; -static const mp_limb_t _ten_p4[] = - { 0x00000000, 0x00000000, 0x6fc10000, 0x002386f2 }; -static const mp_limb_t _ten_p5[] = - { 0x00000000, 0x00000000, 0x00000000, 0x85acef81, 0x2d6d415b, 0x000004ee }; -static const mp_limb_t _ten_p6[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xbf6a1f01, 0x6e38ed64, - 0xdaa797ed, 0xe93ff9f4, 0x00184f03 }; -static const mp_limb_t _ten_p7[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x2e953e01, 0x03df9909, 0x0f1538fd, 0x2374e42f, 0xd3cff5ec, 0xc404dc08, - 0xbccdb0da, 0xa6337f19, 0xe91f2603, 0x0000024e }; -static const mp_limb_t _ten_p8[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x982e7c01, 0xbed3875b, - 0xd8d99f72, 0x12152f87, 0x6bde50c6, 0xcf4a6e70, 0xd595d80f, 0x26b2716e, - 0xadc666b0, 0x1d153624, 0x3c42d35a, 0x63ff540e, 0xcc5573c0, 0x65f9ef17, - 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x000553f7 }; +const mp_limb_t __tens[] = +{ +#define TENS_P0_IDX 0 +#define TENS_P0_SIZE 3 + [TENS_P0_IDX] = 0x00000000, 0x00000000, 0x0000000a, + +#define TENS_P1_IDX (TENS_P0_IDX + TENS_P0_SIZE) +#define TENS_P1_SIZE 3 + [TENS_P1_IDX] = 0x00000000, 0x00000000, 0x00000064, + +#define TENS_P2_IDX (TENS_P1_IDX + TENS_P1_SIZE) +#define TENS_P2_SIZE 3 + [TENS_P2_IDX] = 0x00000000, 0x00000000, 0x00002710, + +#define TENS_P3_IDX (TENS_P2_IDX + TENS_P2_SIZE) +#define TENS_P3_SIZE 3 + [TENS_P3_IDX] = 0x00000000, 0x00000000, 0x05f5e100, + +#define TENS_P4_IDX (TENS_P3_IDX + TENS_P3_SIZE) +#define TENS_P4_SIZE 4 + [TENS_P4_IDX] = 0x00000000, 0x00000000, 0x6fc10000, 0x002386f2, + +#define TENS_P5_IDX (TENS_P4_IDX + TENS_P4_SIZE) +#define TENS_P5_SIZE 6 + [TENS_P5_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x85acef81, 0x2d6d415b, + 0x000004ee, + +#define TENS_P6_IDX (TENS_P5_IDX + TENS_P5_SIZE) +#define TENS_P6_SIZE 9 + [TENS_P6_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xbf6a1f01, + 0x6e38ed64, 0xdaa797ed, 0xe93ff9f4, 0x00184f03, + +#define TENS_P7_IDX (TENS_P6_IDX + TENS_P6_SIZE) +#define TENS_P7_SIZE 16 + [TENS_P7_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x2e953e01, 0x03df9909, 0x0f1538fd, 0x2374e42f, 0xd3cff5ec, + 0xc404dc08, 0xbccdb0da, 0xa6337f19, 0xe91f2603, 0x0000024e, + +#define TENS_P8_IDX (TENS_P7_IDX + TENS_P7_SIZE) +#define TENS_P8_SIZE 29 + [TENS_P8_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x982e7c01, + 0xbed3875b, 0xd8d99f72, 0x12152f87, 0x6bde50c6, 0xcf4a6e70, 0xd595d80f, + 0x26b2716e, 0xadc666b0, 0x1d153624, 0x3c42d35a, 0x63ff540e, 0xcc5573c0, + 0x65f9ef17, 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x000553f7, + #ifndef __NO_LONG_DOUBLE_MATH -static const mp_limb_t _ten_p9[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xfc6cf801, 0x77f27267, 0x8f9546dc, 0x5d96976f, 0xb83a8a97, 0xc31e1ad9, - 0x46c40513, 0x94e65747, 0xc88976c1, 0x4475b579, 0x28f8733b, 0xaa1da1bf, - 0x703ed321, 0x1e25cfea, 0xb21a2f22, 0xbc51fb2e, 0x96e14f5d, 0xbfa3edac, - 0x329c57ae, 0xe7fc7153, 0xc3fc0695, 0x85a91924, 0xf95f635e, 0xb2908ee0, - 0x93abade4, 0x1366732a, 0x9449775c, 0x69be5b0e, 0x7343afac, 0xb099bc81, - 0x45a71d46, 0xa2699748, 0x8cb07303, 0x8a0b1f13, 0x8cab8a97, 0xc1d238d9, - 0x633415d4, 0x0000001c }; -static const mp_limb_t _ten_p10[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2919f001, 0xf55b2b72, - 0x6e7c215b, 0x1ec29f86, 0x991c4e87, 0x15c51a88, 0x140ac535, 0x4c7d1e1a, - 0xcc2cd819, 0x0ed1440e, 0x896634ee, 0x7de16cfb, 0x1e43f61f, 0x9fce837d, - 0x231d2b9c, 0x233e55c7, 0x65dc60d7, 0xf451218b, 0x1c5cd134, 0xc9635986, - 0x922bbb9f, 0xa7e89431, 0x9f9f2a07, 0x62be695a, 0x8e1042c4, 0x045b7a74, - 0x1abe1de3, 0x8ad822a5, 0xba34c411, 0xd814b505, 0xbf3fdeb3, 0x8fc51a16, - 0xb1b896bc, 0xf56deeec, 0x31fb6bfd, 0xb6f4654b, 0x101a3616, 0x6b7595fb, - 0xdc1a47fe, 0x80d98089, 0x80bda5a5, 0x9a202882, 0x31eb0f66, 0xfc8f1f90, - 0x976a3310, 0xe26a7b7e, 0xdf68368a, 0x3ce3a0b8, 0x8e4262ce, 0x75a351a2, - 0x6cb0b6c9, 0x44597583, 0x31b5653f, 0xc356e38a, 0x35faaba6, 0x0190fba0, - 0x9fc4ed52, 0x88bc491b, 0x1640114a, 0x005b8041, 0xf4f3235e, 0x1e8d4649, - 0x36a8de06, 0x73c55349, 0xa7e6bd2a, 0xc1a6970c, 0x47187094, 0xd2db49ef, - 0x926c3f5b, 0xae6209d4, 0x2d433949, 0x34f4a3c6, 0xd4305d94, 0xd9d61a05, - 0x00000325 }; -static const mp_limb_t _ten_p11[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x1333e001, 0xe3096865, 0xb27d4d3f, 0x49e28dcf, 0xec2e4721, 0xee87e354, - 0xb6067584, 0x368b8abb, 0xa5e5a191, 0x2ed56d55, 0xfd827773, 0xea50d142, - 0x51b78db2, 0x98342c9e, 0xc850dabc, 0x866ed6f1, 0x19342c12, 0x92794987, - 0xd2f869c2, 0x66912e4a, 0x71c7fd8f, 0x57a7842d, 0x235552eb, 0xfb7fedcc, - 0xf3861ce0, 0x38209ce1, 0x9713b449, 0x34c10134, 0x8c6c54de, 0xa7a8289c, - 0x2dbb6643, 0xe3cb64f3, 0x8074ff01, 0xe3892ee9, 0x10c17f94, 0xa8f16f92, - 0xa8281ed6, 0x967abbb3, 0x5a151440, 0x9952fbed, 0x13b41e44, 0xafe609c3, - 0xa2bca416, 0xf111821f, 0xfb1264b4, 0x91bac974, 0xd6c7d6ab, 0x8e48ff35, - 0x4419bd43, 0xc4a65665, 0x685e5510, 0x33554c36, 0xab498697, 0x0dbd21fe, - 0x3cfe491d, 0x982da466, 0xcbea4ca7, 0x9e110c7b, 0x79c56b8a, 0x5fc5a047, - 0x84d80e2e, 0x1aa9f444, 0x730f203c, 0x6a57b1ab, 0xd752f7a6, 0x87a7dc62, - 0x944545ff, 0x40660460, 0x77c1a42f, 0xc9ac375d, 0xe866d7ef, 0x744695f0, - 0x81428c85, 0xa1fc6b96, 0xd7917c7b, 0x7bf03c19, 0x5b33eb41, 0x5715f791, - 0x8f6cae5f, 0xdb0708fd, 0xb125ac8e, 0x785ce6b7, 0x56c6815b, 0x6f46eadb, - 0x4eeebeee, 0x195355d8, 0xa244de3c, 0x9d7389c0, 0x53761abd, 0xcf99d019, - 0xde9ec24b, 0x0d76ce39, 0x70beb181, 0x2e55ecee, 0xd5f86079, 0xf56d9d4b, - 0xfb8886fb, 0x13ef5a83, 0x408f43c5, 0x3f3389a4, 0xfad37943, 0x58ccf45c, - 0xf82df846, 0x415c7f3e, 0x2915e818, 0x8b3d5cf4, 0x6a445f27, 0xf8dbb57a, - 0xca8f0070, 0x8ad803ec, 0xb2e87c34, 0x038f9245, 0xbedd8a6c, 0xc7c9dee0, - 0x0eac7d56, 0x2ad3fa14, 0xe0de0840, 0xf775677c, 0xf1bd0ad5, 0x92be221e, - 0x87fa1fb9, 0xce9d04a4, 0xd2c36fa9, 0x3f6f7024, 0xb028af62, 0x907855ee, - 0xd83e49d6, 0x4efac5dc, 0xe7151aab, 0x77cd8c6b, 0x0a753b7d, 0x0af908b4, - 0x8c983623, 0xe50f3027, 0x94222771, 0x1d08e2d6, 0xf7e928e6, 0xf2ee5ca6, - 0x1b61b93c, 0x11eb962b, 0x9648b21c, 0xce2bcba1, 0x34f77154, 0x7bbebe30, - 0xe526a319, 0x8ce329ac, 0xde4a74d2, 0xb5dc53d5, 0x0009e8b3 }; -static const mp_limb_t _ten_p12[] = - { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2a67c001, 0xd4724e8d, - 0x8efe7ae7, 0xf89a1e90, 0xef084117, 0x54e05154, 0x13b1bb51, 0x506be829, - 0xfb29b172, 0xe599574e, 0xf0da6146, 0x806c0ed3, 0xb86ae5be, 0x45155e93, - 0xc0591cc2, 0x7e1e7c34, 0x7c4823da, 0x1d1f4cce, 0x9b8ba1e8, 0xd6bfdf75, - 0xe341be10, 0xc2dfae78, 0x016b67b2, 0x0f237f1a, 0x3dbeabcd, 0xaf6a2574, - 0xcab3e6d7, 0x142e0e80, 0x61959127, 0x2c234811, 0x87009701, 0xcb4bf982, - 0xf8169c84, 0x88052f8c, 0x68dde6d4, 0xbc131761, 0xff0b0905, 0x54ab9c41, - 0x7613b224, 0x1a1c304e, 0x3bfe167b, 0x441c2d47, 0x4f6cea9c, 0x78f06181, - 0xeb659fb8, 0x30c7ae41, 0x947e0d0e, 0xa1ebcad7, 0xd97d9556, 0x2130504d, - 0x1a8309cb, 0xf2acd507, 0x3f8ec72a, 0xfd82373a, 0x95a842bc, 0x280f4d32, - 0xf3618ac0, 0x811a4f04, 0x6dc3a5b4, 0xd3967a1b, 0x15b8c898, 0xdcfe388f, - 0x454eb2a0, 0x8738b909, 0x10c4e996, 0x2bd9cc11, 0x3297cd0c, 0x655fec30, - 0xae0725b1, 0xf4090ee8, 0x037d19ee, 0x398c6fed, 0x3b9af26b, 0xc994a450, - 0xb5341743, 0x75a697b2, 0xac50b9c1, 0x3ccb5b92, 0xffe06205, 0xa8329761, - 0xdfea5242, 0xeb83cadb, 0xe79dadf7, 0x3c20ee69, 0x1e0a6817, 0x7021b97a, - 0x743074fa, 0x176ca776, 0x77fb8af6, 0xeca19beb, 0x92baf1de, 0xaf63b712, - 0xde35c88b, 0xa4eb8f8c, 0xe137d5e9, 0x40b464a0, 0x87d1cde8, 0x42923bbd, - 0xcd8f62ff, 0x2e2690f3, 0x095edc16, 0x59c89f1b, 0x1fa8fd5d, 0x5138753d, - 0x390a2b29, 0x80152f18, 0x2dd8d925, 0xf984d83e, 0x7a872e74, 0xc19e1faf, - 0xed4d542d, 0xecf9b5d0, 0x9462ea75, 0xc53c0adf, 0x0caea134, 0x37a2d439, - 0xc8fa2e8a, 0x2181327e, 0x6e7bb827, 0x2d240820, 0x50be10e0, 0x5893d4b8, - 0xab312bb9, 0x1f2b2322, 0x440b3f25, 0xbf627ede, 0x72dac789, 0xb608b895, - 0x78787e2a, 0x86deb3f0, 0x6fee7aab, 0xbb9373f4, 0x27ecf57b, 0xf7d8b57e, - 0xfca26a9f, 0x3d04e8d2, 0xc9df13cb, 0x3172826a, 0xcd9e8d7c, 0xa8fcd8e0, - 0xb2c39497, 0x307641d9, 0x1cc939c1, 0x2608c4cf, 0xb6d1c7bf, 0x3d326a7e, - 0xeeaf19e6, 0x8e13e25f, 0xee63302b, 0x2dfe6d97, 0x25971d58, 0xe41d3cc4, - 0x0a80627c, 0xab8db59a, 0x9eea37c8, 0xe90afb77, 0x90ca19cf, 0x9ee3352c, - 0x3613c850, 0xfe78d682, 0x788f6e50, 0x5b060904, 0xb71bd1a4, 0x3fecb534, - 0xb32c450c, 0x20c33857, 0xa6e9cfda, 0x0239f4ce, 0x48497187, 0xa19adb95, - 0xb492ed8a, 0x95aca6a8, 0x4dcd6cd9, 0xcf1b2350, 0xfbe8b12a, 0x1a67778c, - 0x38eb3acc, 0xc32da383, 0xfb126ab1, 0xa03f40a8, 0xed5bf546, 0xe9ce4724, - 0x4c4a74fd, 0x73a130d8, 0xd9960e2d, 0xa2ebd6c1, 0x94ab6feb, 0x6f233b7c, - 0x49126080, 0x8e7b9a73, 0x4b8c9091, 0xd298f999, 0x35e836b5, 0xa96ddeff, - 0x96119b31, 0x6b0dd9bc, 0xc6cc3f8d, 0x282566fb, 0x72b882e7, 0xd6769f3b, - 0xa674343d, 0x00fc509b, 0xdcbf7789, 0xd6266a3f, 0xae9641fd, 0x4e89541b, - 0x11953407, 0x53400d03, 0x8e0dd75a, 0xe5b53345, 0x108f19ad, 0x108b89bc, - 0x41a4c954, 0xe03b2b63, 0x437b3d7f, 0x97aced8e, 0xcbd66670, 0x2c5508c2, - 0x650ebc69, 0x5c4f2ef0, 0x904ff6bf, 0x9985a2df, 0x9faddd9e, 0x5ed8d239, - 0x25585832, 0xe3e51cb9, 0x0ff4f1d4, 0x56c02d9a, 0x8c4ef804, 0xc1a08a13, - 0x13fd01c8, 0xe6d27671, 0xa7c234f4, 0x9d0176cc, 0xd0d73df2, 0x4d8bfa89, - 0x544f10cd, 0x2b17e0b2, 0xb70a5c7d, 0xfd86fe49, 0xdf373f41, 0x214495bb, - 0x84e857fd, 0x00d313d5, 0x0496fcbe, 0xa4ba4744, 0xe8cac982, 0xaec29e6e, - 0x87ec7038, 0x7000a519, 0xaeee333b, 0xff66e42c, 0x8afd6b25, 0x03b4f63b, - 0xbd7991dc, 0x5ab8d9c7, 0x2ed4684e, 0x48741a6c, 0xaf06940d, 0x2fdc6349, - 0xb03d7ecd, 0xe974996f, 0xac7867f9, 0x52ec8721, 0xbcdd9d4a, 0x8edd2d00, - 0x3557de06, 0x41c759f8, 0x3956d4b9, 0xa75409f2, 0x123cd8a1, 0xb6100fab, - 0x3e7b21e2, 0x2e8d623b, 0x92959da2, 0xbca35f77, 0x200c03a5, 0x35fcb457, - 0x1bb6c6e4, 0xf74eb928, 0x3d5d0b54, 0x87cc1d21, 0x4964046f, 0x18ae4240, - 0xd868b275, 0x8bd2b496, 0x1c5563f4, 0xc234d8f5, 0xf868e970, 0xf9151fff, - 0xae7be4a2, 0x271133ee, 0xbb0fd922, 0x25254932, 0xa60a9fc0, 0x104bcd64, - 0x30290145, 0x00000062 }; +# define TENS_P9_IDX (TENS_P8_IDX + TENS_P8_SIZE) +# define TENS_P9_SIZE 56 + [TENS_P9_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0xfc6cf801, 0x77f27267, 0x8f9546dc, 0x5d96976f, 0xb83a8a97, + 0xc31e1ad9, 0x46c40513, 0x94e65747, 0xc88976c1, 0x4475b579, 0x28f8733b, + 0xaa1da1bf, 0x703ed321, 0x1e25cfea, 0xb21a2f22, 0xbc51fb2e, 0x96e14f5d, + 0xbfa3edac, 0x329c57ae, 0xe7fc7153, 0xc3fc0695, 0x85a91924, 0xf95f635e, + 0xb2908ee0, 0x93abade4, 0x1366732a, 0x9449775c, 0x69be5b0e, 0x7343afac, + 0xb099bc81, 0x45a71d46, 0xa2699748, 0x8cb07303, 0x8a0b1f13, 0x8cab8a97, + 0xc1d238d9, 0x633415d4, 0x0000001c, + +# define TENS_P10_IDX (TENS_P9_IDX + TENS_P9_SIZE) +# define TENS_P10_SIZE 109 + [TENS_P10_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2919f001, + 0xf55b2b72, 0x6e7c215b, 0x1ec29f86, 0x991c4e87, 0x15c51a88, 0x140ac535, + 0x4c7d1e1a, 0xcc2cd819, 0x0ed1440e, 0x896634ee, 0x7de16cfb, 0x1e43f61f, + 0x9fce837d, 0x231d2b9c, 0x233e55c7, 0x65dc60d7, 0xf451218b, 0x1c5cd134, + 0xc9635986, 0x922bbb9f, 0xa7e89431, 0x9f9f2a07, 0x62be695a, 0x8e1042c4, + 0x045b7a74, 0x1abe1de3, 0x8ad822a5, 0xba34c411, 0xd814b505, 0xbf3fdeb3, + 0x8fc51a16, 0xb1b896bc, 0xf56deeec, 0x31fb6bfd, 0xb6f4654b, 0x101a3616, + 0x6b7595fb, 0xdc1a47fe, 0x80d98089, 0x80bda5a5, 0x9a202882, 0x31eb0f66, + 0xfc8f1f90, 0x976a3310, 0xe26a7b7e, 0xdf68368a, 0x3ce3a0b8, 0x8e4262ce, + 0x75a351a2, 0x6cb0b6c9, 0x44597583, 0x31b5653f, 0xc356e38a, 0x35faaba6, + 0x0190fba0, 0x9fc4ed52, 0x88bc491b, 0x1640114a, 0x005b8041, 0xf4f3235e, + 0x1e8d4649, 0x36a8de06, 0x73c55349, 0xa7e6bd2a, 0xc1a6970c, 0x47187094, + 0xd2db49ef, 0x926c3f5b, 0xae6209d4, 0x2d433949, 0x34f4a3c6, 0xd4305d94, + 0xd9d61a05, 0x00000325, + +# define TENS_P11_IDX (TENS_P10_IDX + TENS_P10_SIZE) +# define TENS_P11_SIZE 215 + [TENS_P11_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x1333e001, 0xe3096865, 0xb27d4d3f, 0x49e28dcf, 0xec2e4721, + 0xee87e354, 0xb6067584, 0x368b8abb, 0xa5e5a191, 0x2ed56d55, 0xfd827773, + 0xea50d142, 0x51b78db2, 0x98342c9e, 0xc850dabc, 0x866ed6f1, 0x19342c12, + 0x92794987, 0xd2f869c2, 0x66912e4a, 0x71c7fd8f, 0x57a7842d, 0x235552eb, + 0xfb7fedcc, 0xf3861ce0, 0x38209ce1, 0x9713b449, 0x34c10134, 0x8c6c54de, + 0xa7a8289c, 0x2dbb6643, 0xe3cb64f3, 0x8074ff01, 0xe3892ee9, 0x10c17f94, + 0xa8f16f92, 0xa8281ed6, 0x967abbb3, 0x5a151440, 0x9952fbed, 0x13b41e44, + 0xafe609c3, 0xa2bca416, 0xf111821f, 0xfb1264b4, 0x91bac974, 0xd6c7d6ab, + 0x8e48ff35, 0x4419bd43, 0xc4a65665, 0x685e5510, 0x33554c36, 0xab498697, + 0x0dbd21fe, 0x3cfe491d, 0x982da466, 0xcbea4ca7, 0x9e110c7b, 0x79c56b8a, + 0x5fc5a047, 0x84d80e2e, 0x1aa9f444, 0x730f203c, 0x6a57b1ab, 0xd752f7a6, + 0x87a7dc62, 0x944545ff, 0x40660460, 0x77c1a42f, 0xc9ac375d, 0xe866d7ef, + 0x744695f0, 0x81428c85, 0xa1fc6b96, 0xd7917c7b, 0x7bf03c19, 0x5b33eb41, + 0x5715f791, 0x8f6cae5f, 0xdb0708fd, 0xb125ac8e, 0x785ce6b7, 0x56c6815b, + 0x6f46eadb, 0x4eeebeee, 0x195355d8, 0xa244de3c, 0x9d7389c0, 0x53761abd, + 0xcf99d019, 0xde9ec24b, 0x0d76ce39, 0x70beb181, 0x2e55ecee, 0xd5f86079, + 0xf56d9d4b, 0xfb8886fb, 0x13ef5a83, 0x408f43c5, 0x3f3389a4, 0xfad37943, + 0x58ccf45c, 0xf82df846, 0x415c7f3e, 0x2915e818, 0x8b3d5cf4, 0x6a445f27, + 0xf8dbb57a, 0xca8f0070, 0x8ad803ec, 0xb2e87c34, 0x038f9245, 0xbedd8a6c, + 0xc7c9dee0, 0x0eac7d56, 0x2ad3fa14, 0xe0de0840, 0xf775677c, 0xf1bd0ad5, + 0x92be221e, 0x87fa1fb9, 0xce9d04a4, 0xd2c36fa9, 0x3f6f7024, 0xb028af62, + 0x907855ee, 0xd83e49d6, 0x4efac5dc, 0xe7151aab, 0x77cd8c6b, 0x0a753b7d, + 0x0af908b4, 0x8c983623, 0xe50f3027, 0x94222771, 0x1d08e2d6, 0xf7e928e6, + 0xf2ee5ca6, 0x1b61b93c, 0x11eb962b, 0x9648b21c, 0xce2bcba1, 0x34f77154, + 0x7bbebe30, 0xe526a319, 0x8ce329ac, 0xde4a74d2, 0xb5dc53d5, 0x0009e8b3, + +# define TENS_P12_IDX (TENS_P11_IDX + TENS_P11_SIZE) +# define TENS_P12_SIZE 428 + [TENS_P12_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2a67c001, + 0xd4724e8d, 0x8efe7ae7, 0xf89a1e90, 0xef084117, 0x54e05154, 0x13b1bb51, + 0x506be829, 0xfb29b172, 0xe599574e, 0xf0da6146, 0x806c0ed3, 0xb86ae5be, + 0x45155e93, 0xc0591cc2, 0x7e1e7c34, 0x7c4823da, 0x1d1f4cce, 0x9b8ba1e8, + 0xd6bfdf75, 0xe341be10, 0xc2dfae78, 0x016b67b2, 0x0f237f1a, 0x3dbeabcd, + 0xaf6a2574, 0xcab3e6d7, 0x142e0e80, 0x61959127, 0x2c234811, 0x87009701, + 0xcb4bf982, 0xf8169c84, 0x88052f8c, 0x68dde6d4, 0xbc131761, 0xff0b0905, + 0x54ab9c41, 0x7613b224, 0x1a1c304e, 0x3bfe167b, 0x441c2d47, 0x4f6cea9c, + 0x78f06181, 0xeb659fb8, 0x30c7ae41, 0x947e0d0e, 0xa1ebcad7, 0xd97d9556, + 0x2130504d, 0x1a8309cb, 0xf2acd507, 0x3f8ec72a, 0xfd82373a, 0x95a842bc, + 0x280f4d32, 0xf3618ac0, 0x811a4f04, 0x6dc3a5b4, 0xd3967a1b, 0x15b8c898, + 0xdcfe388f, 0x454eb2a0, 0x8738b909, 0x10c4e996, 0x2bd9cc11, 0x3297cd0c, + 0x655fec30, 0xae0725b1, 0xf4090ee8, 0x037d19ee, 0x398c6fed, 0x3b9af26b, + 0xc994a450, 0xb5341743, 0x75a697b2, 0xac50b9c1, 0x3ccb5b92, 0xffe06205, + 0xa8329761, 0xdfea5242, 0xeb83cadb, 0xe79dadf7, 0x3c20ee69, 0x1e0a6817, + 0x7021b97a, 0x743074fa, 0x176ca776, 0x77fb8af6, 0xeca19beb, 0x92baf1de, + 0xaf63b712, 0xde35c88b, 0xa4eb8f8c, 0xe137d5e9, 0x40b464a0, 0x87d1cde8, + 0x42923bbd, 0xcd8f62ff, 0x2e2690f3, 0x095edc16, 0x59c89f1b, 0x1fa8fd5d, + 0x5138753d, 0x390a2b29, 0x80152f18, 0x2dd8d925, 0xf984d83e, 0x7a872e74, + 0xc19e1faf, 0xed4d542d, 0xecf9b5d0, 0x9462ea75, 0xc53c0adf, 0x0caea134, + 0x37a2d439, 0xc8fa2e8a, 0x2181327e, 0x6e7bb827, 0x2d240820, 0x50be10e0, + 0x5893d4b8, 0xab312bb9, 0x1f2b2322, 0x440b3f25, 0xbf627ede, 0x72dac789, + 0xb608b895, 0x78787e2a, 0x86deb3f0, 0x6fee7aab, 0xbb9373f4, 0x27ecf57b, + 0xf7d8b57e, 0xfca26a9f, 0x3d04e8d2, 0xc9df13cb, 0x3172826a, 0xcd9e8d7c, + 0xa8fcd8e0, 0xb2c39497, 0x307641d9, 0x1cc939c1, 0x2608c4cf, 0xb6d1c7bf, + 0x3d326a7e, 0xeeaf19e6, 0x8e13e25f, 0xee63302b, 0x2dfe6d97, 0x25971d58, + 0xe41d3cc4, 0x0a80627c, 0xab8db59a, 0x9eea37c8, 0xe90afb77, 0x90ca19cf, + 0x9ee3352c, 0x3613c850, 0xfe78d682, 0x788f6e50, 0x5b060904, 0xb71bd1a4, + 0x3fecb534, 0xb32c450c, 0x20c33857, 0xa6e9cfda, 0x0239f4ce, 0x48497187, + 0xa19adb95, 0xb492ed8a, 0x95aca6a8, 0x4dcd6cd9, 0xcf1b2350, 0xfbe8b12a, + 0x1a67778c, 0x38eb3acc, 0xc32da383, 0xfb126ab1, 0xa03f40a8, 0xed5bf546, + 0xe9ce4724, 0x4c4a74fd, 0x73a130d8, 0xd9960e2d, 0xa2ebd6c1, 0x94ab6feb, + 0x6f233b7c, 0x49126080, 0x8e7b9a73, 0x4b8c9091, 0xd298f999, 0x35e836b5, + 0xa96ddeff, 0x96119b31, 0x6b0dd9bc, 0xc6cc3f8d, 0x282566fb, 0x72b882e7, + 0xd6769f3b, 0xa674343d, 0x00fc509b, 0xdcbf7789, 0xd6266a3f, 0xae9641fd, + 0x4e89541b, 0x11953407, 0x53400d03, 0x8e0dd75a, 0xe5b53345, 0x108f19ad, + 0x108b89bc, 0x41a4c954, 0xe03b2b63, 0x437b3d7f, 0x97aced8e, 0xcbd66670, + 0x2c5508c2, 0x650ebc69, 0x5c4f2ef0, 0x904ff6bf, 0x9985a2df, 0x9faddd9e, + 0x5ed8d239, 0x25585832, 0xe3e51cb9, 0x0ff4f1d4, 0x56c02d9a, 0x8c4ef804, + 0xc1a08a13, 0x13fd01c8, 0xe6d27671, 0xa7c234f4, 0x9d0176cc, 0xd0d73df2, + 0x4d8bfa89, 0x544f10cd, 0x2b17e0b2, 0xb70a5c7d, 0xfd86fe49, 0xdf373f41, + 0x214495bb, 0x84e857fd, 0x00d313d5, 0x0496fcbe, 0xa4ba4744, 0xe8cac982, + 0xaec29e6e, 0x87ec7038, 0x7000a519, 0xaeee333b, 0xff66e42c, 0x8afd6b25, + 0x03b4f63b, 0xbd7991dc, 0x5ab8d9c7, 0x2ed4684e, 0x48741a6c, 0xaf06940d, + 0x2fdc6349, 0xb03d7ecd, 0xe974996f, 0xac7867f9, 0x52ec8721, 0xbcdd9d4a, + 0x8edd2d00, 0x3557de06, 0x41c759f8, 0x3956d4b9, 0xa75409f2, 0x123cd8a1, + 0xb6100fab, 0x3e7b21e2, 0x2e8d623b, 0x92959da2, 0xbca35f77, 0x200c03a5, + 0x35fcb457, 0x1bb6c6e4, 0xf74eb928, 0x3d5d0b54, 0x87cc1d21, 0x4964046f, + 0x18ae4240, 0xd868b275, 0x8bd2b496, 0x1c5563f4, 0xc234d8f5, 0xf868e970, + 0xf9151fff, 0xae7be4a2, 0x271133ee, 0xbb0fd922, 0x25254932, 0xa60a9fc0, + 0x104bcd64, 0x30290145, 0x00000062 #endif /* !__NO_LONG_DOUBLE_MATH */ +}; #elif BITS_PER_MP_LIMB == 64 /* Table with constants of 10^(2^i), i=0..12 for 64-bit limbs. */ -static const mp_limb_t _ten_p0[] = - { 0x0000000000000000, 0x000000000000000a }; -static const mp_limb_t _ten_p1[] = - { 0x0000000000000000, 0x0000000000000064 }; -static const mp_limb_t _ten_p2[] = - { 0x0000000000000000, 0x0000000000002710 }; -static const mp_limb_t _ten_p3[] = - { 0x0000000000000000, 0x0000000005f5e100 }; -static const mp_limb_t _ten_p4[] = - { 0x0000000000000000, 0x002386f26fc10000 }; -static const mp_limb_t _ten_p5[] = - { 0x0000000000000000, 0x85acef8100000000, 0x000004ee2d6d415b }; -static const mp_limb_t _ten_p6[] = - { 0x0000000000000000, 0x0000000000000000, 0x6e38ed64bf6a1f01, - 0xe93ff9f4daa797ed, 0x0000000000184f03 }; -static const mp_limb_t _ten_p7[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x03df99092e953e01, 0x2374e42f0f1538fd, 0xc404dc08d3cff5ec, - 0xa6337f19bccdb0da, 0x0000024ee91f2603 }; -static const mp_limb_t _ten_p8[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0xbed3875b982e7c01, - 0x12152f87d8d99f72, 0xcf4a6e706bde50c6, 0x26b2716ed595d80f, - 0x1d153624adc666b0, 0x63ff540e3c42d35a, 0x65f9ef17cc5573c0, - 0x80dcc7f755bc28f2, 0x5fdcefcef46eeddc, 0x00000000000553f7 }; +static const mp_limb_t __tens[] = +{ +#define TENS_P0_IDX 0 +#define TENS_P0_SIZE 2 + [TENS_P0_IDX] = 0x0000000000000000, 0x000000000000000a, + +#define TENS_P1_IDX (TENS_P0_IDX + TENS_P0_SIZE) +#define TENS_P1_SIZE 2 + [TENS_P1_IDX] = 0x0000000000000000, 0x0000000000000064, + +#define TENS_P2_IDX (TENS_P1_IDX + TENS_P1_SIZE) +#define TENS_P2_SIZE 2 + [TENS_P2_IDX] = 0x0000000000000000, 0x0000000000002710, + +#define TENS_P3_IDX (TENS_P2_IDX + TENS_P2_SIZE) +#define TENS_P3_SIZE 2 + [TENS_P3_IDX] = 0x0000000000000000, 0x0000000005f5e100, + +#define TENS_P4_IDX (TENS_P3_IDX + TENS_P3_SIZE) +#define TENS_P4_SIZE 2 + [TENS_P4_IDX] = 0x0000000000000000, 0x002386f26fc10000, + +#define TENS_P5_IDX (TENS_P4_IDX + TENS_P4_SIZE) +#define TENS_P5_SIZE 3 + [TENS_P5_IDX] = 0x0000000000000000, 0x85acef8100000000, 0x000004ee2d6d415b, + +#define TENS_P6_IDX (TENS_P5_IDX + TENS_P5_SIZE) +#define TENS_P6_SIZE 5 + [TENS_P6_IDX] = 0x0000000000000000, 0x0000000000000000, 0x6e38ed64bf6a1f01, + 0xe93ff9f4daa797ed, 0x0000000000184f03, + +#define TENS_P7_IDX (TENS_P6_IDX + TENS_P6_SIZE) +#define TENS_P7_SIZE 8 + [TENS_P7_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x03df99092e953e01, 0x2374e42f0f1538fd, 0xc404dc08d3cff5ec, + 0xa6337f19bccdb0da, 0x0000024ee91f2603, + +#define TENS_P8_IDX (TENS_P7_IDX + TENS_P7_SIZE) +#define TENS_P8_SIZE 15 + [TENS_P8_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0xbed3875b982e7c01, + 0x12152f87d8d99f72, 0xcf4a6e706bde50c6, 0x26b2716ed595d80f, + 0x1d153624adc666b0, 0x63ff540e3c42d35a, 0x65f9ef17cc5573c0, + 0x80dcc7f755bc28f2, 0x5fdcefcef46eeddc, 0x00000000000553f7, #ifndef __NO_LONG_DOUBLE_MATH -static const mp_limb_t _ten_p9[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x77f27267fc6cf801, 0x5d96976f8f9546dc, 0xc31e1ad9b83a8a97, - 0x94e6574746c40513, 0x4475b579c88976c1, 0xaa1da1bf28f8733b, - 0x1e25cfea703ed321, 0xbc51fb2eb21a2f22, 0xbfa3edac96e14f5d, - 0xe7fc7153329c57ae, 0x85a91924c3fc0695, 0xb2908ee0f95f635e, - 0x1366732a93abade4, 0x69be5b0e9449775c, 0xb099bc817343afac, - 0xa269974845a71d46, 0x8a0b1f138cb07303, 0xc1d238d98cab8a97, - 0x0000001c633415d4 }; -static const mp_limb_t _ten_p10[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0xf55b2b722919f001, - 0x1ec29f866e7c215b, 0x15c51a88991c4e87, 0x4c7d1e1a140ac535, - 0x0ed1440ecc2cd819, 0x7de16cfb896634ee, 0x9fce837d1e43f61f, - 0x233e55c7231d2b9c, 0xf451218b65dc60d7, 0xc96359861c5cd134, - 0xa7e89431922bbb9f, 0x62be695a9f9f2a07, 0x045b7a748e1042c4, - 0x8ad822a51abe1de3, 0xd814b505ba34c411, 0x8fc51a16bf3fdeb3, - 0xf56deeecb1b896bc, 0xb6f4654b31fb6bfd, 0x6b7595fb101a3616, - 0x80d98089dc1a47fe, 0x9a20288280bda5a5, 0xfc8f1f9031eb0f66, - 0xe26a7b7e976a3310, 0x3ce3a0b8df68368a, 0x75a351a28e4262ce, - 0x445975836cb0b6c9, 0xc356e38a31b5653f, 0x0190fba035faaba6, - 0x88bc491b9fc4ed52, 0x005b80411640114a, 0x1e8d4649f4f3235e, - 0x73c5534936a8de06, 0xc1a6970ca7e6bd2a, 0xd2db49ef47187094, - 0xae6209d4926c3f5b, 0x34f4a3c62d433949, 0xd9d61a05d4305d94, - 0x0000000000000325 }; -static const mp_limb_t _ten_p11[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0xe30968651333e001, 0x49e28dcfb27d4d3f, 0xee87e354ec2e4721, - 0x368b8abbb6067584, 0x2ed56d55a5e5a191, 0xea50d142fd827773, - 0x98342c9e51b78db2, 0x866ed6f1c850dabc, 0x9279498719342c12, - 0x66912e4ad2f869c2, 0x57a7842d71c7fd8f, 0xfb7fedcc235552eb, - 0x38209ce1f3861ce0, 0x34c101349713b449, 0xa7a8289c8c6c54de, - 0xe3cb64f32dbb6643, 0xe3892ee98074ff01, 0xa8f16f9210c17f94, - 0x967abbb3a8281ed6, 0x9952fbed5a151440, 0xafe609c313b41e44, - 0xf111821fa2bca416, 0x91bac974fb1264b4, 0x8e48ff35d6c7d6ab, - 0xc4a656654419bd43, 0x33554c36685e5510, 0x0dbd21feab498697, - 0x982da4663cfe491d, 0x9e110c7bcbea4ca7, 0x5fc5a04779c56b8a, - 0x1aa9f44484d80e2e, 0x6a57b1ab730f203c, 0x87a7dc62d752f7a6, - 0x40660460944545ff, 0xc9ac375d77c1a42f, 0x744695f0e866d7ef, - 0xa1fc6b9681428c85, 0x7bf03c19d7917c7b, 0x5715f7915b33eb41, - 0xdb0708fd8f6cae5f, 0x785ce6b7b125ac8e, 0x6f46eadb56c6815b, - 0x195355d84eeebeee, 0x9d7389c0a244de3c, 0xcf99d01953761abd, - 0x0d76ce39de9ec24b, 0x2e55ecee70beb181, 0xf56d9d4bd5f86079, - 0x13ef5a83fb8886fb, 0x3f3389a4408f43c5, 0x58ccf45cfad37943, - 0x415c7f3ef82df846, 0x8b3d5cf42915e818, 0xf8dbb57a6a445f27, - 0x8ad803ecca8f0070, 0x038f9245b2e87c34, 0xc7c9dee0bedd8a6c, - 0x2ad3fa140eac7d56, 0xf775677ce0de0840, 0x92be221ef1bd0ad5, - 0xce9d04a487fa1fb9, 0x3f6f7024d2c36fa9, 0x907855eeb028af62, - 0x4efac5dcd83e49d6, 0x77cd8c6be7151aab, 0x0af908b40a753b7d, - 0xe50f30278c983623, 0x1d08e2d694222771, 0xf2ee5ca6f7e928e6, - 0x11eb962b1b61b93c, 0xce2bcba19648b21c, 0x7bbebe3034f77154, - 0x8ce329ace526a319, 0xb5dc53d5de4a74d2, 0x000000000009e8b3 }; -static const mp_limb_t _ten_p12[] = - { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0xd4724e8d2a67c001, - 0xf89a1e908efe7ae7, 0x54e05154ef084117, 0x506be82913b1bb51, - 0xe599574efb29b172, 0x806c0ed3f0da6146, 0x45155e93b86ae5be, - 0x7e1e7c34c0591cc2, 0x1d1f4cce7c4823da, 0xd6bfdf759b8ba1e8, - 0xc2dfae78e341be10, 0x0f237f1a016b67b2, 0xaf6a25743dbeabcd, - 0x142e0e80cab3e6d7, 0x2c23481161959127, 0xcb4bf98287009701, - 0x88052f8cf8169c84, 0xbc13176168dde6d4, 0x54ab9c41ff0b0905, - 0x1a1c304e7613b224, 0x441c2d473bfe167b, 0x78f061814f6cea9c, - 0x30c7ae41eb659fb8, 0xa1ebcad7947e0d0e, 0x2130504dd97d9556, - 0xf2acd5071a8309cb, 0xfd82373a3f8ec72a, 0x280f4d3295a842bc, - 0x811a4f04f3618ac0, 0xd3967a1b6dc3a5b4, 0xdcfe388f15b8c898, - 0x8738b909454eb2a0, 0x2bd9cc1110c4e996, 0x655fec303297cd0c, - 0xf4090ee8ae0725b1, 0x398c6fed037d19ee, 0xc994a4503b9af26b, - 0x75a697b2b5341743, 0x3ccb5b92ac50b9c1, 0xa8329761ffe06205, - 0xeb83cadbdfea5242, 0x3c20ee69e79dadf7, 0x7021b97a1e0a6817, - 0x176ca776743074fa, 0xeca19beb77fb8af6, 0xaf63b71292baf1de, - 0xa4eb8f8cde35c88b, 0x40b464a0e137d5e9, 0x42923bbd87d1cde8, - 0x2e2690f3cd8f62ff, 0x59c89f1b095edc16, 0x5138753d1fa8fd5d, - 0x80152f18390a2b29, 0xf984d83e2dd8d925, 0xc19e1faf7a872e74, - 0xecf9b5d0ed4d542d, 0xc53c0adf9462ea75, 0x37a2d4390caea134, - 0x2181327ec8fa2e8a, 0x2d2408206e7bb827, 0x5893d4b850be10e0, - 0x1f2b2322ab312bb9, 0xbf627ede440b3f25, 0xb608b89572dac789, - 0x86deb3f078787e2a, 0xbb9373f46fee7aab, 0xf7d8b57e27ecf57b, - 0x3d04e8d2fca26a9f, 0x3172826ac9df13cb, 0xa8fcd8e0cd9e8d7c, - 0x307641d9b2c39497, 0x2608c4cf1cc939c1, 0x3d326a7eb6d1c7bf, - 0x8e13e25feeaf19e6, 0x2dfe6d97ee63302b, 0xe41d3cc425971d58, - 0xab8db59a0a80627c, 0xe90afb779eea37c8, 0x9ee3352c90ca19cf, - 0xfe78d6823613c850, 0x5b060904788f6e50, 0x3fecb534b71bd1a4, - 0x20c33857b32c450c, 0x0239f4cea6e9cfda, 0xa19adb9548497187, - 0x95aca6a8b492ed8a, 0xcf1b23504dcd6cd9, 0x1a67778cfbe8b12a, - 0xc32da38338eb3acc, 0xa03f40a8fb126ab1, 0xe9ce4724ed5bf546, - 0x73a130d84c4a74fd, 0xa2ebd6c1d9960e2d, 0x6f233b7c94ab6feb, - 0x8e7b9a7349126080, 0xd298f9994b8c9091, 0xa96ddeff35e836b5, - 0x6b0dd9bc96119b31, 0x282566fbc6cc3f8d, 0xd6769f3b72b882e7, - 0x00fc509ba674343d, 0xd6266a3fdcbf7789, 0x4e89541bae9641fd, - 0x53400d0311953407, 0xe5b533458e0dd75a, 0x108b89bc108f19ad, - 0xe03b2b6341a4c954, 0x97aced8e437b3d7f, 0x2c5508c2cbd66670, - 0x5c4f2ef0650ebc69, 0x9985a2df904ff6bf, 0x5ed8d2399faddd9e, - 0xe3e51cb925585832, 0x56c02d9a0ff4f1d4, 0xc1a08a138c4ef804, - 0xe6d2767113fd01c8, 0x9d0176cca7c234f4, 0x4d8bfa89d0d73df2, - 0x2b17e0b2544f10cd, 0xfd86fe49b70a5c7d, 0x214495bbdf373f41, - 0x00d313d584e857fd, 0xa4ba47440496fcbe, 0xaec29e6ee8cac982, - 0x7000a51987ec7038, 0xff66e42caeee333b, 0x03b4f63b8afd6b25, - 0x5ab8d9c7bd7991dc, 0x48741a6c2ed4684e, 0x2fdc6349af06940d, - 0xe974996fb03d7ecd, 0x52ec8721ac7867f9, 0x8edd2d00bcdd9d4a, - 0x41c759f83557de06, 0xa75409f23956d4b9, 0xb6100fab123cd8a1, - 0x2e8d623b3e7b21e2, 0xbca35f7792959da2, 0x35fcb457200c03a5, - 0xf74eb9281bb6c6e4, 0x87cc1d213d5d0b54, 0x18ae42404964046f, - 0x8bd2b496d868b275, 0xc234d8f51c5563f4, 0xf9151ffff868e970, - 0x271133eeae7be4a2, 0x25254932bb0fd922, 0x104bcd64a60a9fc0, - 0x0000006230290145 }; +# define TENS_P9_IDX (TENS_P8_IDX + TENS_P8_SIZE) +# define TENS_P9_SIZE 28 + [TENS_P9_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x77f27267fc6cf801, 0x5d96976f8f9546dc, 0xc31e1ad9b83a8a97, + 0x94e6574746c40513, 0x4475b579c88976c1, 0xaa1da1bf28f8733b, + 0x1e25cfea703ed321, 0xbc51fb2eb21a2f22, 0xbfa3edac96e14f5d, + 0xe7fc7153329c57ae, 0x85a91924c3fc0695, 0xb2908ee0f95f635e, + 0x1366732a93abade4, 0x69be5b0e9449775c, 0xb099bc817343afac, + 0xa269974845a71d46, 0x8a0b1f138cb07303, 0xc1d238d98cab8a97, + 0x0000001c633415d4, + +# define TENS_P10_IDX (TENS_P9_IDX + TENS_P9_SIZE) +# define TENS_P10_SIZE 55 + [TENS_P10_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0xf55b2b722919f001, + 0x1ec29f866e7c215b, 0x15c51a88991c4e87, 0x4c7d1e1a140ac535, + 0x0ed1440ecc2cd819, 0x7de16cfb896634ee, 0x9fce837d1e43f61f, + 0x233e55c7231d2b9c, 0xf451218b65dc60d7, 0xc96359861c5cd134, + 0xa7e89431922bbb9f, 0x62be695a9f9f2a07, 0x045b7a748e1042c4, + 0x8ad822a51abe1de3, 0xd814b505ba34c411, 0x8fc51a16bf3fdeb3, + 0xf56deeecb1b896bc, 0xb6f4654b31fb6bfd, 0x6b7595fb101a3616, + 0x80d98089dc1a47fe, 0x9a20288280bda5a5, 0xfc8f1f9031eb0f66, + 0xe26a7b7e976a3310, 0x3ce3a0b8df68368a, 0x75a351a28e4262ce, + 0x445975836cb0b6c9, 0xc356e38a31b5653f, 0x0190fba035faaba6, + 0x88bc491b9fc4ed52, 0x005b80411640114a, 0x1e8d4649f4f3235e, + 0x73c5534936a8de06, 0xc1a6970ca7e6bd2a, 0xd2db49ef47187094, + 0xae6209d4926c3f5b, 0x34f4a3c62d433949, 0xd9d61a05d4305d94, + 0x0000000000000325, + +# define TENS_P11_IDX (TENS_P10_IDX + TENS_P10_SIZE) +# define TENS_P11_SIZE 108 + [TENS_P11_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0xe30968651333e001, 0x49e28dcfb27d4d3f, 0xee87e354ec2e4721, + 0x368b8abbb6067584, 0x2ed56d55a5e5a191, 0xea50d142fd827773, + 0x98342c9e51b78db2, 0x866ed6f1c850dabc, 0x9279498719342c12, + 0x66912e4ad2f869c2, 0x57a7842d71c7fd8f, 0xfb7fedcc235552eb, + 0x38209ce1f3861ce0, 0x34c101349713b449, 0xa7a8289c8c6c54de, + 0xe3cb64f32dbb6643, 0xe3892ee98074ff01, 0xa8f16f9210c17f94, + 0x967abbb3a8281ed6, 0x9952fbed5a151440, 0xafe609c313b41e44, + 0xf111821fa2bca416, 0x91bac974fb1264b4, 0x8e48ff35d6c7d6ab, + 0xc4a656654419bd43, 0x33554c36685e5510, 0x0dbd21feab498697, + 0x982da4663cfe491d, 0x9e110c7bcbea4ca7, 0x5fc5a04779c56b8a, + 0x1aa9f44484d80e2e, 0x6a57b1ab730f203c, 0x87a7dc62d752f7a6, + 0x40660460944545ff, 0xc9ac375d77c1a42f, 0x744695f0e866d7ef, + 0xa1fc6b9681428c85, 0x7bf03c19d7917c7b, 0x5715f7915b33eb41, + 0xdb0708fd8f6cae5f, 0x785ce6b7b125ac8e, 0x6f46eadb56c6815b, + 0x195355d84eeebeee, 0x9d7389c0a244de3c, 0xcf99d01953761abd, + 0x0d76ce39de9ec24b, 0x2e55ecee70beb181, 0xf56d9d4bd5f86079, + 0x13ef5a83fb8886fb, 0x3f3389a4408f43c5, 0x58ccf45cfad37943, + 0x415c7f3ef82df846, 0x8b3d5cf42915e818, 0xf8dbb57a6a445f27, + 0x8ad803ecca8f0070, 0x038f9245b2e87c34, 0xc7c9dee0bedd8a6c, + 0x2ad3fa140eac7d56, 0xf775677ce0de0840, 0x92be221ef1bd0ad5, + 0xce9d04a487fa1fb9, 0x3f6f7024d2c36fa9, 0x907855eeb028af62, + 0x4efac5dcd83e49d6, 0x77cd8c6be7151aab, 0x0af908b40a753b7d, + 0xe50f30278c983623, 0x1d08e2d694222771, 0xf2ee5ca6f7e928e6, + 0x11eb962b1b61b93c, 0xce2bcba19648b21c, 0x7bbebe3034f77154, + 0x8ce329ace526a319, 0xb5dc53d5de4a74d2, 0x000000000009e8b3, + +# define TENS_P12_IDX (TENS_P11_IDX + TENS_P11_SIZE) +# define TENS_P12_SIZE 214 + [TENS_P12_IDX] = 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0xd4724e8d2a67c001, + 0xf89a1e908efe7ae7, 0x54e05154ef084117, 0x506be82913b1bb51, + 0xe599574efb29b172, 0x806c0ed3f0da6146, 0x45155e93b86ae5be, + 0x7e1e7c34c0591cc2, 0x1d1f4cce7c4823da, 0xd6bfdf759b8ba1e8, + 0xc2dfae78e341be10, 0x0f237f1a016b67b2, 0xaf6a25743dbeabcd, + 0x142e0e80cab3e6d7, 0x2c23481161959127, 0xcb4bf98287009701, + 0x88052f8cf8169c84, 0xbc13176168dde6d4, 0x54ab9c41ff0b0905, + 0x1a1c304e7613b224, 0x441c2d473bfe167b, 0x78f061814f6cea9c, + 0x30c7ae41eb659fb8, 0xa1ebcad7947e0d0e, 0x2130504dd97d9556, + 0xf2acd5071a8309cb, 0xfd82373a3f8ec72a, 0x280f4d3295a842bc, + 0x811a4f04f3618ac0, 0xd3967a1b6dc3a5b4, 0xdcfe388f15b8c898, + 0x8738b909454eb2a0, 0x2bd9cc1110c4e996, 0x655fec303297cd0c, + 0xf4090ee8ae0725b1, 0x398c6fed037d19ee, 0xc994a4503b9af26b, + 0x75a697b2b5341743, 0x3ccb5b92ac50b9c1, 0xa8329761ffe06205, + 0xeb83cadbdfea5242, 0x3c20ee69e79dadf7, 0x7021b97a1e0a6817, + 0x176ca776743074fa, 0xeca19beb77fb8af6, 0xaf63b71292baf1de, + 0xa4eb8f8cde35c88b, 0x40b464a0e137d5e9, 0x42923bbd87d1cde8, + 0x2e2690f3cd8f62ff, 0x59c89f1b095edc16, 0x5138753d1fa8fd5d, + 0x80152f18390a2b29, 0xf984d83e2dd8d925, 0xc19e1faf7a872e74, + 0xecf9b5d0ed4d542d, 0xc53c0adf9462ea75, 0x37a2d4390caea134, + 0x2181327ec8fa2e8a, 0x2d2408206e7bb827, 0x5893d4b850be10e0, + 0x1f2b2322ab312bb9, 0xbf627ede440b3f25, 0xb608b89572dac789, + 0x86deb3f078787e2a, 0xbb9373f46fee7aab, 0xf7d8b57e27ecf57b, + 0x3d04e8d2fca26a9f, 0x3172826ac9df13cb, 0xa8fcd8e0cd9e8d7c, + 0x307641d9b2c39497, 0x2608c4cf1cc939c1, 0x3d326a7eb6d1c7bf, + 0x8e13e25feeaf19e6, 0x2dfe6d97ee63302b, 0xe41d3cc425971d58, + 0xab8db59a0a80627c, 0xe90afb779eea37c8, 0x9ee3352c90ca19cf, + 0xfe78d6823613c850, 0x5b060904788f6e50, 0x3fecb534b71bd1a4, + 0x20c33857b32c450c, 0x0239f4cea6e9cfda, 0xa19adb9548497187, + 0x95aca6a8b492ed8a, 0xcf1b23504dcd6cd9, 0x1a67778cfbe8b12a, + 0xc32da38338eb3acc, 0xa03f40a8fb126ab1, 0xe9ce4724ed5bf546, + 0x73a130d84c4a74fd, 0xa2ebd6c1d9960e2d, 0x6f233b7c94ab6feb, + 0x8e7b9a7349126080, 0xd298f9994b8c9091, 0xa96ddeff35e836b5, + 0x6b0dd9bc96119b31, 0x282566fbc6cc3f8d, 0xd6769f3b72b882e7, + 0x00fc509ba674343d, 0xd6266a3fdcbf7789, 0x4e89541bae9641fd, + 0x53400d0311953407, 0xe5b533458e0dd75a, 0x108b89bc108f19ad, + 0xe03b2b6341a4c954, 0x97aced8e437b3d7f, 0x2c5508c2cbd66670, + 0x5c4f2ef0650ebc69, 0x9985a2df904ff6bf, 0x5ed8d2399faddd9e, + 0xe3e51cb925585832, 0x56c02d9a0ff4f1d4, 0xc1a08a138c4ef804, + 0xe6d2767113fd01c8, 0x9d0176cca7c234f4, 0x4d8bfa89d0d73df2, + 0x2b17e0b2544f10cd, 0xfd86fe49b70a5c7d, 0x214495bbdf373f41, + 0x00d313d584e857fd, 0xa4ba47440496fcbe, 0xaec29e6ee8cac982, + 0x7000a51987ec7038, 0xff66e42caeee333b, 0x03b4f63b8afd6b25, + 0x5ab8d9c7bd7991dc, 0x48741a6c2ed4684e, 0x2fdc6349af06940d, + 0xe974996fb03d7ecd, 0x52ec8721ac7867f9, 0x8edd2d00bcdd9d4a, + 0x41c759f83557de06, 0xa75409f23956d4b9, 0xb6100fab123cd8a1, + 0x2e8d623b3e7b21e2, 0xbca35f7792959da2, 0x35fcb457200c03a5, + 0xf74eb9281bb6c6e4, 0x87cc1d213d5d0b54, 0x18ae42404964046f, + 0x8bd2b496d868b275, 0xc234d8f51c5563f4, 0xf9151ffff868e970, + 0x271133eeae7be4a2, 0x25254932bb0fd922, 0x104bcd64a60a9fc0, + 0x0000006230290145 +}; #endif #else # error "mp_limb_t size " BITS_PER_MP_LIMB "not accounted for" #endif -#ifndef __NO_LONG_DOUBLE_MATH -/* This value is the index of the last array element. */ -# define _LAST_POW10 12 -#else -# define _LAST_POW10 8 -#endif - /* Each of array variable above defines one mpn integer which is a power of 10. This table points to those variables, indexed by the exponent. */ -const struct mp_power _fpioconst_pow10[_LAST_POW10 + 1] = - { - { _ten_p0, sizeof (_ten_p0) / sizeof (_ten_p0[0]), 4, }, - { _ten_p1, sizeof (_ten_p1) / sizeof (_ten_p1[0]), 7, 4 }, - { _ten_p2, sizeof (_ten_p2) / sizeof (_ten_p2[0]), 14, 10 }, - { _ten_p3, sizeof (_ten_p3) / sizeof (_ten_p3[0]), 27, 24 }, - { _ten_p4, sizeof (_ten_p4) / sizeof (_ten_p4[0]), 54, 50 }, - { _ten_p5, sizeof (_ten_p5) / sizeof (_ten_p5[0]), 107, 103 }, - { _ten_p6, sizeof (_ten_p6) / sizeof (_ten_p6[0]), 213, 210 }, - { _ten_p7, sizeof (_ten_p7) / sizeof (_ten_p7[0]), 426, 422 }, - { _ten_p8, sizeof (_ten_p8) / sizeof (_ten_p8[0]), 851, 848 }, +const struct mp_power _fpioconst_pow10[LDBL_MAX_10_EXP_LOG + 1] = +{ + { TENS_P0_IDX, TENS_P0_SIZE, 4, }, + { TENS_P1_IDX, TENS_P1_SIZE, 7, 4 }, + { TENS_P2_IDX, TENS_P2_SIZE, 14, 10 }, + { TENS_P3_IDX, TENS_P3_SIZE, 27, 24 }, + { TENS_P4_IDX, TENS_P4_SIZE, 54, 50 }, + { TENS_P5_IDX, TENS_P5_SIZE, 107, 103 }, + { TENS_P6_IDX, TENS_P6_SIZE, 213, 210 }, + { TENS_P7_IDX, TENS_P7_SIZE, 426, 422 }, + { TENS_P8_IDX, TENS_P8_SIZE, 851, 848 }, #ifndef __NO_LONG_DOUBLE_MATH - { _ten_p9, sizeof (_ten_p9) / sizeof (_ten_p9[0]), 1701, 1698 }, - { _ten_p10, sizeof (_ten_p10) / sizeof (_ten_p10[0]), 3402, 3399 }, - { _ten_p11, sizeof (_ten_p11) / sizeof (_ten_p11[0]), 6804, 6800 }, - { _ten_p12, sizeof (_ten_p12) / sizeof (_ten_p12[0]), 13607, 13604 } + { TENS_P9_IDX, TENS_P9_SIZE, 1701, 1698 }, + { TENS_P10_IDX, TENS_P10_SIZE, 3402, 3399 }, + { TENS_P11_IDX, TENS_P11_SIZE, 6804, 6800 }, + { TENS_P12_IDX, TENS_P12_SIZE, 13607, 13604 } #endif - }; +}; #if LAST_POW10 > _LAST_POW10 # error "Need to expand 10^(2^i) table for i up to" LAST_POW10 diff --git a/stdlib/fpioconst.h b/stdlib/fpioconst.h index b802148ad6..869fc94d89 100644 --- a/stdlib/fpioconst.h +++ b/stdlib/fpioconst.h @@ -42,11 +42,14 @@ #define FLT_MAX_10_EXP_LOG 5 /* = floor(log_2(FLT_MAX_10_EXP)) */ +/* The array with the number representation. */ +extern const mp_limb_t __tens[]; + /* Table of powers of ten. This is used by __printf_fp and by strtof/strtod/strtold. */ struct mp_power { - const mp_limb_t *array; /* The array with the number representation. */ + size_t arrayoff; /* Offset in `__tens'. */ mp_size_t arraysize; /* Size of the array. */ int p_expo; /* Exponent of the number 10^(2^i). */ int m_expo; /* Exponent of the number 10^-(2^i-1). */ diff --git a/stdlib/getsubopt.c b/stdlib/getsubopt.c index ecdc1edce9..d559d9077f 100644 --- a/stdlib/getsubopt.c +++ b/stdlib/getsubopt.c @@ -41,9 +41,7 @@ getsubopt (optionp, tokens, valuep) return -1; /* Find end of next token. */ - endp = strchr (*optionp, ','); - if (endp == NULL) - endp = strchr (*optionp, '\0'); + endp = __strchrnul (*optionp, ','); /* Find start of value. */ vstart = memchr (*optionp, '=', endp - *optionp); diff --git a/stdlib/strtod.c b/stdlib/strtod.c index 0de96a571b..7502799edf 100644 --- a/stdlib/strtod.c +++ b/stdlib/strtod.c @@ -1,7 +1,7 @@ /* Read decimal floating point numbers. This file is part of the GNU C Library. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -892,6 +892,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM) { if ((exponent & expbit) != 0) { + size_t size = ttab->arraysize - _FPIO_CONST_OFFSET; mp_limb_t cy; exponent ^= expbit; @@ -901,13 +902,14 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM) bits follow. */ if (numsize >= ttab->arraysize - _FPIO_CONST_OFFSET) cy = __mpn_mul (pdest, psrc, numsize, - &ttab->array[_FPIO_CONST_OFFSET], - ttab->arraysize - _FPIO_CONST_OFFSET); + &__tens[ttab->arrayoff + + _FPIO_CONST_OFFSET], + size); else - cy = __mpn_mul (pdest, &ttab->array[_FPIO_CONST_OFFSET], - ttab->arraysize - _FPIO_CONST_OFFSET, - psrc, numsize); - numsize += ttab->arraysize - _FPIO_CONST_OFFSET; + cy = __mpn_mul (pdest, &__tens[ttab->arrayoff + + _FPIO_CONST_OFFSET], + size, psrc, numsize); + numsize += size; if (cy == 0) --numsize; SWAP (psrc, pdest); @@ -1062,12 +1064,13 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM) if (densize == 0) { densize = ttab->arraysize - _FPIO_CONST_OFFSET; - memcpy (psrc, &ttab->array[_FPIO_CONST_OFFSET], + memcpy (psrc, &__tens[ttab->arrayoff + _FPIO_CONST_OFFSET], densize * sizeof (mp_limb_t)); } else { - cy = __mpn_mul (pdest, &ttab->array[_FPIO_CONST_OFFSET], + cy = __mpn_mul (pdest, &__tens[ttab->arrayoff + + _FPIO_CONST_OFFSET], ttab->arraysize - _FPIO_CONST_OFFSET, psrc, densize); densize += ttab->arraysize - _FPIO_CONST_OFFSET; diff --git a/string/Makefile b/string/Makefile index ebdaad85ba..d0e3c8e83b 100644 --- a/string/Makefile +++ b/string/Makefile @@ -34,7 +34,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn \ mempcpy bcopy bzero ffs ffsll stpcpy stpncpy \ strcasecmp strncase strcasecmp_l strncase_l \ memccpy memcpy wordcopy strsep strcasestr \ - swab strfry memfrob memmem rawmemchr \ + swab strfry memfrob memmem rawmemchr strchrnul \ $(addprefix argz-,append count create ctsep next \ delete extract insert stringify \ addsep replace) \ diff --git a/string/Versions b/string/Versions index fa599fcb59..48562e9e4c 100644 --- a/string/Versions +++ b/string/Versions @@ -58,6 +58,6 @@ libc { } GLIBC_2.1.1 { # s* - __strverscmp; + strchrnul; __strverscmp; } } diff --git a/string/strfry.c b/string/strfry.c index 98aa71aa3f..c13b3da979 100644 --- a/string/strfry.c +++ b/string/strfry.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1996, 1999 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 @@ -23,7 +23,7 @@ char * strfry (char *string) { - static int init = 0; + static int init; static struct random_data rdata; size_t len, i; diff --git a/string/string.h b/string/string.h index 766913a620..6c913a85c6 100644 --- a/string/string.h +++ b/string/string.h @@ -147,6 +147,12 @@ extern char *strchr __P ((__const char *__s, int __c)); /* Find the last occurrence of C in S. */ extern char *strrchr __P ((__const char *__s, int __c)); +#ifdef __USE_GNU +/* This funciton is similar to `strchr'. But it returns a pointer to + the closing NUL byte in case C is not found in S. */ +extern char *strchrnul __P ((__const char *__s, int __c)); +#endif + /* Return the length of the initial segment of S which consists entirely of characters not in REJECT. */ extern size_t strcspn __P ((__const char *__s, __const char *__reject)); diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c index d756cb12ba..ae6a1da7e0 100644 --- a/sunrpc/clnt_perr.c +++ b/sunrpc/clnt_perr.c @@ -153,47 +153,102 @@ clnt_perror (CLIENT * rpch, const char *msg) struct rpc_errtab { enum clnt_stat status; - const char *message; + unsigned int message_off; +}; + +static const char rpc_errstr[] = +{ +#define RPC_SUCCESS_IDX 0 + N_("RPC: Success") + "\0" +#define RPC_CANTENCODEARGS_IDX (RPC_SUCCESS_IDX + sizeof "RPC: Success") + N_("RPC: Can't encode arguments") + "\0" +#define RPC_CANTDECODERES_IDX (RPC_CANTENCODEARGS_IDX \ + + sizeof "RPC: Can't encode arguments") + N_("RPC: Can't decode result") + "\0" +#define RPC_CANTSEND_IDX (RPC_CANTDECODERES_IDX \ + + sizeof "RPC: Can't decode result") + N_("RPC: Unable to send") + "\0" +#define RPC_CANTRECV_IDX (RPC_CANTSEND_IDX \ + + sizeof "RPC: Unable to send") + N_("RPC: Unable to receive") + "\0" +#define RPC_TIMEDOUT_IDX (RPC_CANTRECV_IDX \ + + sizeof "RPC: Unable to receive") + N_("RPC: Timed out") + "\0" +#define RPC_VERSMISMATCH_IDX (RPC_TIMEDOUT_IDX \ + + sizeof "RPC: Timed out") + N_("RPC: Incompatible versions of RPC") + "\0" +#define RPC_AUTHERROR_IDX (RPC_VERSMISMATCH_IDX \ + + sizeof "RPC: Incompatible versions of RPC") + N_("RPC: Authentication error") + "\0" +#define RPC_PROGUNAVAIL_IDX (RPC_AUTHERROR_IDX \ + + sizeof "RPC: Authentication error") + N_("RPC: Program unavailable") + "\0" +#define RPC_PROGVERSMISMATCH_IDX (RPC_PROGUNAVAIL_IDX \ + + sizeof "RPC: Program unavailable") + N_("RPC: Program/version mismatch") + "\0" +#define RPC_PROCUNAVAIL_IDX (RPC_PROGVERSMISMATCH_IDX \ + + sizeof "RPC: Program/version mismatch") + N_("RPC: Procedure unavailable") + "\0" +#define RPC_CANTDECODEARGS_IDX (RPC_PROCUNAVAIL_IDX \ + + sizeof "RPC: Procedure unavailable") + N_("RPC: Server can't decode arguments") + "\0" +#define RPC_SYSTEMERROR_IDX (RPC_CANTDECODEARGS_IDX \ + + sizeof "RPC: Server can't decode arguments") + N_("RPC: Remote system error") + "\0" +#define RPC_UNKNOWNHOST_IDX (RPC_SYSTEMERROR_IDX \ + + sizeof "RPC: Remote system error") + N_("RPC: Unknown host") + "\0" +#define RPC_UNKNOWNPROTO_IDX (RPC_UNKNOWNHOST_IDX \ + + sizeof "RPC: Unknown host") + N_("RPC: Unknown protocol") + "\0" +#define RPC_PMAPFAILURE_IDX (RPC_UNKNOWNPROTO_IDX \ + + sizeof "RPC: Unknown protocol") + N_("RPC: Port mapper failure") + "\0" +#define RPC_PROGNOTREGISTERED_IDX (RPC_PMAPFAILURE_IDX \ + + sizeof "RPC: Port mapper failure") + N_("RPC: Program not registered") + "\0" +#define RPC_FAILED_IDX (RPC_PROGNOTREGISTERED_IDX \ + + sizeof "RPC: Program not registered") + N_("RPC: Failed (unspecified error)") }; static const struct rpc_errtab rpc_errlist[] = { - {RPC_SUCCESS, - N_("RPC: Success")}, - {RPC_CANTENCODEARGS, - N_("RPC: Can't encode arguments")}, - {RPC_CANTDECODERES, - N_("RPC: Can't decode result")}, - {RPC_CANTSEND, - N_("RPC: Unable to send")}, - {RPC_CANTRECV, - N_("RPC: Unable to receive")}, - {RPC_TIMEDOUT, - N_("RPC: Timed out")}, - {RPC_VERSMISMATCH, - N_("RPC: Incompatible versions of RPC")}, - {RPC_AUTHERROR, - N_("RPC: Authentication error")}, - {RPC_PROGUNAVAIL, - N_("RPC: Program unavailable")}, - {RPC_PROGVERSMISMATCH, - N_("RPC: Program/version mismatch")}, - {RPC_PROCUNAVAIL, - N_("RPC: Procedure unavailable")}, - {RPC_CANTDECODEARGS, - N_("RPC: Server can't decode arguments")}, - {RPC_SYSTEMERROR, - N_("RPC: Remote system error")}, - {RPC_UNKNOWNHOST, - N_("RPC: Unknown host")}, - {RPC_UNKNOWNPROTO, - N_("RPC: Unknown protocol")}, - {RPC_PMAPFAILURE, - N_("RPC: Port mapper failure")}, - {RPC_PROGNOTREGISTERED, - N_("RPC: Program not registered")}, - {RPC_FAILED, - N_("RPC: Failed (unspecified error)")} + { RPC_SUCCESS, RPC_SUCCESS_IDX }, + { RPC_CANTENCODEARGS, RPC_CANTENCODEARGS_IDX }, + { RPC_CANTDECODERES, RPC_CANTDECODERES_IDX }, + { RPC_CANTSEND, RPC_CANTSEND_IDX }, + { RPC_CANTRECV, RPC_CANTRECV_IDX }, + { RPC_TIMEDOUT, RPC_TIMEDOUT_IDX }, + { RPC_VERSMISMATCH, RPC_VERSMISMATCH_IDX }, + { RPC_AUTHERROR, RPC_AUTHERROR_IDX }, + { RPC_PROGUNAVAIL, RPC_PROGUNAVAIL_IDX }, + { RPC_PROGVERSMISMATCH, RPC_PROGVERSMISMATCH }, + { RPC_PROCUNAVAIL, RPC_PROCUNAVAIL_IDX }, + { RPC_CANTDECODEARGS, RPC_CANTDECODEARGS_IDX }, + { RPC_SYSTEMERROR, RPC_SYSTEMERROR_IDX }, + { RPC_UNKNOWNHOST, RPC_UNKNOWNHOST_IDX }, + { RPC_UNKNOWNPROTO, RPC_UNKNOWNPROTO_IDX }, + { RPC_PMAPFAILURE, RPC_PMAPFAILURE_IDX }, + { RPC_PROGNOTREGISTERED, RPC_PROGNOTREGISTERED_IDX }, + { RPC_FAILED, RPC_FAILED_IDX } }; @@ -209,7 +264,7 @@ clnt_sperrno (enum clnt_stat stat) { if (rpc_errlist[i].status == stat) { - return _(rpc_errlist[i].message); + return _(rpc_errstr + rpc_errlist[i].message_off); } } return _("RPC: (unknown error code)"); @@ -264,27 +319,52 @@ clnt_pcreateerror (const char *msg) struct auth_errtab { enum auth_stat status; - const char *message; + unsigned int message_off; +}; + +static const char auth_errstr[] = +{ +#define AUTH_OK_IDX 0 + N_("Authentication OK") + "\0" +#define AUTH_BADCRED_IDX (AUTH_OK_IDX + sizeof "Authentication OK") + N_("Invalid client credential") + "\0" +#define AUTH_REJECTEDCRED_IDX (AUTH_BADCRED_IDX \ + + sizeof "Invalid client credential") + N_("Server rejected credential") + "\0" +#define AUTH_BADVERF_IDX (AUTH_REJECTEDCRED_IDX \ + + sizeof "Server rejected credential") + N_("Invalid client verifier") + "\0" +#define AUTH_REJECTEDVERF_IDX (AUTH_BADVERF_IDX \ + + sizeof "Invalid client verifier") + N_("Server rejected verifier") + "\0" +#define AUTH_TOOWEAK_IDX (AUTH_REJECTEDVERF_IDX \ + + sizeof "Server rejected verifier") + N_("Client credential too weak") + "\0" +#define AUTH_INVALIDRESP_IDX (AUTH_TOOWEAK_IDX \ + + sizeof "Client credential too weak") + N_("Invalid server verifier") + "\0" +#define AUTH_FAILED_IDX (AUTH_INVALIDRESP_IDX \ + + sizeof "Invalid server verifier") + N_("Failed (unspecified error)") }; static const struct auth_errtab auth_errlist[] = { - {AUTH_OK, - N_("Authentication OK")}, - {AUTH_BADCRED, - N_("Invalid client credential")}, - {AUTH_REJECTEDCRED, - N_("Server rejected credential")}, - {AUTH_BADVERF, - N_("Invalid client verifier")}, - {AUTH_REJECTEDVERF, - N_("Server rejected verifier")}, - {AUTH_TOOWEAK, - N_("Client credential too weak")}, - {AUTH_INVALIDRESP, - N_("Invalid server verifier")}, - {AUTH_FAILED, - N_("Failed (unspecified error)")}, + { AUTH_OK, AUTH_OK_IDX }, + { AUTH_BADCRED, AUTH_BADCRED_IDX }, + { AUTH_REJECTEDCRED, AUTH_REJECTEDCRED_IDX }, + { AUTH_BADVERF, AUTH_BADVERF_IDX }, + { AUTH_REJECTEDVERF, AUTH_REJECTEDVERF_IDX }, + { AUTH_TOOWEAK, AUTH_TOOWEAK_IDX }, + { AUTH_INVALIDRESP, AUTH_INVALIDRESP_IDX }, + { AUTH_FAILED, AUTH_FAILED_IDX } }; static char * @@ -297,7 +377,7 @@ auth_errmsg (enum auth_stat stat) { if (auth_errlist[i].status == stat) { - return _(auth_errlist[i].message); + return _(auth_errstr + auth_errlist[i].message_off); } } return NULL; diff --git a/sunrpc/des_soft.c b/sunrpc/des_soft.c index ae12d7b0a6..f358cac480 100644 --- a/sunrpc/des_soft.c +++ b/sunrpc/des_soft.c @@ -8,23 +8,23 @@ static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/ /* * Table giving odd parity in the low bit for ASCII characters */ -static char partab[128] = +static const char partab[128] = { 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c index 6157e574b9..5aef933cbf 100644 --- a/sunrpc/key_call.c +++ b/sunrpc/key_call.c @@ -59,14 +59,14 @@ #define debug(msg) /* turn off debugging */ -extern int _openchild (char *command, FILE **fto, FILE **ffrom); +extern int _openchild (const char *command, FILE **fto, FILE **ffrom); static int key_call (u_long, xdrproc_t xdr_arg, char *, xdrproc_t xdr_rslt, char *) internal_function; -static struct timeval trytimeout = {KEY_TIMEOUT, 0}; -static struct timeval tottimeout = {KEY_TIMEOUT *KEY_NRETRY, 0}; +static const struct timeval trytimeout = {KEY_TIMEOUT, 0}; +static const struct timeval tottimeout = {KEY_TIMEOUT *KEY_NRETRY, 0}; int key_setsecret (char *secretkey) @@ -268,9 +268,9 @@ key_get_conv (char *pkey, des_block *deskey) * implementations of these functions, and to call those in key_call(). */ -cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *) = 0; -cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *) = 0; -des_block *(*__key_gendes_LOCAL) (uid_t, char *) = 0; +cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *); +cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *); +des_block *(*__key_gendes_LOCAL) (uid_t, char *); static int internal_function @@ -287,7 +287,7 @@ key_call_keyenvoy (u_long proc, xdrproc_t xdr_arg, char *arg, int success; uid_t ruid; uid_t euid; - static char MESSENGER[] = "/usr/etc/keyenvoy"; + static const char MESSENGER[] = "/usr/etc/keyenvoy"; success = 1; sigemptyset (&mask); @@ -355,7 +355,7 @@ struct key_call_private { pid_t pid; /* process-id at moment of creation */ uid_t uid; /* user-id at last authorization */ }; -static struct key_call_private *key_call_private_main = NULL; +static struct key_call_private *key_call_private_main; __libc_lock_define_initialized (static, keycall_lock) /* @@ -555,9 +555,9 @@ internal_function key_call (u_long proc, xdrproc_t xdr_arg, char *arg, xdrproc_t xdr_rslt, char *rslt) { - static int use_keyenvoy = 0; + static int use_keyenvoy; #ifdef HAVE_DOORS - static int use_doors = 1; + static int not_use_doors; #endif if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL) @@ -583,11 +583,11 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, } #ifdef HAVE_DOORS - if (use_doors) + if (!not_use_doors) { if (key_call_door (proc, xdr_arg, arg, xdr_rslt, rslt)) return 1; - use_doors = 0; + not_use_doors = 1; } #endif if (!use_keyenvoy) diff --git a/sunrpc/netname.c b/sunrpc/netname.c index 1578108194..3a2025da09 100644 --- a/sunrpc/netname.c +++ b/sunrpc/netname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997. @@ -26,7 +26,7 @@ #define OPSYS_LEN 4 #define MAXIPRINT (11) /* max length of printed integer */ -static const char *OPSYS = "unix"; +static const char OPSYS[] = "unix"; int user2netname (char netname[MAXNETNAMELEN + 1], const uid_t uid, @@ -141,7 +141,7 @@ int netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp, gid_t * gidp, int *gidlenp, gid_t * gidlist) { - static service_user *startp = NULL; + static service_user *startp; static netname2user_function start_fct; service_user *nip; netname2user_function fct; diff --git a/sunrpc/openchild.c b/sunrpc/openchild.c index 8399b261bd..4b5a0a5f24 100644 --- a/sunrpc/openchild.c +++ b/sunrpc/openchild.c @@ -53,7 +53,7 @@ * returns pid, or -1 for failure */ int -_openchild (char *command, FILE ** fto, FILE ** ffrom) +_openchild (const char *command, FILE ** fto, FILE ** ffrom) { int i; int pid; diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c index c35540e06e..f361ac3598 100644 --- a/sunrpc/pmap_rmt.c +++ b/sunrpc/pmap_rmt.c @@ -58,7 +58,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; extern u_long _create_xid (void); -static struct timeval timeout = {3, 0}; +static const struct timeval timeout = {3, 0}; /* * pmapper remote-call-service interface. diff --git a/sunrpc/publickey.c b/sunrpc/publickey.c index 16664b6714..94d5499b98 100644 --- a/sunrpc/publickey.c +++ b/sunrpc/publickey.c @@ -1,5 +1,5 @@ /* Get public or secret key from key server. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -38,7 +38,7 @@ extern int __nss_publickey_lookup (service_user **nip, const char *name, int getpublickey (const char *name, char *key) { - static service_user *startp = NULL; + static service_user *startp; static public_function start_fct; service_user *nip; public_function fct; @@ -76,7 +76,7 @@ getpublickey (const char *name, char *key) int getsecretkey (const char *name, char *key, const char *passwd) { - static service_user *startp = NULL; + static service_user *startp; static secret_function start_fct; service_user *nip; secret_function fct; diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c index 1a76b10183..d854fb4f2c 100644 --- a/sunrpc/svc_run.c +++ b/sunrpc/svc_run.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; #include <errno.h> #include <rpc/rpc.h> -static int svc_stop = 0; +static int svc_stop; /* This function can be used as a signal handler to terminate the server loop. */ diff --git a/sunrpc/xcrypt.c b/sunrpc/xcrypt.c index bee38ad8b5..a6b2499708 100644 --- a/sunrpc/xcrypt.c +++ b/sunrpc/xcrypt.c @@ -50,7 +50,7 @@ static char sccsid[] = "@(#)xcrypt.c 1.3 89/03/24 Copyr 1986 Sun Micro"; #include <sys/types.h> #include <rpc/des_crypt.h> -static char hex[16] = +static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', diff --git a/sysdeps/generic/stackinfo.h b/sysdeps/generic/stackinfo.h new file mode 100644 index 0000000000..5d6d8200bd --- /dev/null +++ b/sysdeps/generic/stackinfo.h @@ -0,0 +1,21 @@ +/* Copyright (C) 1999 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. */ + +/* This file contains a bit of information about the stack allocation + of the processor. Since there is no general truth we can't say + anything here. */ diff --git a/sysdeps/generic/strchrnul.c b/sysdeps/generic/strchrnul.c new file mode 100644 index 0000000000..1d6ece5332 --- /dev/null +++ b/sysdeps/generic/strchrnul.c @@ -0,0 +1,166 @@ +/* Copyright (C) 1991, 93, 94, 95, 96, 97, 99 Free Software Foundation, Inc. + Based on strlen implementation by Torbjorn Granlund (tege@sics.se), + with help from Dan Sahlin (dan@sics.se) and + bug fix and commentary by Jim Blandy (jimb@ai.mit.edu); + adaptation to strchr suggested by Dick Karpinski (dick@cca.ucsf.edu), + and implemented by Roland McGrath (roland@ai.mit.edu). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is 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 <string.h> + +#undef __strchrnul +#undef strchrnul + +/* Find the first occurrence of C in S or the final NUL byte. */ +char * +__strchrnul (s, c) + const char *s; + int c; +{ + const unsigned char *char_ptr; + const unsigned long int *longword_ptr; + unsigned long int longword, magic_bits, charmask; + + c = (unsigned char) c; + + /* Handle the first few characters by reading one character at a time. + Do this until CHAR_PTR is aligned on a longword boundary. */ + for (char_ptr = s; ((unsigned long int) char_ptr + & (sizeof (longword) - 1)) != 0; + ++char_ptr) + if (*char_ptr == c || *char_ptr == '\0') + return (void *) char_ptr; + + /* All these elucidatory comments refer to 4-byte longwords, + but the theory applies equally well to 8-byte longwords. */ + + longword_ptr = (unsigned long int *) char_ptr; + + /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits + the "holes." Note that there is a hole just to the left of + each byte, with an extra at the end: + + bits: 01111110 11111110 11111110 11111111 + bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD + + The 1-bits make sure that carries propagate to the next 0-bit. + The 0-bits provide holes for carries to fall into. */ + switch (sizeof (longword)) + { + case 4: magic_bits = 0x7efefeffL; break; + case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; + default: + abort (); + } + + /* Set up a longword, each of whose bytes is C. */ + charmask = c | (c << 8); + charmask |= charmask << 16; + if (sizeof (longword) > 4) + /* Do the shift in two steps to avoid a warning if long has 32 bits. */ + charmask |= (charmask << 16) << 16; + if (sizeof (longword) > 8) + abort (); + + /* Instead of the traditional loop which tests each character, + we will test a longword at a time. The tricky part is testing + if *any of the four* bytes in the longword in question are zero. */ + for (;;) + { + /* We tentatively exit the loop if adding MAGIC_BITS to + LONGWORD fails to change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-30 is set, there will be a carry + into bit 31, so all of the hole bits will be changed. + + The one misfire occurs when bits 24-30 are clear and bit + 31 is set; in this case, the hole at bit 31 is not + changed. If we had access to the processor carry flag, + we could close this loophole by putting the fourth hole + at bit 32! + + So it ignores everything except 128's, when they're aligned + properly. + + 3) But wait! Aren't we looking for C as well as zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + + longword = *longword_ptr++; + + /* Add MAGIC_BITS to LONGWORD. */ + if ((((longword + magic_bits) + + /* Set those bits that were unchanged by the addition. */ + ^ ~longword) + + /* Look at only the hole bits. If any of the hole bits + are unchanged, most likely one of the bytes was a + zero. */ + & ~magic_bits) != 0 || + + /* That caught zeroes. Now test for C. */ + ((((longword ^ charmask) + magic_bits) ^ ~(longword ^ charmask)) + & ~magic_bits) != 0) + { + /* Which of the bytes was C or zero? + If none of them were, it was a misfire; continue the search. */ + + const unsigned char *cp = (const unsigned char *) (longword_ptr - 1); + + if (*cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (sizeof (longword) > 4) + { + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + if (*++cp == c || *cp == '\0') + return (char *) cp; + } + } + } + + /* This should never happen. */ + return NULL; +} + +weak_alias (__strchrnul, strchrnul) diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h index 4bd65af7f1..5a67c1b4e1 100644 --- a/sysdeps/i386/bits/string.h +++ b/sysdeps/i386/bits/string.h @@ -517,6 +517,66 @@ __strchr_c (__const char *__s, int __c) } +/* Find the first occurrence of C in S or the final NUL byte. */ +#define _HAVE_STRING_ARCH_strchrnul 1 +#define __strchrnul(s, c) \ + (__extension__ (__builtin_constant_p (c) \ + ? ((c) == '\0' \ + ? (char *) __rawmemchr (s, c) \ + : __strchrnul_c (s, ((c) & 0xff) << 8)) \ + : __strchrnul_g (s, c))) + +__STRING_INLINE char *__strchrnul_g (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_g (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movb %%al,%%ah\n" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} + +__STRING_INLINE char *__strchrnul_c (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_c (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} +#ifdef __USE_GNU +# define strchrnul(s, c) __strchrnul (s, c) +#endif + + /* Return the length of the initial segment of S which consists entirely of characters not in REJECT. */ #define _HAVE_STRING_ARCH_strcspn 1 diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h index 6e5c3fed1f..cb0229b5cd 100644 --- a/sysdeps/i386/i486/bits/string.h +++ b/sysdeps/i386/i486/bits/string.h @@ -1056,6 +1056,66 @@ __strchr_g (__const char *__s, int __c) } +/* Find the first occurrence of C in S or the final NUL byte. */ +#define _HAVE_STRING_ARCH_strchrnul 1 +#define __strchrnul(s, c) \ + (__extension__ (__builtin_constant_p (c) \ + ? ((c) == '\0' \ + ? (char *) __rawmemchr (s, c) \ + : __strchrnul_c (s, ((c) & 0xff) << 8)) \ + : __strchrnul_g (s, c))) + +__STRING_INLINE char *__strchrnul_c (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_c (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("1:\n\t" + "movb (%0),%%al\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "leal 1(%0),%0\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "decl %0\n" + "2:" + : "=r" (__res), "=&a" (__d0) + : "0" (__s), "1" (__c) + : "cc"); + return __res; +} + +__STRING_INLINE char *__strchrnul_g (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_g (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("movb %%al,%%ah\n" + "1:\n\t" + "movb (%0),%%al\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "leal 1(%0),%0\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "decl %0\n" + "2:" + : "=r" (__res), "=&a" (__d0) + : "0" (__s), "1" (__c) + : "cc"); + return __res; +} +#ifdef __USE_GNU +# define strchrnul(s, c) __strchrnul (s, c) +#endif + + #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED /* Find the first occurrence of C in S. This is the BSD name. */ # define _HAVE_STRING_ARCH_index 1 diff --git a/sysdeps/i386/stackinfo.h b/sysdeps/i386/stackinfo.h new file mode 100644 index 0000000000..2fe865a364 --- /dev/null +++ b/sysdeps/i386/stackinfo.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1999 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. */ + +/* This file contains a bit of information about the stack allocation + of the processor. */ + +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +/* On x86 the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +#endif /* stackinfo.h */ diff --git a/sysdeps/i386/strchrnul.S b/sysdeps/i386/strchrnul.S new file mode 100644 index 0000000000..45950c3564 --- /dev/null +++ b/sysdeps/i386/strchrnul.S @@ -0,0 +1,275 @@ +/* strchrnul (str, ch) -- Return pointer to first occurrence of CH in STR + or the final NUL byte. + For Intel 80x86, x>=3. + Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@gnu.org> + Some optimisations by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> + + 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 "asm-syntax.h" + +/* + INPUT PARAMETERS: + str (sp + 4) + ch (sp + 8) +*/ + + .text +ENTRY (__strchrnul) + pushl %edi /* Save callee-safe registers used here. */ + + movl 8(%esp), %eax /* get string pointer */ + movl 12(%esp), %edx /* get character we are looking for */ + + /* At the moment %edx contains C. What we need for the + algorithm is C in all bytes of the dword. Avoid + operations on 16 bit words because these require an + prefix byte (and one more cycle). */ + movb %dl, %dh /* now it is 0|0|c|c */ + movl %edx, %ecx + shll $16, %edx /* now it is c|c|0|0 */ + movw %cx, %dx /* and finally c|c|c|c */ + + /* Before we start with the main loop we process single bytes + until the source pointer is aligned. This has two reasons: + 1. aligned 32-bit memory access is faster + and (more important) + 2. we process in the main loop 32 bit in one step although + we don't know the end of the string. But accessing at + 4-byte alignment guarantees that we never access illegal + memory if this would not also be done by the trivial + implementation (this is because all processor inherent + boundaries are multiples of 4. */ + + testb $3, %eax /* correctly aligned ? */ + jz L(11) /* yes => begin loop */ + movb (%eax), %cl /* load byte in question (we need it twice) */ + cmpb %cl, %dl /* compare byte */ + je L(6) /* target found => return */ + testb %cl, %cl /* is NUL? */ + jz L(6) /* yes => return NULL */ + incl %eax /* increment pointer */ + + testb $3, %eax /* correctly aligned ? */ + jz L(11) /* yes => begin loop */ + movb (%eax), %cl /* load byte in question (we need it twice) */ + cmpb %cl, %dl /* compare byte */ + je L(6) /* target found => return */ + testb %cl, %cl /* is NUL? */ + jz L(6) /* yes => return NULL */ + incl %eax /* increment pointer */ + + testb $3, %eax /* correctly aligned ? */ + jz L(11) /* yes => begin loop */ + movb (%eax), %cl /* load byte in question (we need it twice) */ + cmpb %cl, %dl /* compare byte */ + je L(6) /* target found => return */ + testb %cl, %cl /* is NUL? */ + jz L(6) /* yes => return NULL */ + incl %eax /* increment pointer */ + + /* No we have reached alignment. */ + jmp L(11) /* begin loop */ + + /* We exit the loop if adding MAGIC_BITS to LONGWORD fails to + change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-31 is set, there will be a carry + into bit 32 (=carry flag), so all of the hole bits will + be changed. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + + /* Each round the main loop processes 16 bytes. */ + + ALIGN(4) + +L(1): addl $16, %eax /* adjust pointer for whole round */ + +L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ + xorl %edx, %ecx /* XOR with word c|c|c|c => bytes of str == c + are now 0 */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* C */ + + /* According to the algorithm we had to reverse the effect of the + XOR first and then test the overflow bits. But because the + following XOR would destroy the carry flag and it would (in a + representation with more than 32 bits) not alter then last + overflow, we can now test this condition. If no carry is signaled + no overflow must have occurred in the last byte => it was 0. */ + jnc L(7) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ + + /* Now test for the other three overflow bits. */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + + /* If at least one byte of the word is C we don't get 0 in %edi. */ + jnz L(7) /* found it => return pointer */ + + /* Now we made sure the dword does not contain the character we are + looking for. But because we deal with strings we have to check + for the end of string before testing the next dword. */ + + xorl %edx, %ecx /* restore original dword without reload */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* 0 */ + jnc L(71) /* highest byte is NUL => return NULL */ + xorl %ecx, %edi /* (word+magic)^word */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(71) /* found NUL => return NULL */ + + movl 4(%eax), %ecx /* get word (= 4 bytes) in question */ + xorl %edx, %ecx /* XOR with word c|c|c|c => bytes of str == c + are now 0 */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* C */ + jnc L(71) /* highest byte is C => return pointer */ + xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(71) /* found it => return pointer */ + xorl %edx, %ecx /* restore original dword without reload */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* 0 */ + jnc L(71) /* highest byte is NUL => return NULL */ + xorl %ecx, %edi /* (word+magic)^word */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(71) /* found NUL => return NULL */ + + movl 8(%eax), %ecx /* get word (= 4 bytes) in question */ + xorl %edx, %ecx /* XOR with word c|c|c|c => bytes of str == c + are now 0 */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* C */ + jnc L(72) /* highest byte is C => return pointer */ + xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(72) /* found it => return pointer */ + xorl %edx, %ecx /* restore original dword without reload */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* 0 */ + jnc L(72) /* highest byte is NUL => return NULL */ + xorl %ecx, %edi /* (word+magic)^word */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(72) /* found NUL => return NULL */ + + movl 12(%eax), %ecx /* get word (= 4 bytes) in question */ + xorl %edx, %ecx /* XOR with word c|c|c|c => bytes of str == c + are now 0 */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* C */ + jnc L(73) /* highest byte is C => return pointer */ + xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jnz L(73) /* found it => return pointer */ + xorl %edx, %ecx /* restore original dword without reload */ + movl $0xfefefeff, %edi /* magic value */ + addl %ecx, %edi /* add the magic value to the word. We get + carry bits reported for each byte which + is *not* 0 */ + jnc L(73) /* highest byte is NUL => return NULL */ + xorl %ecx, %edi /* (word+magic)^word */ + orl $0xfefefeff, %edi /* set all non-carry bits */ + incl %edi /* add 1: if one carry bit was *not* set + the addition will not result in 0. */ + jz L(1) /* no NUL found => restart loop */ + +L(73): addl $4, %eax /* adjust pointer */ +L(72): addl $4, %eax +L(71): addl $4, %eax + + /* We now scan for the byte in which the character was matched. + But we have to take care of the case that a NUL char is + found before this in the dword. */ + +L(7): testb %cl, %cl /* is first byte C? */ + jz L(6) /* yes => return pointer */ + cmpb %dl, %cl /* is first byte NUL? */ + je L(6) /* yes => return NULL */ + incl %eax /* it's not in the first byte */ + + testb %ch, %ch /* is second byte C? */ + jz L(6) /* yes => return pointer */ + cmpb %dl, %ch /* is second byte NUL? */ + je L(6) /* yes => return NULL? */ + incl %eax /* it's not in the second byte */ + + shrl $16, %ecx /* make upper byte accessible */ + testb %cl, %cl /* is third byte C? */ + jz L(6) /* yes => return pointer */ + cmpb %dl, %cl /* is third byte NUL? */ + je L(6) /* yes => return NULL */ + + /* It must be in the fourth byte and it cannot be NUL. */ + incl %eax + +L(6): popl %edi /* restore saved register content */ + + ret +END (__strchrnul) + +weak_alias (__strchrnul, strchrnul) diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c index d38e7cc71b..e2205861a8 100644 --- a/sysdeps/posix/euidaccess.c +++ b/sysdeps/posix/euidaccess.c @@ -1,5 +1,5 @@ /* Check if effective user id can access file - Copyright (C) 1990, 91, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 95, 96, 97, 98, 99 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 @@ -119,7 +119,7 @@ static uid_t euid; static gid_t egid; /* Nonzero if UID, GID, EUID, and EGID have valid values. */ -static int have_ids = 0; +static int have_ids; /* Return 0 if the user has permission of type MODE on file PATH; diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c index bbe21d627f..fe28e2d894 100644 --- a/sysdeps/unix/sysv/linux/getcwd.c +++ b/sysdeps/unix/sysv/linux/getcwd.c @@ -1,5 +1,5 @@ /* Determine current working directory. Linux version. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -40,10 +40,10 @@ static char *generic_getcwd (char *buf, size_t size) internal_function; compiling under 2.1.92+ the libc still runs under older kernels. */ extern int __syscall_getcwd (char *buf, unsigned long size); static int no_syscall_getcwd; -static int no_new_dcache = 1; +static int have_new_dcache; #else # define no_syscall_getcwd 1 -static int no_new_dcache; +static int have_new_dcache = 1; #endif char * @@ -55,7 +55,7 @@ __getcwd (char *buf, size_t size) char *result; size_t alloc_size = size; - if (no_syscall_getcwd && no_new_dcache) + if (no_syscall_getcwd && !have_new_dcache) return generic_getcwd (buf, size); if (size == 0) @@ -101,7 +101,7 @@ __getcwd (char *buf, size_t size) if (errno == ENOSYS) { no_syscall_getcwd = 1; - no_new_dcache = 0; /* Now we will try the /proc method. */ + have_new_dcache = 1; /* Now we will try the /proc method. */ } else if (errno != ERANGE || buf != NULL) { @@ -137,12 +137,13 @@ __getcwd (char *buf, size_t size) return buf; } else - no_new_dcache = 1; + have_new_dcache = 0; } - /* Set to no_new_dcache only if error indicates that proc doesn't exist. */ + /* Set to have_new_dcache only if error indicates that proc doesn't + exist. */ if (errno != EACCES && errno != ENAMETOOLONG) - no_new_dcache = 1; + have_new_dcache = 0; /* Something went wrong. Restore the error number and use the generic version. */ diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c index 8165eccc1b..d2e0f1a7b8 100644 --- a/sysdeps/unix/sysv/linux/getpt.c +++ b/sysdeps/unix/sysv/linux/getpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. @@ -31,10 +31,10 @@ int __bsd_getpt (void); int __getpt (void) { - static int have_dev_ptmx = 1; + static int have_no_dev_ptmx; int fd; - if (have_dev_ptmx) + if (!have_no_dev_ptmx) { fd = __open (_PATH_DEVPTMX, O_RDWR); if (fd != -1) @@ -42,7 +42,7 @@ __getpt (void) else { if (errno == ENOENT || errno == ENODEV) - have_dev_ptmx = 0; + have_no_dev_ptmx = 1; else return -1; } diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h index 77c859ba53..7624cbc94e 100644 --- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h +++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h @@ -1,5 +1,5 @@ /* Linux/i386 version of processor capability information handling macros. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -28,7 +28,7 @@ static const char x86_cap_flags[][7] = "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic", "10", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse36", "18", "19", "20", "21", "22", "mmx", - "fxsr", "25", "26", "27", "28", "29", "30", "amd3d" + "osfxsr", "25", "26", "27", "28", "29", "30", "amd3d" }; static inline int diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index aa89a38e69..9b3db6abfb 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999 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 @@ -120,7 +120,7 @@ if_nameindex (void) unsigned int nifs, i; int rq_len; struct if_nameindex *idx = NULL; - static int new_siocgifconf = 1; + static int old_siocgifconf; #define RQ_IFS 4 if (fd < 0) @@ -130,13 +130,13 @@ if_nameindex (void) /* We may be able to get the needed buffer size directly, rather than guessing. */ - if (new_siocgifconf) + if (! old_siocgifconf) { ifc.ifc_buf = NULL; ifc.ifc_len = 0; if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0) { - new_siocgifconf = 0; + old_siocgifconf = 1; rq_len = RQ_IFS * sizeof (struct ifreq); } else @@ -156,7 +156,7 @@ if_nameindex (void) } rq_len *= 2; } - while (ifc.ifc_len == rq_len && new_siocgifconf == 0); + while (ifc.ifc_len == rq_len && old_siocgifconf); nifs = ifc.ifc_len / sizeof (struct ifreq); @@ -212,9 +212,9 @@ if_indextoname (unsigned int ifindex, char *ifname) list. This ioctl is not present in kernels before version 2.1.50. */ struct ifreq ifr; int fd; - static int siogifname_works = 1; + static int siogifname_works_not; - if (siogifname_works) + if (!siogifname_works_not) { int serrno = errno; @@ -227,7 +227,7 @@ if_indextoname (unsigned int ifindex, char *ifname) if (__ioctl (fd, SIOGIFNAME, &ifr) < 0) { if (errno == EINVAL) - siogifname_works = 0; /* Don't make the same mistake twice. */ + siogifname_works_not = 1; /* Don't make the same mistake twice. */ } else { diff --git a/sysdeps/unix/sysv/linux/poll.c b/sysdeps/unix/sysv/linux/poll.c index 880eeb9aa8..e7df3b7774 100644 --- a/sysdeps/unix/sysv/linux/poll.c +++ b/sysdeps/unix/sysv/linux/poll.c @@ -1,5 +1,5 @@ /* Poll system call, with emulation if it is not available. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 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 @@ -37,7 +37,7 @@ __poll (fds, nfds, timeout) unsigned long int nfds; int timeout; { - static int must_emulate = 0; + static int must_emulate; if (!must_emulate) { diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 0dd9c704af..cc8f9f0ee2 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -28,7 +28,7 @@ #include <stdio-common/_itoa.h> -char *__ttyname = NULL; +char *__ttyname; static char * getttyname __P ((const char *dev, dev_t mydev, ino_t myino, int save, int *dostat)) @@ -44,7 +44,7 @@ getttyname (dev, mydev, myino, save, dostat) int *dostat; { static char *name; - static size_t namelen = 0; + static size_t namelen; struct stat st; DIR *dirstream; struct dirent *d; @@ -106,7 +106,7 @@ ttyname (fd) int fd; { static char *buf; - static size_t buflen = 0; + static size_t buflen; char procname[30]; struct stat st, st1; int dostat = 0; diff --git a/termios/tcgetsid.c b/termios/tcgetsid.c index b83858f420..aab72f9a62 100644 --- a/termios/tcgetsid.c +++ b/termios/tcgetsid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999 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 @@ -30,9 +30,9 @@ tcgetsid (fd) pid_t pgrp; pid_t sid; #ifdef TIOCGSID - static int tiocgsid_works = 1; + static int tiocgsid_does_not_works; - if (tiocgsid_works) + if (! tiocgsid_does_not_works) { int serrno = errno; int sid; @@ -41,7 +41,7 @@ tcgetsid (fd) { if (errno == EINVAL) { - tiocgsid_works = 0; + tiocgsid_does_not_works = 1; __set_errno (serrno); } else diff --git a/time/getdate.c b/time/getdate.c index c25a49d5a1..9957411fd8 100644 --- a/time/getdate.c +++ b/time/getdate.c @@ -1,5 +1,5 @@ /* Convert a string representation of time to a time value. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. @@ -42,7 +42,7 @@ static int check_mday (int year, int mon, int mday); 8 invalid input specification Example: February 31 or a time is specified that can not be represented in a time_t (representing the time in seconds since 00:00:00 UTC, January 1, 1970) */ -int getdate_err = 0; +int getdate_err; /* Returns the first weekday WDAY of month MON in the year YEAR. */ diff --git a/time/tzfile.c b/time/tzfile.c index cfbdae6886..6681f9a66c 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -27,7 +27,7 @@ #define NOID #include <timezone/tzfile.h> -int __use_tzfile = 0; +int __use_tzfile; struct ttinfo { @@ -48,15 +48,15 @@ static struct ttinfo *find_transition (time_t timer) internal_function; static void compute_tzname_max (size_t) internal_function; static size_t num_transitions; -static time_t *transitions = NULL; -static unsigned char *type_idxs = NULL; +static time_t *transitions; +static unsigned char *type_idxs; static size_t num_types; -static struct ttinfo *types = NULL; -static char *zone_names = NULL; +static struct ttinfo *types; +static char *zone_names; static long int rule_stdoff; static long int rule_dstoff; static size_t num_leaps; -static struct leap *leaps = NULL; +static struct leap *leaps; #include <endian.h> #include <byteswap.h> @@ -84,7 +84,7 @@ decode (const void *ptr) } void -__tzfile_read (const char *file) +__tzfile_read (const char *file, size_t extra, char **extrap) { static const char default_tzdir[] = TZDIR; size_t num_isstd, num_isgmt; @@ -92,24 +92,15 @@ __tzfile_read (const char *file) struct tzhead tzhead; size_t chars; register size_t i; + size_t total_size; + size_t types_idx; + size_t leaps_idx; __use_tzfile = 0; if (transitions != NULL) free ((void *) transitions); transitions = NULL; - if (type_idxs != NULL) - free ((void *) type_idxs); - type_idxs = NULL; - if (types != NULL) - free ((void *) types); - types = NULL; - if (zone_names != NULL) - free ((void *) zone_names); - zone_names = NULL; - if (leaps != NULL) - free ((void *) leaps); - leaps = NULL; if (file == NULL) /* No user specification; use the site-wide default. */ @@ -151,7 +142,7 @@ __tzfile_read (const char *file) new = (char *) __alloca (tzdir_len + 1 + len); tmp = __mempcpy (new, tzdir, tzdir_len); *tmp++ = '/'; - __mempcpy (tmp, file, len); + memcpy (tmp, file, len); file = new; } @@ -169,41 +160,48 @@ __tzfile_read (const char *file) num_isstd = (size_t) decode (tzhead.tzh_ttisstdcnt); num_isgmt = (size_t) decode (tzhead.tzh_ttisgmtcnt); - if (num_transitions > 0) - { - transitions = (time_t *) malloc (num_transitions * sizeof (time_t)); - if (transitions == NULL) - goto lose; - type_idxs = (unsigned char *) malloc (num_transitions); - if (type_idxs == NULL) - goto lose; - } - if (num_types > 0) - { - types = (struct ttinfo *) malloc (num_types * sizeof (struct ttinfo)); - if (types == NULL) - goto lose; - } - if (chars > 0) + total_size = num_transitions * (sizeof (time_t) + 1); + total_size = ((total_size + __alignof__ (struct ttinfo) - 1) + & ~(__alignof__ (struct ttinfo) - 1)); + types_idx = total_size; + total_size += num_types * sizeof (struct ttinfo) + chars; + total_size = ((total_size + __alignof__ (struct leap) - 1) + & ~(__alignof__ (struct leap) - 1)); + leaps_idx = total_size; + total_size += num_leaps * sizeof (struct leap); + /* This is for the extra memory required by the caller. */ + total_size += extra; + + transitions = (time_t *) malloc (total_size); + if (transitions == NULL) + goto lose; + + type_idxs = (unsigned char *) transitions + (num_transitions + * sizeof (time_t)); + types = (struct ttinfo *) ((char *) transitions + types_idx); + zone_names = (char *) types + num_types * sizeof (struct ttinfo); + leaps = (struct leap *) ((char *) transitions + leaps_idx); + if (extra > 0) + *extrap = (char *) &leaps[num_leaps]; + + if (sizeof (time_t) < 4) + abort (); + + if (sizeof (time_t) == 4) { - zone_names = (char *) malloc (chars); - if (zone_names == NULL) + if (fread_unlocked (transitions, 1, (4 + 1) * num_transitions, f) + != (4 + 1) * num_transitions) goto lose; } - if (num_leaps > 0) + else { - leaps = (struct leap *) malloc (num_leaps * sizeof (struct leap)); - if (leaps == NULL) + if (fread_unlocked (transitions, 4, num_transitions, f) + != num_transitions + || fread_unlocked (type_idxs, 1, num_transitions, f) + != num_transitions) goto lose; } - if (sizeof (time_t) < 4) - abort (); - - if (fread_unlocked (transitions, 4, num_transitions, f) != num_transitions - || fread_unlocked (type_idxs, 1, num_transitions, f) != num_transitions) - goto lose; - /* Check for bogus indices in the data file, so we can hereafter safely use type_idxs[T] as indices into `types' and never crash. */ for (i = 0; i < num_transitions; ++i) @@ -224,14 +222,17 @@ __tzfile_read (const char *file) for (i = 0; i < num_types; ++i) { unsigned char x[4]; - if (fread_unlocked (x, 1, 4, f) != 4 - || fread_unlocked (&types[i].isdst, 1, 1, f) != 1 - || fread_unlocked (&types[i].idx, 1, 1, f) != 1) + int c; + if (fread_unlocked (x, 1, sizeof (x), f) != sizeof (x)) goto lose; - if (types[i].isdst > 1) + c = getc_unlocked (f); + if ((unsigned int) c > 1u) goto lose; - if (types[i].idx >= chars) /* Bogus index in data file. */ + types[i].isdst = c; + c = getc_unlocked (f); + if ((size_t) c > chars) /* Bogus index in data file. */ goto lose; + types[i].idx = c; types[i].offset = (long int) decode (x); } @@ -354,10 +355,13 @@ void __tzfile_default (const char *std, const char *dst, long int stdoff, long int dstoff) { - size_t stdlen, dstlen, i; + size_t stdlen = strlen (std) + 1; + size_t dstlen = strlen (dst) + 1; + size_t i; int isdst; + char *cp; - __tzfile_read (TZDEFRULES); + __tzfile_read (TZDEFRULES, stdlen + dstlen, &cp); if (!__use_tzfile) return; @@ -367,19 +371,10 @@ __tzfile_default (const char *std, const char *dst, return; } - /* Ignore the zone names read from the file. */ - free (zone_names); - - /* Use the names the user specified. */ - stdlen = strlen (std) + 1; - dstlen = strlen (dst) + 1; - zone_names = malloc (stdlen + dstlen); - if (zone_names == NULL) - { - __use_tzfile = 0; - return; - } - __mempcpy (__mempcpy (zone_names, std, stdlen), dst, dstlen); + /* Ignore the zone names read from the file and use the given ones + instead. */ + __mempcpy (__mempcpy (cp, std, stdlen), dst, dstlen); + zone_names = cp; /* Now there are only two zones, regardless of what the file contained. */ num_types = 2; @@ -554,3 +549,14 @@ compute_tzname_max (size_t chars) } while (++p < &zone_names[chars]); } + +/* This function is only called when we are checking for memory leaks. */ +static void +freeres (void) +{ + if (transitions != NULL) + free ((void *) transitions); +} + +/* Make sure all allocated data is freed before exiting. */ +text_set_element (__libc_subfreeres, freeres); diff --git a/time/tzset.c b/time/tzset.c index d6d1b2089a..24624fa188 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98,99 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 @@ -121,7 +121,7 @@ __tzstring (const char *s) return new->data; } -static char *old_tz = NULL; +static char *old_tz; /* Interpret the TZ envariable. */ static void @@ -129,7 +129,7 @@ internal_function tzset_internal (always) int always; { - static int is_initialized = 0; + static int is_initialized; register const char *tz; register size_t l; char *tzbuf; @@ -169,7 +169,7 @@ tzset_internal (always) old_tz = tz ? __strdup (tz) : NULL; /* Try to read a data file. */ - __tzfile_read (tz); + __tzfile_read (tz, 0, NULL); if (__use_tzfile) return; diff --git a/wcsmbs/wcsmbsload.c b/wcsmbs/wcsmbsload.c index 725652d656..b16aa6c500 100644 --- a/wcsmbs/wcsmbsload.c +++ b/wcsmbs/wcsmbsload.c @@ -46,6 +46,11 @@ static struct gconv_step to_wc = fct: __gconv_transform_ascii_internal, init_fct: NULL, end_fct: NULL, + min_needed_from: 1, + max_needed_from: 1, + min_needed_to: 4, + max_needed_to: 4, + stateful: 0, data: NULL }; @@ -59,6 +64,11 @@ static struct gconv_step to_mb = fct: __gconv_transform_internal_ascii, init_fct: NULL, end_fct: NULL, + min_needed_from: 4, + max_needed_from: 4, + min_needed_to: 1, + max_needed_to: 1, + stateful: 0, data: NULL }; diff --git a/wcsmbs/wmemset.c b/wcsmbs/wmemset.c index 42ff55b009..c0812cf616 100644 --- a/wcsmbs/wmemset.c +++ b/wcsmbs/wmemset.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Ulrich Dreppere <drepper@gnu.ai.mit.edu>, 1996. + Contributed by Ulrich Drepper <drepper@gnu.org>, 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 @@ -40,16 +40,16 @@ wmemset (s, c, n) if (n > 0) { - *wp++ = c; - --n; - } - if (n > 0) - { - *wp++ = c; - --n; + wp[0] = c; + + if (n > 1) + { + wp[1] = c; + + if (n > 2) + wp[2] = c; + } } - if (n > 0) - *wp = c; return s; } |