diff options
38 files changed, 731 insertions, 120 deletions
diff --git a/ChangeLog b/ChangeLog index 6d8eea5ae4..dc3e0391b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,86 @@ +2006-08-07 Jakub Jelinek <jakub@redhat.com> + Ulrich Drepper <drepper@redhat.com> + + * nis/nis_call.c (rec_dirsearch) [case LOWER_NAME]: Don't take + short cut if only one name component is stripped away. + +2006-08-07 Ulrich Drepper <drepper@redhat.com> + + * nis/nis_call.c: Minor cleanups throughout. + (rec_dirsearch) [HIGHER_NAME]: Correctly size ndomain array. + (first_shoot): Add search_parent_first parameter. Only if it is set + search parent server first. + If directory for table found through cold start cache is not the same + as referenced in the cache, don't use it. + (__nisfind_server): Take additional parameter. Pass it on to + first_shoot. + (__prepare_niscall): Adjust __nisfind_server call. + * nis/rpcsvc/nislib.h: Adjust __nisfind_server prototype. + * nis/nis_table.c: Adjust __nisfind_server call. + * nis/nis_lookup.c: Likewise. + (nis_lookup): Don't loop endlessly if name is reduced to ".". + +2006-08-03 Ulrich Drepper <drepper@redhat.com> + + [BZ #2182] + * math/s_cacosh.c: Return values from positive branch. + * math/s_cacoshf.c: Likewise. + * math/s_cacoshl.c: Likewise. + + [BZ #2883] + * sysvipc/sys/msg.h: Change return value to ssize_t. + * sysdeps/unix/sysv/linux/msgrcv.c: Likewise. + * sysvipc/msgrcv.c: Likewise. + * include/sys/msg.h: Likewise. + + * grp/initgroups.c (internal_getgrouplist): Remove unnecessary + test introduced in patch for bz #661. + (getgrouplist): Simplify code a bit. Don't allocate one additional + element for NEWGROUPS. + + [BZ #2908] + * stdio-common/printf_fphex.c (__printf_fphex): When rounding up + 'f', use '1' as leading digit not '\1'. + * stdio-common/Makefile (tests): Add bug16. + * stdio-common/bug16.c: New file. + + [BZ #2914] + * sysdeps/unix/sysv/linux/gethostid.c: Don't define OLD_HOSTIDFILE + and don't try to open it. The patch introducing the macro + contained a bug and used the same file name as the new file + instead of using /var/adm/hostid. Nobody complaint so I'm taking + this out completely. + + [BZ #2926] + * assert/assert.h: Move cast to void inside ?: to quiet gcc. + Patch by Jerry James <Jerry.James@usu.edu>. + + * rt/Makefile (tests): Add tst-clock2. + * rt/tst-clock2.c: New file. + + [BZ #2978] + * resolv/gai_notify.c (__gai_notify_only): Copy memory for thread + function and its parameters and pass it to new thread. + (__gai_notify): Add support for alternative waiting for completion. + * resolv/gai_suspend.c (gai_suspend): Add support for alternative + waiting for completion. + * resolv/getaddrinfo_a.c: Likewise. + * resolv/gai_misc.h (struct waitlist): Don't add cond if alternative + waiting for completion is used. + * resolv/gai_misc.c: Allow overwriting code to start helper thread. + * resolv/gai_cancel.c: Include <gai_misc.h> not "gai_misc.h". + * resolv/gai_error.c: Likewise. + * resolv/gai_sigqueue.c: Likewise. + +2006-08-02 Thomas Schwinge <tschwinge@gnu.org> + + * hurd/getdport.c (__getdport): Don't return EBADF; instead set + errno to EBADF and return MACH_PORT_NULL. + 2006-06-23 Joseph Myers <joseph@codesourcery.com> [BZ #2980] - * posix/Makefile (CFLAGS-waitid.c): Add - -fasynchronous-unwind-tables. + * posix/Makefile (CFLAGS-waitid.c): Add -fasynchronous-unwind-tables. 2006-08-02 Ulrich Drepper <drepper@redhat.com> @@ -11,6 +89,7 @@ 2006-08-01 Ulrich Drepper <drepper@redhat.com> + [BZ #2098] * nscd/initgrcache.c (addinitgroupsX): Judge successful lookups by status of NSS calls, not the number of returned entries. diff --git a/assert/assert.h b/assert/assert.h index 2f83146274..7c8ae4845d 100644 --- a/assert/assert.h +++ b/assert/assert.h @@ -84,16 +84,18 @@ extern void __assert (const char *__assertion, const char *__file, int __line) __END_DECLS -# define assert(expr) \ - (__ASSERT_VOID_CAST ((expr) ? 0 : \ - (__assert_fail (__STRING(expr), __FILE__, __LINE__, \ - __ASSERT_FUNCTION), 0))) +# define assert(expr) \ + ((expr) \ + ? __ASSERT_VOID_CAST (0) \ + : (__assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION), \ + __ASSERT_VOID_CAST (0))) # ifdef __USE_GNU -# define assert_perror(errnum) \ - (__ASSERT_VOID_CAST (!(errnum) ? 0 : \ - (__assert_perror_fail ((errnum), __FILE__, __LINE__, \ - __ASSERT_FUNCTION), 0))) +# define assert_perror(errnum) \ + (!(errnum) \ + ? __ASSERT_VOID_CAST (0) \ + : (__assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION), \ + __ASSERT_VOID_CAST (0))) # endif /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' diff --git a/fedora/branch.mk b/fedora/branch.mk index 502adadffb..5c2c1cdbd4 100644 --- a/fedora/branch.mk +++ b/fedora/branch.mk @@ -3,5 +3,5 @@ glibc-branch := fedora glibc-base := HEAD DIST_BRANCH := devel COLLECTION := dist-fc4 -fedora-sync-date := 2006-08-02 18:08 UTC -fedora-sync-tag := fedora-glibc-20060802T1808 +fedora-sync-date := 2006-08-07 18:59 UTC +fedora-sync-tag := fedora-glibc-20060807T1859 diff --git a/fedora/glibc.spec.in b/fedora/glibc.spec.in index 67a6b71b7e..ba46724e32 100644 --- a/fedora/glibc.spec.in +++ b/fedora/glibc.spec.in @@ -1,4 +1,4 @@ -%define glibcrelease 17 +%define glibcrelease 18 %define auxarches i586 i686 athlon sparcv9 alphaev6 %define xenarches i686 athlon %ifarch %{xenarches} @@ -1438,6 +1438,8 @@ rm -f *.filelist* %endif %changelog +* Mon Aug 7 2006 Jakub Jelinek <jakub@redhat.com> 2.4.90-18 +- NIS+ fixes - fix memusage and xtrace scripts (#200736) - redirect /sbin/service sshd condrestart std{out,err} to /dev/null when executed from glibc_post_upgrade diff --git a/grp/initgroups.c b/grp/initgroups.c index b887a973ff..2e489463df 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1989,91,93,1996-2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1989,91,93,1996-2005,2006 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 @@ -17,6 +17,7 @@ 02111-1307 USA. */ #include <alloca.h> +#include <assert.h> #include <errno.h> #include <grp.h> #include <limits.h> @@ -74,8 +75,8 @@ internal_getgrouplist (const char *user, gid_t group, long int *size, long int start = 1; /* Never store more than the starting *SIZE number of elements. */ - if (*size > 0) - (*groupsp)[0] = group; + assert (*size > 0); + (*groupsp)[0] = group; if (__nss_group_database != NULL) { @@ -142,11 +143,9 @@ internal_getgrouplist (const char *user, gid_t group, long int *size, int getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) { - gid_t *newgroups; long int size = MAX (1, *ngroups); - int result; - newgroups = (gid_t *) malloc ((size + 1) * sizeof (gid_t)); + gid_t *newgroups = (gid_t *) malloc (size * sizeof (gid_t)); if (__builtin_expect (newgroups == NULL, 0)) /* No more memory. */ // XXX This is wrong. The user provided memory, we have to use @@ -155,20 +154,16 @@ getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) // XXX too small. For initgroups a flag could say: increase size. return -1; - result = internal_getgrouplist (user, group, &size, &newgroups, -1); - - memcpy (groups, newgroups, MIN (*ngroups, result) * sizeof (gid_t)); + int total = internal_getgrouplist (user, group, &size, &newgroups, -1); - if (result > *ngroups) - { - *ngroups = result; - result = -1; - } - else - *ngroups = result; + memcpy (groups, newgroups, MIN (*ngroups, total) * sizeof (gid_t)); free (newgroups); - return result; + + int retval = total > *ngroups ? -1 : total; + *ngroups = total; + + return retval; } static_link_warning (getgrouplist) diff --git a/hurd/getdport.c b/hurd/getdport.c index eeb5a8689e..41567d5fe1 100644 --- a/hurd/getdport.c +++ b/hurd/getdport.c @@ -35,8 +35,11 @@ __getdport (int fd) so we don't bother allocating a real table. */ if (_hurd_init_dtable == NULL) - /* Never had a descriptor table. */ - return EBADF; + { + /* Never had a descriptor table. */ + errno = EBADF; + return MACH_PORT_NULL; + } if (fd < 0 || (unsigned int) fd > _hurd_init_dtablesize || _hurd_init_dtable[fd] == MACH_PORT_NULL) diff --git a/include/sys/msg.h b/include/sys/msg.h index 02bb9aefd0..03e17f915e 100644 --- a/include/sys/msg.h +++ b/include/sys/msg.h @@ -1,8 +1,8 @@ #ifndef _SYS_MSG_H #include <sysvipc/sys/msg.h> -extern int __libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, - int msgflg); +extern ssize_t __libc_msgrcv (int msqid, void *msgp, size_t msgsz, + long int msgtyp, int msgflg); extern int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg); diff --git a/localedata/ChangeLog b/localedata/ChangeLog index b58c0c09f9..76129512b6 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,18 @@ +2006-06-03 Eddy Petrisor <eddy.petrisor@gmail.com> + + [BZ #2125] + * locales/ro_RO: Fix collation rules for <U0218> and <U021A>. + Define first_weekday, first_workdayweek_day, work_day, + country_isbn and country_post fields. + Comments for terminology and bibliographic codes were added. + +2006-08-03 Ulrich Drepper <drepper@redhat.com> + + * SUPPORTED (SUPPORTED-LOCALES): Add csb_PL.UTF-8. + + [BZ #2961] + * locales/csb_PL: New file. + 2006-08-01 Ulrich Drepper <drepper@redhat.com> * locales/es_NI: Define real t_fmt_ampm and am_pm. diff --git a/localedata/SUPPORTED b/localedata/SUPPORTED index e06ce3a768..cd6d91710c 100644 --- a/localedata/SUPPORTED +++ b/localedata/SUPPORTED @@ -72,6 +72,7 @@ ca_IT.UTF-8/UTF-8 \ ca_IT/ISO-8859-15 \ cs_CZ.UTF-8/UTF-8 \ cs_CZ/ISO-8859-2 \ +csb_PL/UTF-8 \ cy_GB.UTF-8/UTF-8 \ cy_GB/ISO-8859-14 \ da_DK.UTF-8/UTF-8 \ diff --git a/localedata/locales/csb_PL b/localedata/locales/csb_PL new file mode 100644 index 0000000000..663fd6cf8d --- /dev/null +++ b/localedata/locales/csb_PL @@ -0,0 +1,210 @@ +comment_char % +escape_char / +% +% Kashubian Language Locale for Poland +% Source: csb_PL locale +% Contact: Michal Ostrowski +% Email: ostrowski.michal@gmail.com +% Tel: +48586717262 +% Fax: none +% Language: csb +% Territory: PL +% Revision: 1.0 +% Date: 2006-07-25 +% Application: general +% Users: general +% Charset: UTF-8 +% Distribution and use is free, also +% for commercial purposes. + +LC_IDENTIFICATION +title "Kashubian locale for Poland" +source "csb_PL locale" +address "" +contact "Michal Ostrowski" +email "bug-glibc-locales@gnu.org" +tel "" +fax "" +language "Kashubian" +territory "Poland" +revision "1.0" +date "2006-07-25" +audience "general" +application "GNU locale" +abbreviation "" +% +category "csb_PL:2000";LC_IDENTIFICATION +category "csb_PL:2000";LC_CTYPE +category "csb_PL:2000";LC_COLLATE +category "csb_PL:2000";LC_TIME +category "csb_PL:2000";LC_NUMERIC +category "csb_PL:2000";LC_MONETARY +category "csb_PL:2000";LC_MESSAGES +category "csb_PL:2000";LC_PAPER +category "csb_PL:2000";LC_NAME +category "csb_PL:2000";LC_ADDRESS +category "csb_PL:2000";LC_TELEPHONE + +END LC_IDENTIFICATION + +LC_CTYPE +copy "pl_PL" +END LC_CTYPE + +LC_COLLATE +copy "iso14651_t1" + +collating-symbol <aogonek> +collating-symbol <atilde> +collating-symbol <eacute> +collating-symbol <ediaeresis> +collating-symbol <lstroke> +collating-symbol <nacute> +collating-symbol <ograve> +collating-symbol <oacute> +collating-symbol <ocircumflex> +collating-symbol <ugrave> +collating-symbol <zdot> + +reorder-after <a> +<aogonek> +<atilde> + +reorder-after <e> +<eacute> +<ediaeresis> + +reorder-after <l> +<lstroke> + +reorder-after <n> +<nacute> + +reorder-after <o> +<ograve> +<oacute> +<ocircumflex> + +reorder-after <u> +<ugrave> + +reorder-after <z> +<zdot> + +reorder-after <U0061> +<U0105> <aogonek>;<BAS>;<MIN>;IGNORE +<U0104> <aogonek>;<BAS>;<CAP>;IGNORE +<U00E3> <atilde>;<BAS>;<MIN>;IGNORE +<U00C3> <atilde>;<BAS>;<CAP>;IGNORE + +reorder-after <U0065> +<U00E9> <eacute>;<BAS>;<MIN>;IGNORE +<U00C9> <eacute>;<BAS>;<CAP>;IGNORE +<U00EB> <ediaeresis>;<BAS>;<MIN>;IGNORE +<U00CB> <ediaeresis>;<BAS>;<CAP>;IGNORE + +reorder-after <U006C> +<U0142> <lstroke>;<BAS>;<MIN>;IGNORE +<U0141> <lstroke>;<BAS>;<CAP>;IGNORE + +reorder-after <U006E> +<U0144> <nacute>;<BAS>;<MIN>;IGNORE +<U0143> <nacute>;<BAS>;<CAP>;IGNORE + +reorder-after <U006F> +<U00F2> <ograve>;<BAS>;<MIN>;IGNORE +<U00D2> <ograve>;<BAS>;<CAP>;IGNORE +<U00F3> <oacute>;<BAS>;<MIN>;IGNORE +<U00D3> <oacute>;<BAS>;<CAP>;IGNORE +<U00F4> <ocircumflex>;<BAS>;<MIN>;IGNORE +<U00D4> <ocircumflex>;<BAS>;<CAP>;IGNORE + +reorder-after <U0075> +<U00F9> <ugrave>;<BAS>;<MIN>;IGNORE +<U00D9> <ugrave>;<BAS>;<CAP>;IGNORE + +reorder-after <U007A> +<U017C> <zdot>;<BAS>;<MIN>;IGNORE +<U017B> <zdot>;<BAS>;<CAP>;IGNORE + +reorder-end + +END LC_COLLATE + +LC_MESSAGES +yesexpr "<U005E><U005B><U004A><U006A><U0054><U0074><U0059><U0079><U005D><U002E><U002A>" +noexpr "<U005E><U005B><U006E><U004E><U005D><U002E><U002A>" + +END LC_MESSAGES + +LC_MONETARY +copy "pl_PL" +END LC_MONETARY + +LC_NUMERIC +copy "pl_PL" +END LC_NUMERIC + +LC_TIME +abday "<U006E><U0069><U0065>"; "<U0070><U00F2><U006E>";/ + "<U0077><U0074><U00F3>"; "<U0073><U0074><U0072>";/ + "<U0063><U007A><U0077>"; "<U0070><U0069><U0105>";/ + "<U0073><U006F><U0062>" + +day "<U006E><U0069><U0065><U0064><U007A><U0065><U006C><U0061>";/ + "<U0070><U00F2><U006E><U0069><U0065><U0064><U007A><U00F4><U0142><U006B>";/ + "<U0077><U0074><U00F3><U0072><U006B>";/ + "<U0073><U0074><U0072><U007A><U006F><U0064><U0061>";/ + "<U0063><U007A><U0077><U0069><U00F4><U0072><U0074><U006B>";/ + "<U0070><U0069><U0105><U0074><U006B>";/ + "<U0073><U006F><U0062><U00F2><U0074><U0061>" +abmon "<U0073><U0074><U00EB>"; "<U0067><U0072><U006F>";/ + "<U0073><U0074><U006D>"; "<U0142><U017C><U00EB>";/ + "<U006D><U00F4><U006A>"; "<U0063><U007A><U0065>";/ + "<U006C><U00EB><U0070>"; "<U007A><U00E9><U006C>";/ + "<U0073><U00E9><U0077>"; "<U0072><U0075><U006A>";/ + "<U006C><U00EB><U0073>"; "<U0067><U00F2><U0064>" +mon "<U0073><U0074><U00EB><U0063><U007A><U006E><U0069><U006B>";/ + "<U0067><U0072><U006F><U006D><U0069><U0063><U007A><U006E><U0069><U006B>";/ + "<U0073><U0074><U0072><U0075><U006D><U0069><U0061><U006E><U006E><U0069><U006B>";/ + "<U0142><U017C><U00EB><U006B><U0077><U0069><U00F4><U0074>";/ + "<U006D><U00F4><U006A>";/ + "<U0063><U007A><U0065><U0072><U0077><U0069><U0144><U0063>";/ + "<U006C><U00EB><U0070><U0069><U006E><U0063>";/ + "<U007A><U00E9><U006C><U006E><U0069><U006B>";/ + "<U0073><U00E9><U0077><U006E><U0069><U006B>";/ + "<U0072><U0075><U006A><U0061><U006E>";/ + "<U006C><U00EB><U0073><U0074><U006F><U0070><U0061><U0064><U006E><U0069><U006B>";/ + "<U0067><U00F2><U0064><U006E><U0069><U006B>" +d_t_fmt "<U0025><U0061><U0020><U0025><U0064><U0020><U0025><U0062><U0020><U0025><U0059><U0020><U0025><U0054><U0020><U0025><U005A>" +d_fmt "<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064>" +t_fmt "<U0025><U0054>" +am_pm "";"" +t_fmt_ampm "" +date_fmt "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065>/ +<U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/ +<U0025><U005A><U0020><U0025><U0059>" +week 7;19971201;4 +first_weekday 2 +first_workday 2 +END LC_TIME + +LC_PAPER +copy "pl_PL" +END LC_PAPER + +LC_TELEPHONE +copy "pl_PL" +END LC_TELEPHONE + +LC_MEASUREMENT +copy "pl_PL" +END LC_MEASUREMENT + +LC_NAME +copy "pl_PL" +END LC_NAME + +LC_ADDRESS +copy "pl_PL" +END LC_ADDRESS diff --git a/localedata/locales/ro_RO b/localedata/locales/ro_RO index f258b7b6be..210d7f81b2 100644 --- a/localedata/locales/ro_RO +++ b/localedata/locales/ro_RO @@ -94,14 +94,14 @@ reorder-after <U0073> <U0219> <s,>;<CDI>;<MIN>;IGNORE <U015F> <s,>;<CDI>;<MIN>;IGNORE reorder-after <U0053> -<U0218> <s,>;<CDI>;<MIN>;IGNORE +<U0218> <s,>;<CDI>;<CAP>;IGNORE <U015E> <s,>;<CDI>;<CAP>;IGNORE reorder-after <U0074> <U021B> <t,>;<CDI>;<MIN>;IGNORE <U0163> <t,>;<CDI>;<MIN>;IGNORE reorder-after <U0054> -<U021A> <t,>;<CDI>;<MIN>;IGNORE +<U021A> <t,>;<CDI>;<CAP>;IGNORE <U0162> <t,>;<CDI>;<CAP>;IGNORE reorder-end @@ -266,6 +266,10 @@ t_fmt_ampm "" date_fmt "<U0025><U0041><U0020><U0025><U002D><U0065><U0020><U0025><U0042>/ <U0020><U0025><U0059><U002C><U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/ <U0025><U007A>" +% First week day is Monday +first_weekday 2 +% First work day is Monday +first_workday 2 END LC_TIME @@ -369,9 +373,18 @@ country_ab2 "<U0052><U004F>" country_ab3 "<U0052><U004F><U0055>" country_num 642 country_car "<U0052><U004F>" +% ISBN code is 973 +% see: http://homepages.cwi.nl/~dik/english/codes/isbn.html +% and other sources +country_isbn 973 +% FIXME: is it really RO? +country_post "<U0052><U004F>" % language names are not capitalized in Romanian ( roma>na( ) lang_name "<U0072><U006F><U006D><U00E2><U006E><U0103>" lang_ab "<U0072><U006F>" +% set the terminology code to "ron" as defined in iso639-2 lang_term "<U0072><U006F><U006E>" +% set the bibliographic code to "rum" as defined in iso639-2 lang_lib "<U0072><U0075><U006D>" END LC_ADDRESS + diff --git a/math/s_cacosh.c b/math/s_cacosh.c index e921f0763e..ada7ca5af6 100644 --- a/math/s_cacosh.c +++ b/math/s_cacosh.c @@ -80,6 +80,10 @@ __cacosh (__complex__ double x) __imag__ y += __imag__ x; res = __clog (y); + + /* We have to use the positive branch. */ + if (__real__ res < 0.0) + res = -res; } return res; diff --git a/math/s_cacoshf.c b/math/s_cacoshf.c index 3fc48bb617..a062ffc6f6 100644 --- a/math/s_cacoshf.c +++ b/math/s_cacoshf.c @@ -95,6 +95,10 @@ __cacoshf (__complex__ float x) + ro); __imag__ res = __ieee754_atan2f (__imag__ x + b, __real__ x + a); #endif + + /* We have to use the positive branch. */ + if (__real__ res < 0.0) + res = -res; } return res; diff --git a/math/s_cacoshl.c b/math/s_cacoshl.c index 643858920e..da23c8d8aa 100644 --- a/math/s_cacoshl.c +++ b/math/s_cacoshl.c @@ -80,6 +80,10 @@ __cacoshl (__complex__ long double x) __imag__ y += __imag__ x; res = __clogl (y); + + /* We have to use the positive branch. */ + if (__real__ res < 0.0) + res = -res; } return res; diff --git a/nis/nis_call.c b/nis/nis_call.c index f8f00d8c82..928053daf5 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -38,12 +38,12 @@ static const struct timeval UDPTIMEOUT = {5, 0}; extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program, u_long version, u_int protocol); -unsigned long +unsigned long int inetstr2int (const char *str) { size_t j = 0; for (size_t i = 0; str[i] != '\0'; ++i) - if (str[i] == '.' && ++j == 4) + if (str[i] == '.' && __builtin_expect (++j == 4, 0)) { char buffer[i + 1]; buffer[i] = '\0'; @@ -68,8 +68,6 @@ libnsl_hidden_def (__nisbind_destroy) nis_error __nisbind_next (dir_binding *bind) { - u_int j; - if (bind->clnt != NULL) { if (bind->use_auth) @@ -81,7 +79,7 @@ __nisbind_next (dir_binding *bind) if (bind->trys >= bind->server_len) return NIS_FAIL; - for (j = bind->current_ep + 1; + for (u_int j = bind->current_ep + 1; j < bind->server_val[bind->server_used].ep.ep_len; ++j) if (strcmp (bind->server_val[bind->server_used].ep.ep_val[j].family, "inet") == 0) @@ -96,7 +94,7 @@ __nisbind_next (dir_binding *bind) if (bind->server_used >= bind->server_len) bind->server_used = 0; - for (j = 0; j < bind->server_val[bind->server_used].ep.ep_len; ++j) + for (u_int j = 0; j < bind->server_val[bind->server_used].ep.ep_len; ++j) if (strcmp (bind->server_val[bind->server_used].ep.ep_val[j].family, "inet") == 0) if (bind->server_val[bind->server_used].ep.ep_val[j].proto[0] == '-') @@ -125,7 +123,7 @@ __nisbind_connect (dir_binding *dbp) dbp->addr.sin_addr.s_addr = inetstr2int (serv->ep.ep_val[dbp->current_ep].uaddr); - if (dbp->addr.sin_addr.s_addr == 0) + if (dbp->addr.sin_addr.s_addr == INADDR_NONE) return NIS_FAIL; /* Check, if the host is online and rpc.nisd is running. Much faster @@ -340,7 +338,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status) case HIGHER_NAME: { /* We need data from a parent domain */ directory_obj *obj; - char ndomain [strlen (name) + 3]; + char ndomain[strlen (dir->do_name) + 3]; nis_domain_of_r (dir->do_name, ndomain, sizeof (ndomain)); @@ -388,7 +386,6 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status) char domain[namelen + 3]; char ndomain[namelen + 3]; char *cp; - u_int run = 0; strcpy (domain, name); @@ -402,16 +399,9 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status) nis_leaf_of_r (domain, leaf, sizeof (leaf)); nis_domain_of_r (domain, ndomain, sizeof (ndomain)); strcpy (domain, ndomain); - ++run; } while (nis_dir_cmp (domain, dir->do_name) != SAME_NAME); - if (run == 1) - { - /* We have found the directory above. Use it. */ - return dir; - } - cp = rawmemchr (leaf, '\0'); *cp++ = '.'; strcpy (cp, domain); @@ -461,31 +451,44 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, nis_error *status) /* We try to query the current server for the searched object, maybe he know about it ? */ static directory_obj * -first_shoot (const_nis_name name, directory_obj *dir) +first_shoot (const_nis_name name, int search_parent_first, directory_obj *dir) { directory_obj *obj = NULL; fd_result *fd_res; XDR xdrs; char domain[strlen (name) + 3]; +#if 0 if (nis_dir_cmp (name, dir->do_name) == SAME_NAME) return dir; +#endif - nis_domain_of_r (name, domain, sizeof (domain)); + const char *search_name = name; + if (search_parent_first) + { + nis_domain_of_r (name, domain, sizeof (domain)); + search_name = domain; + } - if (nis_dir_cmp (domain, dir->do_name) == SAME_NAME) + if (nis_dir_cmp (search_name, dir->do_name) == SAME_NAME) return dir; - fd_res = __nis_finddirectory (dir, domain); + fd_res = __nis_finddirectory (dir, search_name); if (fd_res == NULL) return NULL; if (fd_res->status == NIS_SUCCESS && (obj = calloc (1, sizeof (directory_obj))) != NULL) { - xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val, - fd_res->dir_data.dir_data_len, XDR_DECODE); + xdrmem_create (&xdrs, fd_res->dir_data.dir_data_val, + fd_res->dir_data.dir_data_len, XDR_DECODE); _xdr_directory_obj (&xdrs, obj); xdr_destroy (&xdrs); + + if (strcmp (dir->do_name, obj->do_name) != 0) + { + nis_free_directory (obj); + obj = NULL; + } } __free_fdresult (fd_res); @@ -497,7 +500,8 @@ first_shoot (const_nis_name name, directory_obj *dir) } nis_error -__nisfind_server (const_nis_name name, directory_obj **dir) +__nisfind_server (const_nis_name name, int search_parent_first, + directory_obj **dir) { if (name == NULL) return NIS_BADNAME; @@ -520,7 +524,7 @@ __nisfind_server (const_nis_name name, directory_obj **dir) return NIS_UNAVAIL; /* Try at first, if servers in "dir" know our object */ - obj = first_shoot (name, *dir); + obj = first_shoot (name, search_parent_first, *dir); if (obj == NULL) { obj = rec_dirsearch (name, *dir, &status); @@ -539,7 +543,7 @@ nis_error __prepare_niscall (const_nis_name name, directory_obj **dirp, dir_binding *bptrp, unsigned int flags) { - nis_error retcode = __nisfind_server (name, dirp); + nis_error retcode = __nisfind_server (name, 1, dirp); if (__builtin_expect (retcode != NIS_SUCCESS, 0)) return retcode; diff --git a/nis/nis_lookup.c b/nis/nis_lookup.c index c198376464..839ee4ee42 100644 --- a/nis/nis_lookup.c +++ b/nis/nis_lookup.c @@ -127,7 +127,7 @@ nis_lookup (const_nis_name name, const unsigned int flags) /* Otherwise __nisfind_server will not do anything. */ dir = NULL; - if (__nisfind_server (req.ns_name, &dir) + if (__nisfind_server (req.ns_name, 1, &dir) != NIS_SUCCESS) goto out; @@ -147,6 +147,11 @@ nis_lookup (const_nis_name name, const unsigned int flags) nis_domain_of_r (req.ns_name, ndomain, sizeof (ndomain)); req.ns_name = strdupa (ndomain); + if (strcmp (ndomain, ".") == 0) + { + NIS_RES_STATUS (res) = NIS_NAMEUNREACHABLE; + goto out; + } __nisbind_destroy (&bptr); nis_free_directory (dir); diff --git a/nis/nis_table.c b/nis/nis_table.c index 3213035067..a92a4b64ce 100644 --- a/nis/nis_table.c +++ b/nis/nis_table.c @@ -271,7 +271,8 @@ nis_list (const_nis_name name, unsigned int flags, memset (res, '\0', sizeof (nis_result)); - status = __nisfind_server (ibreq->ibr_name, &dir); + status = __nisfind_server (ibreq->ibr_name, + ibreq->ibr_srch.ibr_srch_val != NULL, &dir); if (status != NIS_SUCCESS) { NIS_RES_STATUS (res) = status; diff --git a/nis/rpcsvc/nislib.h b/nis/rpcsvc/nislib.h index a55de61830..c993bac5e8 100644 --- a/nis/rpcsvc/nislib.h +++ b/nis/rpcsvc/nislib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997. @@ -276,7 +276,8 @@ extern nis_error __nisbind_create (dir_binding *, const nis_server *, extern nis_error __nisbind_connect (dir_binding *) __THROW; extern nis_error __nisbind_next (dir_binding *) __THROW; extern void __nisbind_destroy (dir_binding *) __THROW; -extern nis_error __nisfind_server (const_nis_name, directory_obj **) __THROW; +extern nis_error __nisfind_server (const_nis_name, int, directory_obj **) + __THROW; #endif diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e9011be083..6450e42574 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,11 @@ +2006-08-03 Ulrich Drepper <drepper@redhat.com> + + [BZ #2892] + * pthread_setspecific.c (__pthread_setspecific): Check + out-of-range index before checking for unused key. + + * sysdeps/pthread/gai_misc.h: New file. + 2006-08-01 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/i386/smp.h: New file. Old Linux-specific diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c index b6e66b5f22..152f5590e2 100644 --- a/nptl/pthread_setspecific.c +++ b/nptl/pthread_setspecific.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -52,8 +52,8 @@ __pthread_setspecific (key, value) } else { - if (KEY_UNUSED ((seq = __pthread_keys[key].seq)) - || key >= PTHREAD_KEYS_MAX) + if (key >= PTHREAD_KEYS_MAX + || KEY_UNUSED ((seq = __pthread_keys[key].seq))) /* Not valid. */ return EINVAL; diff --git a/nptl/sysdeps/pthread/gai_misc.h b/nptl/sysdeps/pthread/gai_misc.h new file mode 100644 index 0000000000..1dc351a2de --- /dev/null +++ b/nptl/sysdeps/pthread/gai_misc.h @@ -0,0 +1,119 @@ +/* Copyright (C) 2006 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* We define a special synchronization primitive for AIO. POSIX + conditional variables would be ideal but the pthread_cond_*wait + operations do not return on EINTR. This is a requirement for + correct aio_suspend and lio_listio implementations. */ + +#include <assert.h> +#include <signal.h> +#include <pthreadP.h> +#include <lowlevellock.h> + +#define DONT_NEED_GAI_MISC_COND 1 + +#define GAI_MISC_NOTIFY(waitlist) \ + do { \ + if (--*waitlist->counterp == 0) \ + lll_futex_wake (waitlist->counterp, 1); \ + } while (0) + +#define GAI_MISC_WAIT(result, futex, timeout, cancel) \ + do { \ + volatile int *futexaddr = &futex; \ + int oldval = futex; \ + \ + if (oldval != 0) \ + { \ + pthread_mutex_unlock (&__gai_requests_mutex); \ + \ + int oldtype; \ + if (cancel) \ + oldtype = LIBC_CANCEL_ASYNC (); \ + \ + int status; \ + do \ + { \ + status = lll_futex_timed_wait (futexaddr, oldval, timeout); \ + if (status != -EWOULDBLOCK) \ + break; \ + \ + oldval = *futexaddr; \ + } \ + while (oldval != 0); \ + \ + if (cancel) \ + LIBC_CANCEL_RESET (oldtype); \ + \ + if (status == -EINTR) \ + result = EINTR; \ + else if (status == -ETIMEDOUT) \ + result = EAGAIN; \ + else \ + assert (status == 0 || status == -EWOULDBLOCK); \ + \ + pthread_mutex_lock (&__gai_requests_mutex); \ + } \ + } while (0) + + +#define gai_start_notify_thread __gai_start_notify_thread +#define gai_create_helper_thread __gai_create_helper_thread + +extern inline void +__gai_start_notify_thread (void) +{ + sigset_t ss; + sigemptyset (&ss); + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8); +} + +extern inline int +__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), + void *arg) +{ + pthread_attr_t attr; + + /* Make sure the thread is created detached. */ + pthread_attr_init (&attr); + pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); + + /* The helper thread needs only very little resources. */ + (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); + + /* Block all signals in the helper thread. To do this thoroughly we + temporarily have to block all signals here. */ + sigset_t ss; + sigset_t oss; + sigfillset (&ss); + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8); + + int ret = pthread_create (threadp, &attr, tf, arg); + + /* Restore the signal mask. */ + INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL, + _NSIG / 8); + + (void) pthread_attr_destroy (&attr); + return ret; +} + +#include_next <gai_misc.h> diff --git a/resolv/gai_cancel.c b/resolv/gai_cancel.c index 45432065c4..19a0a9bb87 100644 --- a/resolv/gai_cancel.c +++ b/resolv/gai_cancel.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -20,7 +20,7 @@ #include <netdb.h> #include <pthread.h> -#include "gai_misc.h" +#include <gai_misc.h> int diff --git a/resolv/gai_error.c b/resolv/gai_error.c index 0620b04b9d..4c91628a62 100644 --- a/resolv/gai_error.c +++ b/resolv/gai_error.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -19,7 +19,7 @@ #include <netdb.h> -#include "gai_misc.h" +#include <gai_misc.h> int gai_error (struct gaicb *req) diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c index b3334f38ef..2eec0f529d 100644 --- a/resolv/gai_misc.c +++ b/resolv/gai_misc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -23,10 +23,31 @@ #include <stdlib.h> #include <sys/time.h> -#include "gai_misc.h" +#include <gai_misc.h> +#ifndef gai_create_helper_thread +# define gai_create_helper_thread __gai_create_helper_thread + +extern inline int +__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), + void *arg) +{ + pthread_attr_t attr; + + /* Make sure the thread is created detached. */ + pthread_attr_init (&attr); + pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); + + int ret = pthread_create (threadp, &attr, tf, arg); + + (void) pthread_attr_destroy (&attr); + return ret; +} +#endif + + /* Pool of request list entries. */ static struct requestlist **pool; @@ -229,16 +250,11 @@ __gai_enqueue_request (struct gaicb *gaicbp) if (nthreads < optim.gai_threads && idle_thread_count == 0) { pthread_t thid; - pthread_attr_t attr; newp->running = 1; - /* Make sure the thread is created detached. */ - pthread_attr_init (&attr); - pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); - /* Now try to start a thread. */ - if (pthread_create (&thid, &attr, handle_requests, newp) == 0) + if (gai_create_helper_thread (&thid, handle_requests, newp) == 0) /* We managed to enqueue the request. All errors which can happen now can be recognized by calls to `gai_error'. */ ++nthreads; diff --git a/resolv/gai_misc.h b/resolv/gai_misc.h index 48a93977ae..94005de02c 100644 --- a/resolv/gai_misc.h +++ b/resolv/gai_misc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -29,7 +29,9 @@ struct waitlist { struct waitlist *next; +#ifndef DONT_NEED_GAI_MISC_COND pthread_cond_t *cond; +#endif volatile int *counterp; /* The next field is used in asynchronous `lio_listio' operations. */ struct sigevent *sigevp; diff --git a/resolv/gai_notify.c b/resolv/gai_notify.c index 987a64c0e2..c3ce0afb45 100644 --- a/resolv/gai_notify.c +++ b/resolv/gai_notify.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -20,15 +20,24 @@ #include <netdb.h> #include <pthread.h> #include <stdlib.h> +#include <gai_misc.h> -#include "gai_misc.h" +struct notify_func + { + void (*func) (sigval_t); + sigval_t value; + }; static void * notify_func_wrapper (void *arg) { - struct sigevent *sigev = arg; - sigev->sigev_notify_function (sigev->sigev_value); + gai_start_notify_thread (); + struct notify_func *const n = arg; + void (*func) (sigval_t) = n->func; + sigval_t value = n->value; + free (n); + (*func) (value); return NULL; } @@ -54,8 +63,26 @@ __gai_notify_only (struct sigevent *sigev, pid_t caller_pid) pattr = &attr; } - if (pthread_create (&tid, pattr, notify_func_wrapper, sigev) < 0) + /* SIGEV may be freed as soon as we return, so we cannot let the + notification thread use that pointer. Even though a sigval_t is + only one word and the same size as a void *, we cannot just pass + the value through pthread_create as the argument and have the new + thread run the user's function directly, because on some machines + the calling convention for a union like sigval_t is different from + that for a pointer type like void *. */ + struct notify_func *nf = malloc (sizeof *nf); + if (nf == NULL) result = -1; + else + { + nf->func = sigev->sigev_notify_function; + nf->value = sigev->sigev_value; + if (pthread_create (&tid, pattr, notify_func_wrapper, nf) < 0) + { + free (nf); + result = -1; + } + } } else if (sigev->sigev_notify == SIGEV_SIGNAL) /* We have to send a signal. */ @@ -79,15 +106,21 @@ __gai_notify (struct requestlist *req) { struct waitlist *next = waitlist->next; - /* Decrement the counter. This is used in both cases. */ - --*waitlist->counterp; - if (waitlist->sigevp == NULL) - pthread_cond_signal (waitlist->cond); + { +#ifdef DONT_NEED_GAI_MISC_COND + GAI_MISC_NOTIFY (waitlist); +#else + /* Decrement the counter. */ + --*waitlist->counterp; + + pthread_cond_signal (waitlist->cond); +#endif + } else /* This is part of a asynchronous `getaddrinfo_a' operation. If this request is the last one, send the signal. */ - if (*waitlist->counterp == 0) + if (--*waitlist->counterp == 0) { __gai_notify_only (waitlist->sigevp, waitlist->caller_pid); /* This is tricky. See getaddrinfo_a.c for the reason why diff --git a/resolv/gai_sigqueue.c b/resolv/gai_sigqueue.c index 2c91df6ddc..278a1d8026 100644 --- a/resolv/gai_sigqueue.c +++ b/resolv/gai_sigqueue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 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 @@ -20,7 +20,7 @@ #include <errno.h> #include <signal.h> -#include "gai_misc.h" +#include <gai_misc.h> int __gai_sigqueue (sig, val, caller_pid) diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c index bb3c9c3402..c2095124b7 100644 --- a/resolv/gai_suspend.c +++ b/resolv/gai_suspend.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -23,7 +23,7 @@ #include <stdlib.h> #include <sys/time.h> -#include "gai_misc.h" +#include <gai_misc.h> int @@ -32,9 +32,11 @@ gai_suspend (const struct gaicb *const list[], int ent, { struct waitlist waitlist[ent]; struct requestlist *requestlist[ent]; +#ifndef DONT_NEED_GAI_MISC_COND pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +#endif int cnt; - int dummy; + int cntr = 1; int none = 1; int result; @@ -50,9 +52,11 @@ gai_suspend (const struct gaicb *const list[], int ent, if (requestlist[cnt] != NULL) { +#ifndef DONT_NEED_GAI_MISC_COND waitlist[cnt].cond = &cond; +#endif waitlist[cnt].next = requestlist[cnt]->waiting; - waitlist[cnt].counterp = &dummy; + waitlist[cnt].counterp = &cntr; waitlist[cnt].sigevp = NULL; waitlist[cnt].caller_pid = 0; /* Not needed. */ requestlist[cnt]->waiting = &waitlist[cnt]; @@ -78,6 +82,9 @@ gai_suspend (const struct gaicb *const list[], int ent, which we must remove. So defer cancelation for now. */ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate); +#ifdef DONT_NEED_GAI_MISC_COND + GAI_MISC_WAIT (result, cntr, timeout, 1); +#else if (timeout == NULL) result = pthread_cond_wait (&cond, &__gai_requests_mutex); else @@ -99,6 +106,7 @@ gai_suspend (const struct gaicb *const list[], int ent, result = pthread_cond_timedwait (&cond, &__gai_requests_mutex, &abstime); } +#endif /* Now remove the entry in the waiting list for all requests which didn't terminate. */ @@ -121,10 +129,12 @@ gai_suspend (const struct gaicb *const list[], int ent, /* Now it's time to restore the cancelation state. */ pthread_setcancelstate (oldstate, NULL); +#ifndef DONT_NEED_GAI_MISC_COND /* Release the conditional variable. */ if (pthread_cond_destroy (&cond) != 0) /* This must never happen. */ abort (); +#endif if (result != 0) { diff --git a/resolv/getaddrinfo_a.c b/resolv/getaddrinfo_a.c index abac27d361..f6af3aa45a 100644 --- a/resolv/getaddrinfo_a.c +++ b/resolv/getaddrinfo_a.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -23,7 +23,7 @@ #include <stdlib.h> #include <unistd.h> -#include "gai_misc.h" +#include <gai_misc.h> /* We need this special structure to handle asynchronous I/O. */ @@ -96,7 +96,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig) } else if (mode == GAI_WAIT) { +#ifndef DONT_NEED_GAI_MISC_COND pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +#endif struct waitlist waitlist[ent]; int oldstate; @@ -104,7 +106,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig) for (cnt = 0; cnt < ent; ++cnt) if (requests[cnt] != NULL) { +#ifndef DONT_NEED_GAI_MISC_COND waitlist[cnt].cond = &cond; +#endif waitlist[cnt].next = requests[cnt]->waiting; waitlist[cnt].counterp = &total; waitlist[cnt].sigevp = NULL; @@ -119,15 +123,24 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig) pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate); while (total > 0) - pthread_cond_wait (&cond, &__gai_requests_mutex); + { +#ifdef DONT_NEED_GAI_MISC_COND + int result; + GAI_MISC_WAIT (result, total, NULL, 1); +#else + pthread_cond_wait (&cond, &__gai_requests_mutex); +#endif + } /* Now it's time to restore the cancelation state. */ pthread_setcancelstate (oldstate, NULL); +#ifndef DONT_NEED_GAI_MISC_COND /* Release the conditional variable. */ if (pthread_cond_destroy (&cond) != 0) /* This must never happen. */ abort (); +#endif } else { @@ -147,7 +160,9 @@ getaddrinfo_a (int mode, struct gaicb *list[], int ent, struct sigevent *sig) for (cnt = 0; cnt < ent; ++cnt) if (requests[cnt] != NULL) { +#ifndef DONT_NEED_GAI_MISC_COND waitlist->list[cnt].cond = NULL; +#endif waitlist->list[cnt].next = requests[cnt]->waiting; waitlist->list[cnt].counterp = &waitlist->counter; waitlist->list[cnt].sigevp = &waitlist->sigev; diff --git a/rt/Makefile b/rt/Makefile index f8487975dd..148ded996e 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -48,7 +48,8 @@ tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \ tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \ tst-timer3 tst-timer4 tst-timer5 \ tst-cpuclock1 tst-cpuclock2 \ - tst-cputimer1 tst-cputimer2 tst-cputimer3 + tst-cputimer1 tst-cputimer2 tst-cputimer3 \ + tst-clock2 extra-libs := librt extra-libs-others := $(extra-libs) diff --git a/rt/tst-clock2.c b/rt/tst-clock2.c new file mode 100644 index 0000000000..4c8fb9f247 --- /dev/null +++ b/rt/tst-clock2.c @@ -0,0 +1,43 @@ +/* Test setting the monotonic clock. */ + +#include <time.h> +#include <unistd.h> + +#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK + +# include <errno.h> +# include <stdio.h> + +static int +do_test (void) +{ + if (sysconf (_SC_MONOTONIC_CLOCK) <= 0) + return 0; + + struct timespec ts; + if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0) + { + puts ("clock_gettime(CLOCK_MONOTONIC) failed"); + return 1; + } + + /* Setting the monotonic clock must fail. */ + if (clock_settime (CLOCK_MONOTONIC, &ts) != -1) + { + puts ("clock_settime(CLOCK_MONOTONIC) did not fail"); + return 1; + } + if (errno != EINVAL) + { + printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n", + errno, EINVAL); + return 1; + } + return 0; +} +# define TEST_FUNCTION do_test () + +#else +# define TEST_FUNCTION 0 +#endif +#include "../test-skeleton.c" diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 70f6d64c9a..37bcdb3bc8 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -54,7 +54,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \ tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \ tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \ tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \ - tst-fwrite + tst-fwrite bug16 test-srcs = tst-unbputc tst-printf diff --git a/stdio-common/bug16.c b/stdio-common/bug16.c new file mode 100644 index 0000000000..42e37fa8b6 --- /dev/null +++ b/stdio-common/bug16.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <string.h> + +static int +do_test (void) +{ + char buf[100]; + snprintf (buf, sizeof (buf), "%.0LA", 0x0.FFFFp+0L); + + if (strcmp (buf, "0X1P+0") != 0) + { + printf ("got \"%s\", expected \"0X1P+0\"\n", buf); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c index fd790d5bf3..4e30d94c61 100644 --- a/stdio-common/printf_fphex.c +++ b/stdio-common/printf_fphex.c @@ -1,5 +1,5 @@ /* Print floating point number in hexadecimal notation according to ISO C99. - Copyright (C) 1997-2002,2004 Free Software Foundation, Inc. + Copyright (C) 1997-2002,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -399,12 +399,15 @@ __printf_fphex (FILE *fp, ++leading; else { - leading = 1; + leading = '1'; if (expnegative) { - exponent += 4; - if (exponent >= 0) - expnegative = 0; + exponent -= 4; + if (exponent <= 0) + { + exponent = -exponent; + expnegative = 0; + } } else exponent += 4; diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index f44a9afbf2..de98fb3d7b 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1995,1996,1998-2001,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998-2001,2003,2004,2006 + 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,7 +25,6 @@ #include <not-cancel.h> #define HOSTIDFILE "/etc/hostid" -#define OLD_HOSTIDFILE "/etc/hostid" #ifdef SET_PROCEDURE int @@ -81,8 +81,6 @@ gethostid () /* First try to get the ID from a former invocation of sethostid. */ fd = open_not_cancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); - if (fd < 0) - fd = open_not_cancel (OLD_HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); if (fd >= 0) { ssize_t n = read_not_cancel (fd, &id, sizeof (id)); diff --git a/sysdeps/unix/sysv/linux/msgrcv.c b/sysdeps/unix/sysv/linux/msgrcv.c index 7d8a8e7859..71e7c7aea5 100644 --- a/sysdeps/unix/sysv/linux/msgrcv.c +++ b/sysdeps/unix/sysv/linux/msgrcv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1997, 1998, 2000, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1995,1997,1998,2000,2002,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -35,7 +35,7 @@ struct ipc_kludge }; -int +ssize_t __libc_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg) int msqid; void *msgp; @@ -56,8 +56,8 @@ __libc_msgrcv (msqid, msgp, msgsz, msgtyp, msgflg) int oldtype = LIBC_CANCEL_ASYNC (); - int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, - __ptrvalue (&tmp)); + ssize_t result = INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, + __ptrvalue (&tmp)); LIBC_CANCEL_RESET (oldtype); diff --git a/sysvipc/msgrcv.c b/sysvipc/msgrcv.c index f366fa8170..83732b3113 100644 --- a/sysvipc/msgrcv.c +++ b/sysvipc/msgrcv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -26,7 +26,7 @@ describes which message is returned in MSGFLG describes the behaviour in buffer overflow or queue underflow. */ -int +ssize_t msgrcv (msqid, msgp, msgsz, msgtyp, msgflg) int msqid; void *msgp; diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h index 1fd64b2ac0..b22c07678a 100644 --- a/sysvipc/sys/msg.h +++ b/sysvipc/sys/msg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1999,2000,2003 Free Software Foundation, Inc. +/* Copyright (C) 1995-1997,1999,2000,2003,2006 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 @@ -66,8 +66,8 @@ extern int msgget (key_t __key, int __msgflg) __THROW; This function is a cancellation point and therefore not marked with __THROW. */ -extern int msgrcv (int __msqid, void *__msgp, size_t __msgsz, - long int __msgtyp, int __msgflg); +extern ssize_t msgrcv (int __msqid, void *__msgp, size_t __msgsz, + long int __msgtyp, int __msgflg); /* Send message to message queue. |