From 26059a9936f45bd4486c7e4a2a75e6ac29c06950 Mon Sep 17 00:00:00 2001 From: Sayamindu Dasgupta Date: Thu, 15 Oct 2009 06:51:37 -0700 Subject: [PATCH 01/47] Afghan locale definition for Pashto language. Mostly by Sayamindu Dasgupta, fixed up by Pravin Satpute . --- localedata/locales/ps_AF | 283 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 localedata/locales/ps_AF diff --git a/localedata/locales/ps_AF b/localedata/locales/ps_AF new file mode 100644 index 0000000000..fe6307617a --- /dev/null +++ b/localedata/locales/ps_AF @@ -0,0 +1,283 @@ +escape_char / +comment_char % + +%%%%%%%%%%%%%%%%%%%%%%% locale definition file "ps_AF" %%%%%%%%%%%%%%%%%%%%%% + +% Pashto Locale for Afghanistan +% Filename: ps_AF +% Locale name: ps_AF.UTF-8 +% Language: Pashto +% Territory: Afghanistan +% Charset: UTF-8 +% Revision: 0.1 +% By: Nasir Gulzade +% Creation Date: Thu, 15 Jan 2009 18:16:15 +0500 GMT +% Last Modification Date: Fri, 16 Jan 2009 20:33:40 +0500 GMT +% + + +LC_IDENTIFICATION + title "Pashto locale for Afghanistan" + source "Nasir Gulzade" + address "see e-mail." + contact "Nasir Gulzade" + email "nasirgulzade@hotmail.com" + tel "+93 700530286" + fax "" + language "Pashto" + territory "Afghanistan" + revision "0.2" + date "2009-01-16" + + category "ps_AF:2007";LC_IDENTIFICATION + category "ps_AF:2007";LC_CTYPE + category "ps_AF:2007";LC_COLLATE + category "ps_AF:2007";LC_TIME + category "ps_AF:2007";LC_NUMERIC + category "ps_AF:2007";LC_MONETARY + category "ps_AF:2007";LC_MESSAGES + category "ps_AF:2007";LC_MEASUREMENT + category "ps_AF:2007";LC_PAPER + category "ps_AF:2007";LC_NAME + category "ps_AF:2007";LC_ADDRESS + category "ps_AF:2007";LC_TELEPHONE +END LC_IDENTIFICATION + +LC_CTYPE + copy "i18n" + outdigit ..;;.. + map to_outpunct; (,);(,) +END LC_CTYPE + +LC_COLLATE +% Collation rules updated as per requirement of glibc by Pravin Satpute +% see rh bug 482881 +copy "iso14651_t1" + +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol +collating-symbol + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + +reorder-after + + + + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + +reorder-after + ;;;IGNORE + ;;;IGNORE + +reorder-after + ;;;IGNORE + "";"";"";IGNORE + ;;;IGNORE + +reorder-end + +END LC_COLLATE + +LC_TIME + abday "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" + day "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" + abmon "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" + mon "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" + d_t_fmt "/ +/ +/ +" + d_fmt "/ +" + t_fmt "" + am_pm "";/ + "" + t_fmt_ampm "/ +" + first_weekday 7 + first_workday 7 + cal_direction 3 +END LC_TIME + +LC_NUMERIC + decimal_point "" + thousands_sep "" + grouping 3 +END LC_NUMERIC + +LC_MONETARY + int_curr_symbol "" + currency_symbol "" + mon_decimal_point "" + mon_thousands_sep "" + mon_grouping 3 + positive_sign "" + negative_sign "" + int_frac_digits 0 + frac_digits 0 + p_cs_precedes 0 + p_sep_by_space 1 + n_cs_precedes 0 + n_sep_by_space 1 + p_sign_posn 1 + n_sign_posn 1 +END LC_MONETARY + +LC_MESSAGES + yesexpr "/ +" + noexpr "/ +" +END LC_MESSAGES + +LC_MEASUREMENT + measurement 1 +END LC_MEASUREMENT + +LC_PAPER + height 297 + width 210 +END LC_PAPER + +LC_NAME + name_fmt "/ +" + name_gen "" % No general salutation for all persons in Pashto. + name_mr "" + name_mrs "" + name_miss "" + name_ms "" +END LC_NAME + +LC_ADDRESS + postal_fmt "/ +/ +/ +/ +" + country_name "/ +" + %country_post "" % FIXME: Not confirmed. + country_ab2 "" + country_ab3 "" + country_num 004 + country_car "" + + %country_isbn "" % Unfortunately not yet assigned :-( + % Since to date there is no ISBN agency working + % in Afghanistan. + + lang_name "" + lang_ab "" + lang_term "" + lang_lib "" +END LC_ADDRESS + +LC_TELEPHONE + tel_int_fmt "/ +" + tel_dom_fmt "" + int_select "" + int_prefix "" +END LC_TELEPHONE + +%%%%%%%%%%%%%%%%%%%% locale definition file "ps_AF" ends %%%%%%%%%%%%%%%%%%%%% + From 0fc3cbc13f508e021c90e2d9fe0ceba88f37a19a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 15 Oct 2009 06:53:24 -0700 Subject: [PATCH 02/47] Add ps_AF locale. --- localedata/ChangeLog | 8 ++++++++ localedata/SUPPORTED | 1 + 2 files changed, 9 insertions(+) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 11d78fde3f..81468d5df3 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,11 @@ +2009-10-15 Ulrich Drepper + + * SUPPORTED (SUPPORTED-LOCALES): Add ps_AF.UTF-8. + + * locale/ps_AF: New file. + Contributed by Sayamindu Dasgupta and + Pravin Satpute . + 2009-06-16 Ulrich Drepper [BZ #10011] diff --git a/localedata/SUPPORTED b/localedata/SUPPORTED index 6a75c9259c..e8a3e513a2 100644 --- a/localedata/SUPPORTED +++ b/localedata/SUPPORTED @@ -317,6 +317,7 @@ pa_PK/UTF-8 \ pap_AN/UTF-8 \ pl_PL.UTF-8/UTF-8 \ pl_PL/ISO-8859-2 \ +ps_AF/UTF-8 \ pt_BR.UTF-8/UTF-8 \ pt_BR/ISO-8859-1 \ pt_PT.UTF-8/UTF-8 \ From 02a544f460de28fe603d91b34692cf3f64713229 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 15 Oct 2009 06:54:25 -0700 Subject: [PATCH 03/47] Mention ps_AF locale as new. --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d2ac1aa02b..9044ec0f49 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2009-8-8 +GNU C Library NEWS -- history of user-visible changes. 2009-10-15 Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc. See the end for copying conditions. @@ -55,6 +55,8 @@ Version 2.11 support for requeueing to PI futexes. NPTL support added for x86-64. Implemented by Ulrich Drepper. +* New locale: ps_AF + Version 2.10 From b7805d0ba8948fcf5e406bf52530d9aba99f5954 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 19 Oct 2009 21:23:15 -0700 Subject: [PATCH 04/47] Correct errno handling in expm1. --- ChangeLog | 11 +++++++++++ include/math.h | 3 +++ sysdeps/i386/fpu/s_expm1.S | 6 ++++++ sysdeps/i386/fpu/s_expm1f.S | 6 ++++++ sysdeps/i386/fpu/s_expm1l.S | 3 ++- sysdeps/ieee754/dbl-64/w_exp.c | 1 + sysdeps/ieee754/flt-32/w_expf.c | 1 + sysdeps/ieee754/ldbl-96/w_expl.c | 1 + 8 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 700e346981..2857d88177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-10-19 Andreas Schwab + + * include/math.h: Add hidden protos for __exp/__expf/__expl. + * sysdeps/ieee754/dbl-64/w_exp.c: Add hidden alias. + * sysdeps/ieee754/flt-32/w_expf.c: Likewise. + * sysdeps/ieee754/ldbl-96/w_expl.c: Likewise. + * sysdeps/i386/fpu/s_expm1.S: Call __exp to handle overflow. + * sysdeps/i386/fpu/s_expm1f.S: Call __expf to handle overflow. + * sysdeps/i386/fpu/s_expm1l.S: Call __expl instead of + __ieee751_expl to handle overflow. + 2009-10-14 David S. Miller * sysdeps/unix/sysv/linux/sparc/sparc32/____longjmp_chk.S: New file. diff --git a/include/math.h b/include/math.h index 1005804273..eb29ef1a56 100644 --- a/include/math.h +++ b/include/math.h @@ -22,9 +22,12 @@ hidden_proto (__isnanl) libm_hidden_proto (__fpclassify) libm_hidden_proto (__fpclassifyf) +libm_hidden_proto (__exp) +libm_hidden_proto (__expf) # ifndef __NO_LONG_DOUBLE_MATH libm_hidden_proto (__fpclassifyl) +libm_hidden_proto (__expl) libm_hidden_proto (__expm1l) # endif diff --git a/sysdeps/i386/fpu/s_expm1.S b/sysdeps/i386/fpu/s_expm1.S index e761183639..c690a458f8 100644 --- a/sysdeps/i386/fpu/s_expm1.S +++ b/sysdeps/i386/fpu/s_expm1.S @@ -22,6 +22,7 @@ /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */ +#include #include #ifdef __ELF__ @@ -48,6 +49,11 @@ l2e: .tfloat 1.442695040888963407359924681002 .text ENTRY(__expm1) + movzwl 4+6(%esp), %eax + xorb $0x80, %ah // invert sign bit (now 1 is "positive") + cmpl $0xc086, %eax // is num >= 704? + jae HIDDEN_JUMPTARGET (__exp) + fldl 4(%esp) // x fxam // Is NaN or +-Inf? fstsw %ax diff --git a/sysdeps/i386/fpu/s_expm1f.S b/sysdeps/i386/fpu/s_expm1f.S index 88adb75b86..8645107274 100644 --- a/sysdeps/i386/fpu/s_expm1f.S +++ b/sysdeps/i386/fpu/s_expm1f.S @@ -22,6 +22,7 @@ /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */ +#include #include #ifdef __ELF__ @@ -48,6 +49,11 @@ l2e: .tfloat 1.442695040888963407359924681002 .text ENTRY(__expm1f) + movzwl 4+2(%esp), %eax + xorb $0x80, %ah // invert sign bit (now 1 is "positive") + cmpl $0xc2b1, %eax // is num >= 88.5? + jae HIDDEN_JUMPTARGET (__expf) + flds 4(%esp) // x fxam // Is NaN or +-Inf? fstsw %ax diff --git a/sysdeps/i386/fpu/s_expm1l.S b/sysdeps/i386/fpu/s_expm1l.S index b69b22bc62..60b5b82e20 100644 --- a/sysdeps/i386/fpu/s_expm1l.S +++ b/sysdeps/i386/fpu/s_expm1l.S @@ -22,6 +22,7 @@ /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */ +#include #include #ifdef __ELF__ @@ -51,7 +52,7 @@ ENTRY(__expm1l) movzwl 4+8(%esp), %eax // load sign bit and 15-bit exponent xorb $0x80, %ah // invert sign bit (now 1 is "positive") cmpl $0xc006, %eax // is num positive and exp >= 6 (number is >= 128.0)? - jae __ieee754_expl // (if num is denormal, it is at least >= 64.0) + jae HIDDEN_JUMPTARGET (__expl) // (if num is denormal, it is at least >= 64.0) fldt 4(%esp) // x fxam // Is NaN or +-Inf? diff --git a/sysdeps/ieee754/dbl-64/w_exp.c b/sysdeps/ieee754/dbl-64/w_exp.c index 445c5788d2..1216492090 100644 --- a/sysdeps/ieee754/dbl-64/w_exp.c +++ b/sysdeps/ieee754/dbl-64/w_exp.c @@ -51,6 +51,7 @@ u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ return z; #endif } +hidden_def (__exp) weak_alias (__exp, exp) #ifdef NO_LONG_DOUBLE strong_alias (__exp, __expl) diff --git a/sysdeps/ieee754/flt-32/w_expf.c b/sysdeps/ieee754/flt-32/w_expf.c index 4ba21c7c42..83b268f570 100644 --- a/sysdeps/ieee754/flt-32/w_expf.c +++ b/sysdeps/ieee754/flt-32/w_expf.c @@ -56,4 +56,5 @@ u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */ return z; #endif } +hidden_def (__expf) weak_alias (__expf, expf) diff --git a/sysdeps/ieee754/ldbl-96/w_expl.c b/sysdeps/ieee754/ldbl-96/w_expl.c index b8152cea65..53bb143734 100644 --- a/sysdeps/ieee754/ldbl-96/w_expl.c +++ b/sysdeps/ieee754/ldbl-96/w_expl.c @@ -57,4 +57,5 @@ u_threshold= -1.140019167866942050398521670162263001513e4; return z; #endif } +hidden_def (__expl) weak_alias (__expl, expl) From bc5e8462188bdd9919e804fbba44e4b983b7724a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 21 Oct 2009 06:23:42 -0700 Subject: [PATCH 05/47] Handle IFUNC symbols in dlsym. --- ChangeLog | 4 ++++ elf/dl-sym.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2857d88177..ccbb625461 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-21 Andreas Schwab + + * elf/dl-sym.c (do_sym): Resolve STT_GNU_IFUNC symbols. + 2009-10-19 Andreas Schwab * include/math.h: Add hidden protos for __exp/__expf/__expl. diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 740bb9a892..459729f0f2 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -191,6 +191,11 @@ RTLD_NEXT used in code not dynamically loaded")); #endif value = DL_SYMBOL_ADDRESS (result, ref); + /* Resolve indirect function address. */ + if (__builtin_expect (ELFW(ST_TYPE) (ref->st_info) == STT_GNU_IFUNC, 0)) + value + = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (value)) (); + #ifdef SHARED /* Auditing checkpoint: we have a new binding. Provide the auditing libraries the possibility to change the value and From 001659f4d59d675c48a7748594e784fb35a5678d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 22 Oct 2009 22:47:12 -0700 Subject: [PATCH 06/47] Implement SSE4.2 optimized strchr and strrchr. --- ChangeLog | 8 + sysdeps/x86_64/multiarch/Makefile | 3 +- sysdeps/x86_64/multiarch/strchr.S | 177 ++++++++++++++++ sysdeps/x86_64/multiarch/strend-sse4.S | 49 +++++ sysdeps/x86_64/multiarch/strrchr.S | 278 +++++++++++++++++++++++++ 5 files changed, 514 insertions(+), 1 deletion(-) create mode 100644 sysdeps/x86_64/multiarch/strchr.S create mode 100644 sysdeps/x86_64/multiarch/strend-sse4.S create mode 100644 sysdeps/x86_64/multiarch/strrchr.S diff --git a/ChangeLog b/ChangeLog index ccbb625461..b88343fa7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-10-21 H.J. Lu + + * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add + strend-sse4. + * sysdeps/x86_64/multiarch/strchr.S: New file. + * sysdeps/x86_64/multiarch/strend-sse4.S: New file. + * sysdeps/x86_64/multiarch/strrchr.S: New file. + 2009-10-21 Andreas Schwab * elf/dl-sym.c (do_sym): Resolve STT_GNU_IFUNC symbols. diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile index 0ded3b3261..364e7bbbd2 100644 --- a/sysdeps/x86_64/multiarch/Makefile +++ b/sysdeps/x86_64/multiarch/Makefile @@ -4,7 +4,8 @@ gen-as-const-headers += ifunc-defines.sym endif ifeq ($(subdir),string) -sysdep_routines += stpncpy-c strncpy-c strcmp-ssse3 strncmp-ssse3 +sysdep_routines += stpncpy-c strncpy-c strcmp-ssse3 strncmp-ssse3 \ + strend-sse4 ifeq (yes,$(config-cflags-sse4)) sysdep_routines += strcspn-c strpbrk-c strspn-c strstr-c strcasestr-c CFLAGS-strcspn-c.c += -msse4 diff --git a/sysdeps/x86_64/multiarch/strchr.S b/sysdeps/x86_64/multiarch/strchr.S new file mode 100644 index 0000000000..a77cc1c844 --- /dev/null +++ b/sysdeps/x86_64/multiarch/strchr.S @@ -0,0 +1,177 @@ +/* strchr with SSE4.2 + Copyright (C) 2009 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. */ + +#include +#include + + +/* Define multiple versions only for the definition in libc. */ +#ifndef NOT_IN_libc + .text +ENTRY(strchr) + .type strchr, @gnu_indirect_function + cmpl $0, __cpu_features+KIND_OFFSET(%rip) + jne 1f + call __init_cpu_features +1: leaq __strchr_sse2(%rip), %rax + testl $(1<<20), __cpu_features+CPUID_OFFSET+COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET(%rip) + jz 2f + leaq __strchr_sse42(%rip), %rax +2: ret +END(strchr) + + +/* + This implementation uses SSE4 instructions to compare up to 16 bytes + at a time looking for the first occurrence of the character c in the + string s: + + char *strchr (const char *s, int c); + + We use 0xa: + _SIDD_SBYTE_OPS + | _SIDD_CMP_EQUAL_EACH + | _SIDD_LEAST_SIGNIFICANT + on pcmpistri to compare xmm/mem128 + + 0 1 2 3 4 5 6 7 8 9 A B C D E F + X X X X X X X X X X X X X X X X + + against xmm + + 0 1 2 3 4 5 6 7 8 9 A B C D E F + C C C C C C C C C C C C C C C C + + to find out if the first 16byte data element has a byte C and the + offset of the first byte. There are 3 cases: + + 1. The first 16byte data element has the byte C at the offset X. + 2. The first 16byte data element has EOS and doesn't have the byte C. + 3. The first 16byte data element is valid and doesn't have the byte C. + + Here is the table of ECX, CFlag, ZFlag and SFlag for 3 cases: + + case ECX CFlag ZFlag SFlag + 1 X 1 0/1 0 + 2 16 0 1 0 + 3 16 0 0 0 + + We exit from the loop for cases 1 and 2 with jbe which branches + when either CFlag or ZFlag is 1. If CFlag == 1, ECX has the offset + X for case 1. */ + + .section .text.sse4.2,"ax",@progbits + .align 16 + .type __strchr_sse42, @function +__strchr_sse42: + cfi_startproc + CALL_MCOUNT + testb %sil, %sil + je __strend_sse4 + pxor %xmm2, %xmm2 + movd %esi, %xmm1 + movl %edi, %ecx + andl $15, %ecx + movq %rdi, %r8 + je L(aligned_start) + +/* Handle unaligned string. */ + andq $-16, %r8 + pshufb %xmm2, %xmm1 + movdqa (%r8), %xmm0 + pcmpeqb %xmm0, %xmm2 + pcmpeqb %xmm1, %xmm0 + /* Find where NULL is. */ + pmovmskb %xmm2, %edx + /* Check if there is a match. */ + pmovmskb %xmm0, %esi + /* Remove the leading bytes. */ + sarl %cl, %edx + sarl %cl, %esi + testl %esi, %esi + je L(unaligned_no_match) + /* Check which byte is a match. */ + bsfl %esi, %eax + /* Is there a NULL? */ + testl %edx, %edx + je L(unaligned_match) + bsfl %edx, %esi + cmpl %esi, %eax + /* Return NULL if NULL comes first. */ + ja L(return_null) +L(unaligned_match): + addq %rdi, %rax + ret + + .p2align 4 +L(unaligned_no_match): + testl %edx, %edx + jne L(return_null) + +/* Loop start on aligned string. */ +L(loop): + addq $16, %r8 +L(aligned_start): + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) + addq $16, %r8 + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) + addq $16, %r8 + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) + addq $16, %r8 + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) + jmp L(loop) +L(wrap): + jc L(loop_exit) + +/* Return NULL. */ +L(return_null): + xorl %eax, %eax + ret + +/* Loop exit. */ + .p2align 4 +L(loop_exit): + leaq (%r8,%rcx), %rax + ret + cfi_endproc + .size __strchr_sse42, .-__strchr_sse42 + + +# undef ENTRY +# define ENTRY(name) \ + .type __strchr_sse2, @function; \ + .align 16; \ + __strchr_sse2: cfi_startproc; \ + CALL_MCOUNT +# undef END +# define END(name) \ + cfi_endproc; .size __strchr_sse2, .-__strchr_sse2 +# undef libc_hidden_builtin_def +/* It doesn't make sense to send libc-internal strchr calls through a PLT. + The speedup we get from using SSE4.2 instruction is likely eaten away + by the indirect call in the PLT. */ +# define libc_hidden_builtin_def(name) \ + .globl __GI_strchr; __GI_strchr = __strchr_sse2 +#endif + +#include "../strchr.S" diff --git a/sysdeps/x86_64/multiarch/strend-sse4.S b/sysdeps/x86_64/multiarch/strend-sse4.S new file mode 100644 index 0000000000..c3220b3386 --- /dev/null +++ b/sysdeps/x86_64/multiarch/strend-sse4.S @@ -0,0 +1,49 @@ +/* Return the pointer to the end of string, using SSE4.2 + Copyright (C) 2009 Free Software Foundation, Inc. + Contributed by Intel Corporation. + 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. */ + +#include +#include "asm-syntax.h" + + .section .text.sse4.2,"ax",@progbits +ENTRY (__strend_sse4) + pxor %xmm2, %xmm2 + movq %rdi, %rcx + andq $~15, %rdi + movdqa %xmm2, %xmm1 + pcmpeqb (%rdi), %xmm2 + orl $0xffffffff, %esi + subq %rdi, %rcx + shll %cl, %esi + pmovmskb %xmm2, %edx + andl %esi, %edx + jnz 1f + +2: pcmpistri $0x08, 16(%rdi), %xmm1 + leaq 16(%rdi), %rdi + jnz 2b + + leaq (%rdi,%rcx), %rax + ret + +1: bsfl %edx, %eax + addq %rdi, %rax + ret + +END (__strend_sse4) diff --git a/sysdeps/x86_64/multiarch/strrchr.S b/sysdeps/x86_64/multiarch/strrchr.S new file mode 100644 index 0000000000..a8c28a484c --- /dev/null +++ b/sysdeps/x86_64/multiarch/strrchr.S @@ -0,0 +1,278 @@ +/* strrchr with SSE4.2 + Copyright (C) 2009 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. */ + +#include +#include + + +/* Define multiple versions only for the definition in libc and for + the DSO. In static binaries we need strrchr before the initialization + happened. */ +#if defined SHARED && !defined NOT_IN_libc + .text +ENTRY(strrchr) + .type strrchr, @gnu_indirect_function + cmpl $0, __cpu_features+KIND_OFFSET(%rip) + jne 1f + call __init_cpu_features +1: leaq __strrchr_sse2(%rip), %rax + testl $(1<<20), __cpu_features+CPUID_OFFSET+COMMON_CPUID_INDEX_1*CPUID_SIZE+CPUID_ECX_OFFSET(%rip) + jz 2f + leaq __strrchr_sse42(%rip), %rax +2: ret +END(strrchr) + +/* + This implementation uses SSE4 instructions to compare up to 16 bytes + at a time looking for the last occurrence of the character c in the + string s: + + char *strrchr (const char *s, int c); + + We use 0x4a: + _SIDD_SBYTE_OPS + | _SIDD_CMP_EQUAL_EACH + | _SIDD_MOST_SIGNIFICANT + on pcmpistri to compare xmm/mem128 + + 0 1 2 3 4 5 6 7 8 9 A B C D E F + X X X X X X X X X X X X X X X X + + against xmm + + 0 1 2 3 4 5 6 7 8 9 A B C D E F + C C C C C C C C C C C C C C C C + + to find out if the first 16byte data element has a byte C and the + last offset. There are 4 cases: + + 1. The first 16byte data element has EOS and has the byte C at the + last offset X. + 2. The first 16byte data element is valid and has the byte C at the + last offset X. + 3. The first 16byte data element has EOS and doesn't have the byte C. + 4. The first 16byte data element is valid and doesn't have the byte C. + + Here is the table of ECX, CFlag, ZFlag and SFlag for 3 cases: + + case ECX CFlag ZFlag SFlag + 1 X 1 1 0 + 2 X 1 0 0 + 3 16 0 1 0 + 4 16 0 0 0 + + We exit from the loop for cases 1 and 3 with jz which branches + when ZFlag is 1. If CFlag == 1, ECX has the offset X for case 1. */ + + + .section .text.sse4.2,"ax",@progbits + .align 16 + .type __strrchr_sse42, @function +__strrchr_sse42: + cfi_startproc + CALL_MCOUNT + testb %sil, %sil + je __strend_sse4 + xor %eax,%eax /* RAX has the last occurrence of s. */ + movd %esi, %xmm1 + punpcklbw %xmm1, %xmm1 + movl %edi, %esi + punpcklbw %xmm1, %xmm1 + andl $15, %esi + pshufd $0, %xmm1, %xmm1 + movq %rdi, %r8 + je L(loop) + +/* Handle unaligned string using psrldq. */ + leaq L(psrldq_table)(%rip), %rdx + andq $-16, %r8 + movslq (%rdx,%rsi,4),%r9 + movdqa (%r8), %xmm0 + addq %rdx, %r9 + jmp *%r9 + +/* Handle unaligned string with offset 1 using psrldq. */ + .p2align 4 +L(psrldq_1): + psrldq $1, %xmm0 + + .p2align 4 +L(unaligned_pcmpistri): + pcmpistri $0x4a, %xmm1, %xmm0 + jnc L(unaligned_no_byte) + leaq (%rdi,%rcx), %rax +L(unaligned_no_byte): + /* Find the length of the unaligned string. */ + pcmpistri $0x3a, %xmm0, %xmm0 + movl $16, %edx + subl %esi, %edx + cmpl %ecx, %edx + /* Return RAX if the unaligned fragment to next 16B already + contain the NULL terminator. */ + jg L(exit) + addq $16, %r8 + +/* Loop start on aligned string. */ + .p2align 4 +L(loop): + pcmpistri $0x4a, (%r8), %xmm1 + jbe L(match_or_eos) + addq $16, %r8 + jmp L(loop) + .p2align 4 +L(match_or_eos): + je L(had_eos) +L(match_no_eos): + leaq (%r8,%rcx), %rax + addq $16, %r8 + jmp L(loop) + .p2align 4 +L(had_eos): + jnc L(exit) + leaq (%r8,%rcx), %rax + .p2align 4 +L(exit): + ret + +/* Handle unaligned string with offset 15 using psrldq. */ + .p2align 4 +L(psrldq_15): + psrldq $15, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 14 using psrldq. */ + .p2align 4 +L(psrldq_14): + psrldq $14, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 13 using psrldq. */ + .p2align 4 +L(psrldq_13): + psrldq $13, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 12 using psrldq. */ + .p2align 4 +L(psrldq_12): + psrldq $12, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 11 using psrldq. */ + .p2align 4 +L(psrldq_11): + psrldq $11, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 10 using psrldq. */ + .p2align 4 +L(psrldq_10): + psrldq $10, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 9 using psrldq. */ + .p2align 4 +L(psrldq_9): + psrldq $9, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 8 using psrldq. */ + .p2align 4 +L(psrldq_8): + psrldq $8, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 7 using psrldq. */ + .p2align 4 +L(psrldq_7): + psrldq $7, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 6 using psrldq. */ + .p2align 4 +L(psrldq_6): + psrldq $6, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 5 using psrldq. */ + .p2align 4 +L(psrldq_5): + psrldq $5, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 4 using psrldq. */ + .p2align 4 +L(psrldq_4): + psrldq $4, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 3 using psrldq. */ + .p2align 4 +L(psrldq_3): + psrldq $3, %xmm0 + jmp L(unaligned_pcmpistri) + +/* Handle unaligned string with offset 2 using psrldq. */ + .p2align 4 +L(psrldq_2): + psrldq $2, %xmm0 + jmp L(unaligned_pcmpistri) + + cfi_endproc + .size __strrchr_sse42, .-__strrchr_sse42 + + .section .rodata.sse4.2,"a",@progbits + .p2align 4 +L(psrldq_table): + .int L(loop) - L(psrldq_table) + .int L(psrldq_1) - L(psrldq_table) + .int L(psrldq_2) - L(psrldq_table) + .int L(psrldq_3) - L(psrldq_table) + .int L(psrldq_4) - L(psrldq_table) + .int L(psrldq_5) - L(psrldq_table) + .int L(psrldq_6) - L(psrldq_table) + .int L(psrldq_7) - L(psrldq_table) + .int L(psrldq_8) - L(psrldq_table) + .int L(psrldq_9) - L(psrldq_table) + .int L(psrldq_10) - L(psrldq_table) + .int L(psrldq_11) - L(psrldq_table) + .int L(psrldq_12) - L(psrldq_table) + .int L(psrldq_13) - L(psrldq_table) + .int L(psrldq_14) - L(psrldq_table) + .int L(psrldq_15) - L(psrldq_table) + + +# undef ENTRY +# define ENTRY(name) \ + .type __strrchr_sse2, @function; \ + .align 16; \ + __strrchr_sse2: cfi_startproc; \ + CALL_MCOUNT +# undef END +# define END(name) \ + cfi_endproc; .size __strrchr_sse2, .-__strrchr_sse2 +# undef libc_hidden_builtin_def +/* It doesn't make sense to send libc-internal strrchr calls through a PLT. + The speedup we get from using SSE4.2 instruction is likely eaten away + by the indirect call in the PLT. */ +# define libc_hidden_builtin_def(name) \ + .globl __GI_strrchr; __GI_strrchr = __strrchr_sse2 +#endif + +#include "../strrchr.S" From 823bc6da658301e546c0650104e7428b8c636873 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 22 Oct 2009 22:50:00 -0700 Subject: [PATCH 07/47] Fix whitespaces. --- localedata/locales/ps_AF | 21 ++++++++++----------- sysdeps/x86_64/multiarch/strchr.S | 16 ++++++++-------- sysdeps/x86_64/multiarch/strrchr.S | 6 +++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/localedata/locales/ps_AF b/localedata/locales/ps_AF index fe6307617a..7f686abbb5 100644 --- a/localedata/locales/ps_AF +++ b/localedata/locales/ps_AF @@ -54,16 +54,16 @@ LC_COLLATE % see rh bug 482881 copy "iso14651_t1" -collating-symbol +collating-symbol collating-symbol -collating-symbol +collating-symbol collating-symbol collating-symbol -collating-symbol +collating-symbol collating-symbol collating-symbol collating-symbol -collating-symbol +collating-symbol collating-symbol collating-symbol @@ -105,25 +105,25 @@ reorder-after reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE reorder-after ;;;IGNORE -reorder-after +reorder-after ;;;IGNORE reorder-after @@ -280,4 +280,3 @@ LC_TELEPHONE END LC_TELEPHONE %%%%%%%%%%%%%%%%%%%% locale definition file "ps_AF" ends %%%%%%%%%%%%%%%%%%%%% - diff --git a/sysdeps/x86_64/multiarch/strchr.S b/sysdeps/x86_64/multiarch/strchr.S index a77cc1c844..b35566d1a5 100644 --- a/sysdeps/x86_64/multiarch/strchr.S +++ b/sysdeps/x86_64/multiarch/strchr.S @@ -77,7 +77,7 @@ END(strchr) X for case 1. */ .section .text.sse4.2,"ax",@progbits - .align 16 + .align 16 .type __strchr_sse42, @function __strchr_sse42: cfi_startproc @@ -129,16 +129,16 @@ L(loop): addq $16, %r8 L(aligned_start): pcmpistri $0x2, (%r8), %xmm1 - jbe L(wrap) + jbe L(wrap) addq $16, %r8 pcmpistri $0x2, (%r8), %xmm1 - jbe L(wrap) - addq $16, %r8 - pcmpistri $0x2, (%r8), %xmm1 - jbe L(wrap) + jbe L(wrap) addq $16, %r8 - pcmpistri $0x2, (%r8), %xmm1 - jbe L(wrap) + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) + addq $16, %r8 + pcmpistri $0x2, (%r8), %xmm1 + jbe L(wrap) jmp L(loop) L(wrap): jc L(loop_exit) diff --git a/sysdeps/x86_64/multiarch/strrchr.S b/sysdeps/x86_64/multiarch/strrchr.S index a8c28a484c..f6665f34b7 100644 --- a/sysdeps/x86_64/multiarch/strrchr.S +++ b/sysdeps/x86_64/multiarch/strrchr.S @@ -82,7 +82,7 @@ END(strrchr) .section .text.sse4.2,"ax",@progbits - .align 16 + .align 16 .type __strrchr_sse42, @function __strrchr_sse42: cfi_startproc @@ -141,10 +141,10 @@ L(match_or_eos): L(match_no_eos): leaq (%r8,%rcx), %rax addq $16, %r8 - jmp L(loop) + jmp L(loop) .p2align 4 L(had_eos): - jnc L(exit) + jnc L(exit) leaq (%r8,%rcx), %rax .p2align 4 L(exit): From 98363ded87633c2bb91140d115cbd7b449634038 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 27 Oct 2009 13:46:08 -0700 Subject: [PATCH 08/47] Fix range checks in coshl. --- ChangeLog | 6 ++++++ math/w_coshl.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b88343fa7a..bac4e7a2f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-27 Jakub Jelinek + + [BZ #10817] + * math/w_coshl.c (__coshl): Use __finitel instead of __finite. + Reported by Ray Chason. + 2009-10-21 H.J. Lu * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add diff --git a/math/w_coshl.c b/math/w_coshl.c index 5f4623a81a..52b8d93522 100644 --- a/math/w_coshl.c +++ b/math/w_coshl.c @@ -38,8 +38,8 @@ static char rcsid[] = "$NetBSD: $"; long double z; z = __ieee754_coshl(x); if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; - if(!__finite(z) && __finite(x)) { - return __kernel_standard(x,x,205); /* cosh overflow */ + if(!__finitel(z) && __finitel(x)) { + return __kernel_standard(x,x,205); /* cosh overflow */ } else return z; #endif From 3ad3a4d0593be70f99a94b009afa76a6dc3f0a17 Mon Sep 17 00:00:00 2001 From: "Joseph S. Myers" Date: Sat, 24 Oct 2009 00:07:32 +0000 Subject: [PATCH 09/47] Readd definition of __expl in ldbl-128 --- ChangeLog | 4 ++++ sysdeps/ieee754/ldbl-128/w_expl.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index bac4e7a2f1..7f1b00539e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-24 Joseph Myers + + * sysdeps/ieee754/ldbl-128/w_expl.c: Add hidden_def (__expl). + 2009-10-27 Jakub Jelinek [BZ #10817] diff --git a/sysdeps/ieee754/ldbl-128/w_expl.c b/sysdeps/ieee754/ldbl-128/w_expl.c index 816ce3caa6..d6205d3ef8 100644 --- a/sysdeps/ieee754/ldbl-128/w_expl.c +++ b/sysdeps/ieee754/ldbl-128/w_expl.c @@ -55,4 +55,5 @@ u_threshold= -1.1433462743336297878837243843452621503410E4; return z; #endif } +hidden_def (__expl) weak_alias (__expl, expl) From 3a85895fa3e15b8d53856161a4ba3950d44ea285 Mon Sep 17 00:00:00 2001 From: Petar Bogdanovic Date: Thu, 29 Oct 2009 08:17:48 -0700 Subject: [PATCH 10/47] Fix mixing IPv4 and IPv6 name server in resolv.conf. --- ChangeLog | 5 +++++ resolv/res_send.c | 52 +++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f1b00539e..637f05a04f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-29 Ulrich Drepper + + * resolv/res_send.c (__libc_res_nsend): Fix copying of IPv4 server + addresses. Patch by Petar Bogdanovic . + 2009-10-24 Joseph Myers * sysdeps/ieee754/ldbl-128/w_expl.c: Add hidden_def (__expl). diff --git a/resolv/res_send.c b/resolv/res_send.c index 4c14db1bf5..fa48bd98d1 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -219,33 +219,33 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp) { int ns; - if (inp->sin6_family == AF_INET) { - struct sockaddr_in *in4p = (struct sockaddr_in *) inp; + if (inp->sin6_family == AF_INET) { + struct sockaddr_in *in4p = (struct sockaddr_in *) inp; in_port_t port = in4p->sin_port; in_addr_t addr = in4p->sin_addr.s_addr; - for (ns = 0; ns < MAXNS; ns++) { - const struct sockaddr_in *srv = + for (ns = 0; ns < MAXNS; ns++) { + const struct sockaddr_in *srv = (struct sockaddr_in *)EXT(statp).nsaddrs[ns]; - if ((srv != NULL) && (srv->sin_family == AF_INET) && - (srv->sin_port == port) && - (srv->sin_addr.s_addr == INADDR_ANY || - srv->sin_addr.s_addr == addr)) - return (1); - } - } else if (inp->sin6_family == AF_INET6) { - for (ns = 0; ns < MAXNS; ns++) { - const struct sockaddr_in6 *srv = EXT(statp).nsaddrs[ns]; - if ((srv != NULL) && (srv->sin6_family == AF_INET6) && - (srv->sin6_port == inp->sin6_port) && - !(memcmp(&srv->sin6_addr, &in6addr_any, - sizeof (struct in6_addr)) && - memcmp(&srv->sin6_addr, &inp->sin6_addr, - sizeof (struct in6_addr)))) - return (1); - } - } + if ((srv != NULL) && (srv->sin_family == AF_INET) && + (srv->sin_port == port) && + (srv->sin_addr.s_addr == INADDR_ANY || + srv->sin_addr.s_addr == addr)) + return (1); + } + } else if (inp->sin6_family == AF_INET6) { + for (ns = 0; ns < MAXNS; ns++) { + const struct sockaddr_in6 *srv = EXT(statp).nsaddrs[ns]; + if ((srv != NULL) && (srv->sin6_family == AF_INET6) && + (srv->sin6_port == inp->sin6_port) && + !(memcmp(&srv->sin6_addr, &in6addr_any, + sizeof (struct in6_addr)) && + memcmp(&srv->sin6_addr, &inp->sin6_addr, + sizeof (struct in6_addr)))) + return (1); + } + } return (0); } @@ -445,7 +445,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, malloc(sizeof (struct sockaddr_in6)); if (EXT(statp).nsaddrs[n] != NULL) { memset (mempcpy(EXT(statp).nsaddrs[n], - &statp->nsaddr_list[ns], + &statp->nsaddr_list[n], sizeof (struct sockaddr_in)), '\0', sizeof (struct sockaddr_in6) @@ -1003,7 +1003,7 @@ send_dg(res_state statp, int orig_anssizp = *anssizp; struct timespec now, timeout, finish; struct pollfd pfd[1]; - int ptimeout; + int ptimeout; struct sockaddr_in6 from; int resplen, n; @@ -1050,7 +1050,7 @@ send_dg(res_state statp, evSubTime(&timeout, &finish, &now); need_recompute = 0; } - /* Convert struct timespec in milliseconds. */ + /* Convert struct timespec in milliseconds. */ ptimeout = timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000; n = 0; @@ -1244,7 +1244,7 @@ send_dg(res_state statp, /* record the error */ statp->_flags |= RES_F_EDNS0ERR; goto err_out; - } + } #endif if (!(statp->options & RES_INSECURE2) && (recvresp1 || !res_queriesmatch(buf, buf + buflen, From 92934e8b848fd55483606addf37687913a980bca Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 08:33:12 -0700 Subject: [PATCH 11/47] Allow compat handling of getutmp. --- ChangeLog | 5 +++++ sysdeps/gnu/getutmp.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 637f05a04f..0f5c45a7a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-29 Ulrich Drepper + [BZ #10847] + * sysdeps/gnu/getutmp.c: Allow compatibility code to play around with + getutmpx symbol. + + [BZ #10823] * resolv/res_send.c (__libc_res_nsend): Fix copying of IPv4 server addresses. Patch by Petar Bogdanovic . diff --git a/sysdeps/gnu/getutmp.c b/sysdeps/gnu/getutmp.c index 7b6d7713ea..9647c252e2 100644 --- a/sysdeps/gnu/getutmp.c +++ b/sysdeps/gnu/getutmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2009 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 @@ -19,10 +19,12 @@ #include #include #include +#ifndef _UTMPX_H /* This is an ugly hack but we must not see the getutmpx declaration. */ -#define getutmpx XXXgetutmpx -#include -#undef getutmpx +# define getutmpx XXXgetutmpx +# include +# undef getutmpx +#endif void getutmp (const struct utmpx *utmpx, struct utmp *utmp) From d9e8f9ec5557cc6ffcc154eafc4d2f2348df7b6b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 08:48:17 -0700 Subject: [PATCH 12/47] Define F_OWNER_* and f_owner_ex for Linux targets. --- ChangeLog | 9 +++++++++ sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/ia64/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/s390/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/sh/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/sparc/bits/fcntl.h | 19 ++++++++++++++++++- sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h | 19 ++++++++++++++++++- 8 files changed, 135 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f5c45a7a1..4ad59290dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-10-29 Ulrich Drepper + * sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Define F_OWNER_* + and f_owner_ex. + * sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/s390/bits/fcntl.h: Likewise. + [BZ #10847] * sysdeps/gnu/getutmp.c: Allow compatibility code to play around with getutmpx symbol. diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 0138b69d78..06b9e48acc 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -168,6 +168,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD diff --git a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index b0af8697f8..9677394773 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/IA64. - Copyright (C) 1999, 2000, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2004,2006,2007,2009 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 @@ -161,6 +161,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index f7ce2aacc8..ea0ee6e551 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/PowerPC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -168,6 +168,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD diff --git a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index 0e6cbfda85..3a11c48e04 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 2000,2001,2002,2004,2006,2007 Free Software Foundation, Inc. + Copyright (C) 2000,2001,2002,2004,2006,2007,2009 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 @@ -183,6 +183,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD diff --git a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index dee02a101e..03ecd72fea 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -168,6 +168,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index 6d5e82676d..2b8c9bd102 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/SPARC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -187,6 +187,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index 2041f5764e..29c956cdf8 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/x86-64. - Copyright (C) 2001, 2002, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2001,2002,2004,2006,2007,2009 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 @@ -182,6 +182,23 @@ struct flock64 }; #endif +#ifdef __USE_GNU +/* Owner types. */ +enum __pid_type + { + F_OWNER_TID = 0, /* Kernel thread. */ + F_OWNER_PID, /* Process. */ + F_OWNER_GID /* Process group. */ + }; + +/* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */ +struct f_owner_ex + { + enum __pid_type type; /* Owner type of ID. */ + __pid_t pid; /* ID of owner. */ + }; +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_BSD From 81c84bd9022328127f46d0484d254848911ea198 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 10:12:59 -0700 Subject: [PATCH 13/47] Fix F_GETOWN on some Linux archs. The syscall conventions on some Linux archs prevented F_GETOWN from working correctly in some situations. This can be rectified when using the new F_GETOWN_EX command. --- ChangeLog | 7 ++++ sysdeps/unix/sysv/linux/fcntl.c | 42 ++++++++++++++++++++--- sysdeps/unix/sysv/linux/i386/fcntl.c | 29 +++++++++++++++- sysdeps/unix/sysv/linux/kernel-features.h | 5 +++ 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ad59290dc..a54bc10848 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-10-29 Ulrich Drepper + [BZ #10840] + * sysdeps/unix/sysv/linux/kernel-features.h: Define + __ASSUME_F_GETOWN_EX. + * sysdeps/unix/sysv/linux/fcntl.c: Implement F_GETOWN using F_GETOWN_EX + if possible. + * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. + * sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Define F_OWNER_* and f_owner_ex. * sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h: Likewise. diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index 1f5aca14a4..b19654c625 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2003, 2004, 2009 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,6 +23,40 @@ #include #include +#include + + +#ifdef __ASSUME_F_GETOWN_EX +# define miss_F_GETOWN_EX 0 +#else +static int miss_F_GETOWN_EX; +#endif + + +static int +do_fcntl (int fd, int cmd, void *arg) +{ + if (cmd != F_GETOWN || miss_F_GETOWN_EX) + return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); + + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + +#ifndef __ASSUME_F_GETOWN_EX + if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL) + { + res = INLINE_SYSCALL (fcntl, 3, fd, F_GETOWN, arg); + miss_F_GETOWN_EX = 1; + return res; + } +#endif + + __set_errno (INTERNAL_SYSCALL_ERRNO (res, err)); + return -1; +} #ifndef NO_CANCELLATION @@ -36,7 +70,7 @@ __fcntl_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); + return do_fcntl (fd, cmd, arg); } #endif @@ -52,11 +86,11 @@ __libc_fcntl (int fd, int cmd, ...) va_end (ap); if (SINGLE_THREAD_P || cmd != F_SETLKW) - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); + return do_fcntl (fd, cmd, arg); int oldtype = LIBC_CANCEL_ASYNC (); - int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); + int result = do_fcntl (fd, cmd, arg); LIBC_CANCEL_RESET (oldtype); diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c index b27373d24b..5544d6e0d9 100644 --- a/sysdeps/unix/sysv/linux/i386/fcntl.c +++ b/sysdeps/unix/sysv/linux/i386/fcntl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000,2002,2003,2004,2006 Free Software Foundation, Inc. +/* Copyright (C) 2000,2002,2003,2004,2006,2009 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,6 +30,13 @@ int __have_no_fcntl64; #endif +#ifdef __ASSUME_F_GETOWN_EX +# define miss_F_GETOWN_EX 0 +#else +static int miss_F_GETOWN_EX; +#endif + + #if defined NO_CANCELLATION && __ASSUME_FCNTL64 == 0 # define __fcntl_nocancel __libc_fcntl #endif @@ -119,6 +126,26 @@ __fcntl_nocancel (int fd, int cmd, ...) assert (F_SETLK - F_SETLKW == F_SETLK64 - F_SETLKW64); return INLINE_SYSCALL (fcntl, 3, fd, cmd + F_SETLK - F_SETLK64, &fl); } + case F_GETOWN: + if (! miss_F_GETOWN_EX) + { + INTERNAL_SYSCALL_DECL (err); + struct f_owner_ex fex; + int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex); + if (!INTERNAL_SYSCALL_ERROR_P (res, err)) + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; + +#ifndef __ASSUME_F_GETOWN_EX + if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL) + miss_F_GETOWN_EX = 1; + else +#endif + { + __set_errno (INTERNAL_SYSCALL_ERRNO (res, err)); + return -1; + } + } + /* FALLTHROUGH */ default: return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); } diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index ff065effb5..f48e644e09 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -542,3 +542,8 @@ # define __ASSUME_PREADV 1 # define __ASSUME_PWRITEV 1 #endif + +/* Support for F_GETOWN_EX was introduced in 2.6.32. */ +#if __LINUX_KERNEL_VERSION >= 0x020620 +# define __ASSUME_F_GETOWN_EX 1 +#endif From 8d55628106730c5e318fa3673b69588509d983f2 Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Thu, 29 Oct 2009 10:40:55 -0700 Subject: [PATCH 14/47] Add macros for DSCP markings. --- ChangeLog | 4 ++++ sysdeps/generic/netinet/ip.h | 38 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a54bc10848..a169cee2c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + [BZ #10789] + * sysdeps/generic/netinet/ip.h: Define IPTOS_ENC* and IPTOS_DSCP* + macros. Patch by Philip Prindeville . + [BZ #10840] * sysdeps/unix/sysv/linux/kernel-features.h: Define __ASSUME_F_GETOWN_EX. diff --git a/sysdeps/generic/netinet/ip.h b/sysdeps/generic/netinet/ip.h index fc91440527..38bd7556da 100644 --- a/sysdeps/generic/netinet/ip.h +++ b/sysdeps/generic/netinet/ip.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2009 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 @@ -152,6 +153,41 @@ struct ip_timestamp #define IPVERSION 4 /* IP version number */ #define IP_MAXPACKET 65535 /* maximum packet size */ +/* + * Definitions for Explicit Congestion Notification (ECN) + * + * Taken from RFC-3168, Section 5. + */ + +#define IPTOS_ECN_MASK 0x03 +#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK) +#define IPTOS_ECN_NOT_ECT 0x00 +#define IPTOS_ECN_ECT1 0x01 +#define IPTOS_ECN_ECT0 0x02 +#define IPTOS_ECN_CE 0x03 + +/* + * Definitions for IP differentiated services code points (DSCP) + * + * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3. + */ + +#define IPTOS_DSCP_MASK 0xfc +#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK) +#define IPTOS_DSCP_AF11 0x28 +#define IPTOS_DSCP_AF12 0x30 +#define IPTOS_DSCP_AF13 0x38 +#define IPTOS_DSCP_AF21 0x48 +#define IPTOS_DSCP_AF22 0x50 +#define IPTOS_DSCP_AF23 0x58 +#define IPTOS_DSCP_AF31 0x68 +#define IPTOS_DSCP_AF32 0x70 +#define IPTOS_DSCP_AF33 0x78 +#define IPTOS_DSCP_AF41 0x88 +#define IPTOS_DSCP_AF42 0x90 +#define IPTOS_DSCP_AF43 0x98 +#define IPTOS_DSCP_EF 0xb8 + /* * Definitions for IP type of service (ip_tos) */ From d94760f944cebf05b239dd0b65c3b40a5577013b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 11:02:34 -0700 Subject: [PATCH 15/47] Fix getttyname on Linux when called for different devices. If a second call to ttyname is not for the same type of device (e.g., serial vs ptty) the prefix of the buffer was wrong. Don't rely on the previous content, always reinitialize it. --- ChangeLog | 7 ++++++- sysdeps/unix/sysv/linux/ttyname.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a169cee2c5..25bb3255df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ 2009-10-29 Ulrich Drepper + [BZ #10784] + * sysdeps/unix/sysv/linux/ttyname.c (getttyname): Always copy name + of the directory we look at into the static buffer if there is one + at the start of the loop. + [BZ #10789] * sysdeps/generic/netinet/ip.h: Define IPTOS_ENC* and IPTOS_DSCP* - macros. Patch by Philip Prindeville . + macros. Patch by Philip Prindeville . [BZ #10840] * sysdeps/unix/sysv/linux/kernel-features.h: Define diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 1b79787515..69af6adc65 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,1996-2002,2006 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,1996-2002,2006,2009 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 @@ -59,6 +59,11 @@ getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat) return NULL; } + /* Prepare for the loop. If we already have a buffer copy the directory + name we look at into it. */ + if (devlen < namelen) + *((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/'; + while ((d = __readdir64 (dirstream)) != NULL) if ((d->d_fileno == myino || *dostat) && strcmp (d->d_name, "stdin") From 22bc5239e1c7d97b0642af6c135af994586f8e82 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 29 Oct 2009 11:25:20 -0700 Subject: [PATCH 16/47] Fix wrap-around in memusage. --- ChangeLog | 5 +++++ malloc/memusage.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25bb3255df..99088df6ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-29 Andreas Schwab + + * malloc/memusage.c (update_data): Fix index wraparound handling + so that buffer_cnt is actually reset. + 2009-10-29 Ulrich Drepper [BZ #10784] diff --git a/malloc/memusage.c b/malloc/memusage.c index fcd58dc684..382261c1c4 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -163,15 +163,16 @@ update_data (struct header *result, size_t len, size_t old_len) if (fd != -1) { uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1); - if (idx >= 2 * buffer_size) + if (idx + 1 >= 2 * buffer_size) { /* We try to reset the counter to the correct range. If this fails because of another thread increasing the counter it does not matter since that thread will take care of the correction. */ - uatomic32_t reset = idx % (2 * buffer_size); - catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx); - idx = reset; + uatomic32_t reset = (idx + 1) % (2 * buffer_size); + catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1); + if (idx >= 2 * buffer_size) + idx = reset - 1; } assert (idx < 2 * DEFAULT_BUFFER_SIZE); From d79eccd6dd8aa2038a9775689a7072fe3ceb40dc Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 29 Oct 2009 11:27:53 -0700 Subject: [PATCH 17/47] Fix errno handling in posix_openpt. The implementation of posix_openpt on Linux can fail in a few extra ways if the appropriate pseudo filesystems are not mounted etc. In some of these cases we have to explicitly set errno. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/getpt.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99088df6ad..c46e962933 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-27 Andreas Schwab + + * sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Make sure + errno is always set when returning unsuccessfully. + 2009-10-29 Andreas Schwab * malloc/memusage.c (update_data): Fix index wraparound handling diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c index bb1ea47643..6b26fdfcdc 100644 --- a/sysdeps/unix/sysv/linux/getpt.c +++ b/sysdeps/unix/sysv/linux/getpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg , 1998. @@ -64,9 +64,10 @@ __posix_openpt (oflag) } /* If /dev/pts is not mounted then the UNIX98 pseudo terminals - are not usable. */ + are not usable. */ __close (fd); have_no_dev_ptmx = 1; + __set_errno (ENOENT); } else { @@ -76,6 +77,8 @@ __posix_openpt (oflag) return -1; } } + else + __set_errno (ENOENT); return -1; } From e0f471a1187cdfcb029c80819da52b4c12e352f5 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 13:45:10 -0700 Subject: [PATCH 18/47] Print timestamp in nscd debug messages. --- ChangeLog | 6 ++++++ nscd/dbg_log.c | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c46e962933..b673fd9580 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-29 Ulrich Drepper + + [BZ #10742] + * nscd/dbg_log.c (dbg_log): Print timestamp before the message text. + Based on patch by Jeffrey Bastian . + 2009-10-27 Andreas Schwab * sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Make sure diff --git a/nscd/dbg_log.c b/nscd/dbg_log.c index 5e192c97dd..fa99dac88f 100644 --- a/nscd/dbg_log.c +++ b/nscd/dbg_log.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998, 2000, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (c) 1998, 2000, 2004, 2005, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -53,14 +53,23 @@ void dbg_log (const char *fmt,...) { va_list ap; - char msg[512], msg2[512]; + char msg2[512]; va_start (ap, fmt); - vsnprintf (msg2, sizeof (msg), fmt, ap); + vsnprintf (msg2, sizeof (msg2), fmt, ap); if (debug_level > 0) { - snprintf (msg, sizeof (msg), "%d: %s%s", getpid (), msg2, + time_t t = time (NULL); + + struct tm now; + localtime_r (&t, &now); + + char buf[256]; + strftime (buf, sizeof (buf), "%c", &now); + + char msg[512]; + snprintf (msg, sizeof (msg), "%s - %d: %s%s", buf, getpid (), msg2, msg2[strlen (msg2) - 1] == '\n' ? "" : "\n"); if (dbgout) { From 67854c131c2ba8c013debf466b20cb13fffa120b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 14:19:33 -0700 Subject: [PATCH 19/47] Fix repairing of memusage trace files. --- ChangeLog | 5 +++++ malloc/memusagestat.c | 32 +++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b673fd9580..48dfde724d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-29 Ulrich Drepper + [BZ #10717] + * malloc/memusagestat.c (main): Fix repairing of trace files. We also + have to compute maxsize_total, we have to update the variables, and + the also_total handling must happen after the repair. + [BZ #10742] * nscd/dbg_log.c (dbg_log): Print timestamp before the message text. Based on patch by Jeffrey Bastian . diff --git a/malloc/memusagestat.c b/malloc/memusagestat.c index bf33175415..4d57f2cc23 100644 --- a/malloc/memusagestat.c +++ b/malloc/memusagestat.c @@ -191,13 +191,6 @@ main (int argc, char *argv[]) maxsize_heap = headent[1].heap; maxsize_stack = headent[1].stack; maxsize_total = headent[0].stack; - if (also_total) - { - /* We use one scale and since we also draw the total amount of - memory used we have to adapt the maximum. */ - maxsize_heap = maxsize_total; - maxsize_stack = maxsize_total; - } if (maxsize_heap == 0 && maxsize_stack == 0) { @@ -210,18 +203,31 @@ main (int argc, char *argv[]) { if (read (fd, &next, sizeof (next)) == 0) break; - if (next.heap > headent[1].heap) - headent[1].heap = next.heap; - if (next.stack > headent[1].stack) - headent[1].stack = next.stack; + if (next.heap > maxsize_heap) + maxsize_heap = next.heap; + if (next.stack > maxsize_stack) + maxsize_stack = next.stack; + if (maxsize_heap + maxsize_stack > maxsize_total) + maxsize_total = maxsize_heap + maxsize_stack; } + headent[0].stack = maxsize_total; + headent[1].heap = maxsize_heap; + headent[1].stack = maxsize_stack; headent[1].time_low = next.time_low; headent[1].time_high = next.time_high; /* Write the computed values in the file. */ - lseek (fd, sizeof (struct entry), SEEK_SET); - write (fd, &headent[1], sizeof (struct entry)); + lseek (fd, 0, SEEK_SET); + write (fd, headent, 2 * sizeof (struct entry)); + } + + if (also_total) + { + /* We use one scale and since we also draw the total amount of + memory used we have to adapt the maximum. */ + maxsize_heap = maxsize_total; + maxsize_stack = maxsize_total; } start_time = ((uint64_t) headent[0].time_high) << 32 | headent[0].time_low; From cc88b371a5072242b76d80fae5483d1777029c71 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 16:03:07 -0700 Subject: [PATCH 20/47] Fix return value of puts for very long strings. --- ChangeLog | 4 ++++ libio/ioputs.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48dfde724d..15a753bf98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + [BZ #10780] + * libio/ioputs.c (_IO_puts): Make sure to not return a number which + overflows the int return type. + [BZ #10717] * malloc/memusagestat.c (main): Fix repairing of trace files. We also have to compute maxsize_total, we have to update the variables, and diff --git a/libio/ioputs.c b/libio/ioputs.c index 2f43e994e3..7fa5db5f1f 100644 --- a/libio/ioputs.c +++ b/libio/ioputs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1996,1997,1998,1999,2003 Free Software Foundation, Inc. +/* Copyright (C) 1993,1996-1999,2003,2009 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,6 +27,7 @@ #include "libioP.h" #include +#include int _IO_puts (str) @@ -40,7 +41,7 @@ _IO_puts (str) || _IO_fwide (_IO_stdout, -1) == -1) && _IO_sputn (_IO_stdout, str, len) == len && _IO_putc_unlocked ('\n', _IO_stdout) != EOF) - result = len + 1; + result = MIN (INT_MAX, len + 1); _IO_release_lock (_IO_stdout); return result; From 1a9e411e2aba14573ddc2ced4a5ee927a01031e0 Mon Sep 17 00:00:00 2001 From: Joe Landers Date: Thu, 29 Oct 2009 16:22:01 -0700 Subject: [PATCH 21/47] Fix memory leak in NIS grp database handling. --- ChangeLog | 4 ++++ nis/nss_nis/nis-grp.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15a753bf98..81defae3f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + [BZ #10713] + * nis/nss_nis/nis-grp.c (internal_nis_endgrent): Start freeing blocks + from intern.start. Patch by Joe Landers . + [BZ #10780] * libio/ioputs.c (_IO_puts): Make sure to not return a number which overflows the int return type. diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 6e36cf828f..071d8a2a55 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-1999, 2001-2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1996-1999,2001-2004,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -55,7 +55,7 @@ internal_nis_endgrent (void) oldkeylen = 0; } - struct response_t *curr = intern.next; + struct response_t *curr = intern.start; while (curr != NULL) { @@ -203,16 +203,16 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, } if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) - { - free (result); - *errnop = ERANGE; - return NSS_STATUS_TRYAGAIN; - } + { + free (result); + *errnop = ERANGE; + return NSS_STATUS_TRYAGAIN; + } char *p = strncpy (buffer, result, len); buffer[len] = '\0'; while (isspace (*p)) - ++p; + ++p; if (!batch_read) free (result); @@ -280,7 +280,7 @@ _nss_nis_getgrnam_r (const char *name, struct group *grp, enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; + *errnop = errno; return retval; } @@ -329,7 +329,7 @@ _nss_nis_getgrgid_r (gid_t gid, struct group *grp, enum nss_status retval = yperr2nss (yperr); if (retval == NSS_STATUS_TRYAGAIN) - *errnop = errno; + *errnop = errno; return retval; } From c240c3a58f21d72982e74a485bd7c4900f188876 Mon Sep 17 00:00:00 2001 From: Joe Landers Date: Thu, 29 Oct 2009 19:59:59 -0700 Subject: [PATCH 22/47] Fix error handling in NIS. A buffer was freed even though it wasn't allocated as expected. Do this only when !batch_read. --- ChangeLog | 4 ++++ nis/nss_nis/nis-grp.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 81defae3f5..d2089f5e2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + [BZ #10692] + * nis/nss_nis/nis-grp.c (internal_nis_getgrent_r): Don't free buffer + in error if batch_read. Patch by Joe Landers . + [BZ #10713] * nis/nss_nis/nis-grp.c (internal_nis_endgrent): Start freeing blocks from intern.start. Patch by Joe Landers . diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c index 071d8a2a55..6ad30eb1bb 100644 --- a/nis/nss_nis/nis-grp.c +++ b/nis/nss_nis/nis-grp.c @@ -204,7 +204,8 @@ internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen, if (__builtin_expect ((size_t) (len + 1) > buflen, 0)) { - free (result); + if (!batch_read) + free (result); *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } From 584715c3a9b0030729e0a8504c820b3bd8d9353d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 21:01:24 -0700 Subject: [PATCH 23/47] Fix AIO when thread creation failed. Several bugs fixed when we needed to create a thread to work on AIO requests but failed and there is not one running. --- ChangeLog | 5 +++++ sysdeps/pthread/aio_misc.c | 26 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2089f5e2c..8bbc93c6cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-29 Ulrich Drepper + [BZ #10643] + * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): If thread + creation filed, remove the request from the 'requests' list and signal + the caller that the request is finished. + [BZ #10692] * nis/nss_nis/nis-grp.c (internal_nis_getgrent_r): Don't free buffer in error if batch_read. Patch by Joe Landers . diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c index fd3fcbb755..c82acbbc2d 100644 --- a/sysdeps/pthread/aio_misc.c +++ b/sysdeps/pthread/aio_misc.c @@ -1,5 +1,5 @@ /* Handle general operations. - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -372,9 +372,13 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) /* Simply enqueue it after the running one according to the priority. */ + last = NULL; while (runp->next_prio != NULL && runp->next_prio->aiocbp->aiocb.__abs_prio >= prio) - runp = runp->next_prio; + { + last = runp; + runp = runp->next_prio; + } newp->next_prio = runp->next_prio; runp->next_prio = newp; @@ -403,6 +407,7 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) } newp->next_prio = NULL; + last = NULL; } if (running == yes) @@ -423,7 +428,8 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) running = newp->running = allocated; /* Now try to start a thread. */ - if (aio_create_helper_thread (&thid, handle_fildes_io, newp) == 0) + result = aio_create_helper_thread (&thid, handle_fildes_io, newp); + if (result == 0) /* We managed to enqueue the request. All errors which can happen now can be recognized by calls to `aio_return' and `aio_error'. */ @@ -434,10 +440,14 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) running = newp->running = yes; if (nthreads == 0) - /* We cannot create a thread in the moment and there is - also no thread running. This is a problem. `errno' is - set to EAGAIN if this is only a temporary problem. */ - result = -1; + { + /* We cannot create a thread in the moment and there is + also no thread running. This is a problem. `errno' is + set to EAGAIN if this is only a temporary problem. */ + __aio_remove_request (last, newp, 0); + } + else + result = 0; } } } @@ -459,6 +469,8 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) { /* Something went wrong. */ __aio_free_request (newp); + aiocbp->aiocb.__error_code = result; + __set_errno (result); newp = NULL; } From 801720e63b20e3b8215764ff0d68a29534ca7e62 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 21:33:26 -0700 Subject: [PATCH 24/47] Fix compat handling in *at functions. When passed an empty string for the filename, the compat code using /proc in all *at functions did the wrong thing. --- ChangeLog | 21 +++++++++++++++++++ sysdeps/unix/sysv/linux/faccessat.c | 8 ++++++- sysdeps/unix/sysv/linux/fchmodat.c | 8 ++++++- sysdeps/unix/sysv/linux/fchownat.c | 8 ++++++- sysdeps/unix/sysv/linux/futimesat.c | 8 ++++++- sysdeps/unix/sysv/linux/fxstatat.c | 8 ++++++- sysdeps/unix/sysv/linux/fxstatat64.c | 8 ++++++- sysdeps/unix/sysv/linux/i386/fchownat.c | 8 ++++++- sysdeps/unix/sysv/linux/i386/fxstatat.c | 8 ++++++- sysdeps/unix/sysv/linux/linkat.c | 8 ++++++- sysdeps/unix/sysv/linux/mkdirat.c | 8 ++++++- sysdeps/unix/sysv/linux/openat.c | 8 ++++++- sysdeps/unix/sysv/linux/powerpc/fchownat.c | 8 ++++++- sysdeps/unix/sysv/linux/readlinkat.c | 8 ++++++- sysdeps/unix/sysv/linux/renameat.c | 14 ++++++++++++- sysdeps/unix/sysv/linux/symlinkat.c | 8 ++++++- sysdeps/unix/sysv/linux/unlinkat.c | 8 ++++++- .../unix/sysv/linux/wordsize-64/fxstatat.c | 8 ++++++- sysdeps/unix/sysv/linux/xmknodat.c | 8 ++++++- 19 files changed, 153 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bbc93c6cb..593de06d1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2009-10-29 Ulrich Drepper + [BZ #10609] + * sysdeps/unix/sysv/linux/faccessat.c: Fix handling of empty parameters + for file names in case the syscall is not available. + * sysdeps/unix/sysv/linux/fchmodat.c: Likewise. + * sysdeps/unix/sysv/linux/fchownat.c: Likewise. + * sysdeps/unix/sysv/linux/futimesat.c: Likewise. + * sysdeps/unix/sysv/linux/fxstatat.c: Likewise. + * sysdeps/unix/sysv/linux/fxstatat64.c: Likewise. + * sysdeps/unix/sysv/linux/i386/fchownat.c: Likewise. + * sysdeps/unix/sysv/linux/i386/fxstatat.c: Likewise. + * sysdeps/unix/sysv/linux/linkat.c: Likewise. + * sysdeps/unix/sysv/linux/mkdirat.c: Likewise. + * sysdeps/unix/sysv/linux/openat.c: Likewise. + * sysdeps/unix/sysv/linux/powerpc/fchownat.c: Likewise. + * sysdeps/unix/sysv/linux/readlinkat.c: Likewise. + * sysdeps/unix/sysv/linux/renameat.c: Likewise. + * sysdeps/unix/sysv/linux/symlinkat.c: Likewise. + * sysdeps/unix/sysv/linux/unlinkat.c: Likewise. + * sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c: Likewise. + * sysdeps/unix/sysv/linux/xmknodat.c: Likewise. + [BZ #10643] * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): If thread creation filed, remove the request from the 'requests' list and signal diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index 10b903d076..c154deb40f 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -1,5 +1,5 @@ /* Test for access to file, relative to open directory. Linux version. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 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 @@ -72,6 +72,12 @@ faccessat (fd, file, mode, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index 8b420153f1..051691230d 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -1,5 +1,5 @@ /* Change the protections of file relative to open directory. Linux version. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 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 @@ -71,6 +71,12 @@ fchmodat (fd, file, mode, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/fchownat.c b/sysdeps/unix/sysv/linux/fchownat.c index 0f731775b3..db43755694 100644 --- a/sysdeps/unix/sysv/linux/fchownat.c +++ b/sysdeps/unix/sysv/linux/fchownat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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,6 +66,12 @@ fchownat (fd, file, owner, group, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/futimesat.c b/sysdeps/unix/sysv/linux/futimesat.c index 7c96b78045..bb83e74faf 100644 --- a/sysdeps/unix/sysv/linux/futimesat.c +++ b/sysdeps/unix/sysv/linux/futimesat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -76,6 +76,12 @@ futimesat (fd, file, tvp) else if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c index 1b9add40d7..dd5c9bc684 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c +++ b/sysdeps/unix/sysv/linux/fxstatat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2007, 2009 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 @@ -85,6 +85,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index cb932b8e59..442e4ca989 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005,2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -90,6 +90,12 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/i386/fchownat.c b/sysdeps/unix/sysv/linux/i386/fchownat.c index 34acf10c27..1b02fde459 100644 --- a/sysdeps/unix/sysv/linux/i386/fchownat.c +++ b/sysdeps/unix/sysv/linux/i386/fchownat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -63,6 +63,12 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c index 94f6e81186..37757937b3 100644 --- a/sysdeps/unix/sysv/linux/i386/fxstatat.c +++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -86,6 +86,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/linkat.c b/sysdeps/unix/sysv/linux/linkat.c index cfd0e18223..b2b7b0386b 100644 --- a/sysdeps/unix/sysv/linux/linkat.c +++ b/sysdeps/unix/sysv/linux/linkat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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,6 +66,12 @@ linkat (fromfd, from, tofd, to, flags) if (fromfd != AT_FDCWD && from[0] != '/') { size_t filelen = strlen (from); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ - the file descriptor number diff --git a/sysdeps/unix/sysv/linux/mkdirat.c b/sysdeps/unix/sysv/linux/mkdirat.c index 3c190085ce..aa89d08730 100644 --- a/sysdeps/unix/sysv/linux/mkdirat.c +++ b/sysdeps/unix/sysv/linux/mkdirat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -57,6 +57,12 @@ mkdirat (fd, file, mode) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index 45b566f2d0..7916c71105 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2007, 2009 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 @@ -110,6 +110,12 @@ OPENAT_NOT_CANCEL (fd, file, oflag, mode) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/powerpc/fchownat.c b/sysdeps/unix/sysv/linux/powerpc/fchownat.c index 67c570648a..46f6d97c6b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/fchownat.c +++ b/sysdeps/unix/sysv/linux/powerpc/fchownat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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,6 +66,12 @@ fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/readlinkat.c b/sysdeps/unix/sysv/linux/readlinkat.c index 1361596503..1e9a9b649f 100644 --- a/sysdeps/unix/sysv/linux/readlinkat.c +++ b/sysdeps/unix/sysv/linux/readlinkat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -59,6 +59,12 @@ readlinkat (fd, path, buf, len) if (fd != AT_FDCWD && path[0] != '/') { size_t pathlen = strlen (path); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/renameat.c b/sysdeps/unix/sysv/linux/renameat.c index 86bb75a7b0..160bdc4903 100644 --- a/sysdeps/unix/sysv/linux/renameat.c +++ b/sysdeps/unix/sysv/linux/renameat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -135,6 +135,12 @@ renameat (oldfd, old, newfd, new) if (oldfd != AT_FDCWD && old[0] != '/') { size_t filelen = strlen (old); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ - the file descriptor number @@ -154,6 +160,12 @@ renameat (oldfd, old, newfd, new) if (newfd != AT_FDCWD && new[0] != '/') { size_t filelen = strlen (new); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ - the file descriptor number diff --git a/sysdeps/unix/sysv/linux/symlinkat.c b/sysdeps/unix/sysv/linux/symlinkat.c index 4cfc924bfc..d2704777bd 100644 --- a/sysdeps/unix/sysv/linux/symlinkat.c +++ b/sysdeps/unix/sysv/linux/symlinkat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -57,6 +57,12 @@ symlinkat (from, tofd, to) if (tofd != AT_FDCWD && to[0] != '/') { size_t tolen = strlen (to); + if (__builtin_expect (tolen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/unlinkat.c b/sysdeps/unix/sysv/linux/unlinkat.c index 0a07a8a875..bb5f89810b 100644 --- a/sysdeps/unix/sysv/linux/unlinkat.c +++ b/sysdeps/unix/sysv/linux/unlinkat.c @@ -1,5 +1,5 @@ /* unlinkat -- Remove a link by relative name. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 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 @@ -64,6 +64,12 @@ unlinkat (fd, file, flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c index 8b1c932ba9..cc41fdedc0 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c +++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -72,6 +72,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c index ef27b686cc..177b3db986 100644 --- a/sysdeps/unix/sysv/linux/xmknodat.c +++ b/sysdeps/unix/sysv/linux/xmknodat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2009 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 @@ -72,6 +72,12 @@ __xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev) if (fd != AT_FDCWD && file[0] != '/') { size_t filelen = strlen (file); + if (__builtin_expect (filelen == 0, 0)) + { + __set_errno (ENOENT); + return -1; + } + static const char procfd[] = "/proc/self/fd/%d/%s"; /* Buffer for the path name we are going to use. It consists of - the string /proc/self/fd/ From 5debe363133d76bfaf60597392ce2629a1920506 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 21:41:19 -0700 Subject: [PATCH 25/47] Bump timeout for utmp operations to 10s. --- ChangeLog | 3 +++ login/utmp_file.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 593de06d1a..0ed1d5cdd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-10-29 Ulrich Drepper + [BZ #10564] + * login/utmp_file.c (TIMEOUT): Increase to 10. + [BZ #10609] * sysdeps/unix/sysv/linux/faccessat.c: Fix handling of empty parameters for file names in case the syscall is not available. diff --git a/login/utmp_file.c b/login/utmp_file.c index f32144d1f7..d19a2c9c4d 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2004, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1996-2004, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper and Paul Janzen , 1996. @@ -45,7 +45,7 @@ static struct utmp last_entry; /* Locking timeout. */ #ifndef TIMEOUT -# define TIMEOUT 1 +# define TIMEOUT 10 #endif /* Do-nothing handler for locking timeout. */ From ee6f35389c751b93fd7298ec02f642587d996c71 Mon Sep 17 00:00:00 2001 From: John Sullivan Date: Thu, 29 Oct 2009 21:50:35 -0700 Subject: [PATCH 26/47] Fix typos in format strings of malloc_info. --- ChangeLog | 4 ++++ malloc/malloc.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ed1d5cdd1..ed055a7f3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + [BZ #10553] + * malloc/malloc.c (malloc_info): Fix typos in format strings. + Patch by John Sullivan . + [BZ #10564] * login/utmp_file.c (TIMEOUT): Increase to 10. diff --git a/malloc/malloc.c b/malloc/malloc.c index 79ba6b6f06..ea10d17f85 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -6474,8 +6474,8 @@ malloc_info (int options, FILE *fp) fprintf (fp, "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" "\n" "\n", From 5c53736b52d5032171813d813d4a7ad505102b61 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Thu, 29 Oct 2009 22:04:58 -0700 Subject: [PATCH 27/47] Fix nss_files if /etc/hosts is missing. --- ChangeLog | 5 +++++ nss/nss_files/files-hosts.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ed055a7f3e..3fae505586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-29 Ulrich Drepper + [BZ #10540] + * nss/nss_files/files-hosts.c (_nss_files_gethostbyname4_r): If + /etc/hosts does not exist set errnop and herrnop appropriately. + Patch by Steve Langasek . + [BZ #10553] * malloc/malloc.c (malloc_info): Fix typos in format strings. Patch by John Sullivan . diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c index 7b69d47fcb..68fb969937 100644 --- a/nss/nss_files/files-hosts.c +++ b/nss/nss_files/files-hosts.c @@ -1,5 +1,5 @@ /* Hosts file parser in nss_files module. - Copyright (C) 1996-2001, 2003-2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1996-2001, 2003-2008, 2009 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 @@ -423,6 +423,11 @@ _nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, if (! keep_stream) internal_endent (); } + else + { + *errnop = errno; + *herrnop = NO_DATA; + } __libc_lock_unlock (lock); From ea547a1a6e350b758fcda76b919b3aa774752318 Mon Sep 17 00:00:00 2001 From: Anders Johansson Date: Thu, 29 Oct 2009 22:18:26 -0700 Subject: [PATCH 28/47] Fix a few asserts and IO calls in nscd. The nscd/*cache.c files contain assert()s, writeall() and sendfileall() calls that invalidly use together &dataset->resp and total where either dataset or dataset->head.recsize should be used instead one of the components. In the writeall() and sendfileall() cases, it is unlikely to matter in practice, but the assertions can fail sometimes without a proper reason. --- ChangeLog | 9 +++++++++ nscd/aicache.c | 6 +++--- nscd/grpcache.c | 6 +++--- nscd/hstcache.c | 2 +- nscd/initgrcache.c | 6 +++--- nscd/pwdcache.c | 6 +++--- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fae505586..47241cc9ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-18 Anders Johansson + + * nscd/aicache.c: Fix mixing up dataset and dataset->resp + offsets and record sizes in assert()s and response sending. + * nscd/grpcache.c: Likewise. + * nscd/hstcache.c: Likewise. + * nscd/initgrcache.c: Likewise. + * nscd/pwdcache.c: Likewise. + 2009-10-29 Ulrich Drepper [BZ #10540] diff --git a/nscd/aicache.c b/nscd/aicache.c index 524c0a63af..992357d2fe 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -453,13 +453,13 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, { assert (db->wr_fd != -1); assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head + total + assert ((char *) dataset - (char *) db->head + total <= (sizeof (struct database_pers_head) + db->head->module * sizeof (ref_t) + db->head->data_size)); ssize_t written; written = sendfileall (fd, db->wr_fd, (char *) &dataset->resp - - (char *) db->head, total); + - (char *) db->head, dataset->head.recsize); # ifndef __ASSUME_SENDFILE if (written == -1 && errno == ENOSYS) goto use_write; @@ -470,7 +470,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, use_write: # endif #endif - writeall (fd, &dataset->resp, total); + writeall (fd, &dataset->resp, dataset->head.recsize); } goto out; diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 184d53898c..bd101c675d 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -295,14 +295,14 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, { assert (db->wr_fd != -1); assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head + assert ((char *) dataset - (char *) db->head + total <= (sizeof (struct database_pers_head) + db->head->module * sizeof (ref_t) + db->head->data_size)); written = sendfileall (fd, db->wr_fd, (char *) &dataset->resp - - (char *) db->head, total); + - (char *) db->head, dataset->head.recsize); # ifndef __ASSUME_SENDFILE if (written == -1 && errno == ENOSYS) goto use_write; @@ -313,7 +313,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, use_write: # endif #endif - written = writeall (fd, &dataset->resp, total); + written = writeall (fd, &dataset->resp, dataset->head.recsize); } /* Add the record to the database. But only if it has not been diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 51e2273960..228f6fd8ab 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -337,7 +337,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, { assert (db->wr_fd != -1); assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head + assert ((char *) dataset - (char *) db->head + total <= (sizeof (struct database_pers_head) + db->head->module * sizeof (ref_t) diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index c33aaf315f..8195b6609e 100644 --- a/nscd/initgrcache.c +++ b/nscd/initgrcache.c @@ -350,14 +350,14 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, { assert (db->wr_fd != -1); assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head + assert ((char *) dataset - (char *) db->head + total <= (sizeof (struct database_pers_head) + db->head->module * sizeof (ref_t) + db->head->data_size)); written = sendfileall (fd, db->wr_fd, (char *) &dataset->resp - - (char *) db->head, total); + - (char *) db->head, dataset->head.recsize); # ifndef __ASSUME_SENDFILE if (written == -1 && errno == ENOSYS) goto use_write; @@ -368,7 +368,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, use_write: # endif #endif - written = writeall (fd, &dataset->resp, total); + written = writeall (fd, &dataset->resp, dataset->head.recsize); } diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index 2338e7e1e0..75f2221e88 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -290,14 +290,14 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, { assert (db->wr_fd != -1); assert ((char *) &dataset->resp > (char *) db->data); - assert ((char *) &dataset->resp - (char *) db->head + assert ((char *) dataset - (char *) db->head + total <= (sizeof (struct database_pers_head) + db->head->module * sizeof (ref_t) + db->head->data_size)); written = sendfileall (fd, db->wr_fd, (char *) &dataset->resp - - (char *) db->head, total); + - (char *) db->head, dataset->head.recsize ); # ifndef __ASSUME_SENDFILE if (written == -1 && errno == ENOSYS) goto use_write; @@ -308,7 +308,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, use_write: # endif #endif - written = writeall (fd, &dataset->resp, total); + written = writeall (fd, &dataset->resp, dataset->head.recsize); } From cfff39ea98ec7765e5339dfdee3388749f75713a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=C3=BEat=20SABIQ?= Date: Thu, 29 Oct 2009 22:21:58 -0700 Subject: [PATCH 29/47] Fix first day of week and a few spellings in crh_UA locale. --- localedata/ChangeLog | 5 +++++ localedata/locales/crh_UA | 37 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 81468d5df3..5e02534758 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,8 @@ +2009-10-29 Ulrich Drepper + + * locales/crh_UA: Fix first day of week and a few spellings. + Patch by Reþat SABIQ . + 2009-10-15 Ulrich Drepper * SUPPORTED (SUPPORTED-LOCALES): Add ps_AF.UTF-8. diff --git a/localedata/locales/crh_UA b/localedata/locales/crh_UA index 5dfab24d90..a6fceeae0a 100644 --- a/localedata/locales/crh_UA +++ b/localedata/locales/crh_UA @@ -1,14 +1,14 @@ comment_char % escape_char / % -% Crimean Tatar Language Locale for Ukraine (latin) -% Source: Reshat Sabiq (Reat) -% Contact: Reshat Sabiq (Reat) -% Email: +% Crimean Tatar (Crimean Turkish) Language Locale for Ukraine (latin) +% Source: Reat SABIQ +% Contact: Reat SABIQ +% Email: % Language: crh % Territory: UA -% Revision: 0.3 -% Date: 2006-10-09 +% Revision: 0.4 +% Date: 2009-08-16 % Application: general % Users: general % Charset: UTF-8 @@ -16,17 +16,17 @@ escape_char / % for commercial purposes. LC_IDENTIFICATION -title "Crimean Tatar language locale for Ukraine" +title "Crimean Tatar (Crimean Turkish) language locale for Ukraine" source "" address "" -contact "Reshat Sabiq (Reat)" -email "tatar.iqtelif.i18n@gmail.com" +contact "Reat SABIQ" +email "tilde.birlik@gmail.com" tel "" fax "" language "Crimean Tatar" territory "Ukraine" -revision "0.3" -date "2006-10-09" +revision "0.4" +date "2009-08-16" category crh_UA:2000;LC_IDENTIFICATION category crh_UA:2000;LC_CTYPE @@ -124,11 +124,10 @@ copy "tr_TR" END LC_CTYPE LC_MESSAGES -% TODO: No is "yoq"; is it OK that it corresponds with English "yes"? yesstr "" -nostr "" -yesexpr "" -noexpr "" +nostr "" +yesexpr "" +noexpr "" END LC_MESSAGES LC_MONETARY @@ -157,9 +156,9 @@ END LC_NUMERIC LC_TIME day "";/ - "";/ + "";/ "";/ - "";/ + "";/ "";/ "";/ "" @@ -198,12 +197,14 @@ d_t_fmt "/ " d_fmt "" t_fmt "" -am_pm "";"" +am_pm "";"" t_fmt_ampm "/ " date_fmt "/ / " +first_weekday 2 +first_workday 2 END LC_TIME LC_PAPER From b0e477a9aa6dafd5b9780b2248e61620e2c83d32 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 29 Oct 2009 22:30:25 -0700 Subject: [PATCH 30/47] Define yesstr and nostr for a few locales. --- localedata/ChangeLog | 4 ++++ localedata/locales/POSIX | 4 ++++ localedata/locales/en_US | 2 ++ 3 files changed, 10 insertions(+) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 5e02534758..bfb384d9e4 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,5 +1,9 @@ 2009-10-29 Ulrich Drepper + * locales/POSIX: Define yesstr and nostr. + * locales/en_US: Likewise. + Patch by Petr Machata . + * locales/crh_UA: Fix first day of week and a few spellings. Patch by Reþat SABIQ . diff --git a/localedata/locales/POSIX b/localedata/locales/POSIX index 00c5b4a0d6..457ce6ec64 100644 --- a/localedata/locales/POSIX +++ b/localedata/locales/POSIX @@ -328,4 +328,8 @@ LC_MESSAGES yesexpr "" # noexpr "" +# +yesstr "" +# +nostr "" END LC_MESSAGES diff --git a/localedata/locales/en_US b/localedata/locales/en_US index 38425e815e..a41f5bc310 100644 --- a/localedata/locales/en_US +++ b/localedata/locales/en_US @@ -132,6 +132,8 @@ END LC_TIME LC_MESSAGES yesexpr "" noexpr "" +yesstr "" +nostr "" END LC_MESSAGES LC_PAPER From 204fcca27c0f787daf95ca6f0c787842eb8a50d8 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 22:43:08 -0700 Subject: [PATCH 31/47] Fix IA-64 and S390 sigevent definitions. --- ChangeLog | 7 +++++++ sysdeps/unix/sysv/linux/ia64/bits/siginfo.h | 6 +++++- sysdeps/unix/sysv/linux/s390/bits/siginfo.h | 10 +++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47241cc9ae..3d869910a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-10-29 Ulrich Drepper + + [BZ #10446] + * sysdeps/unix/sysv/linux/ia64/bits/siginfo.h: Match sigevent + definition to the kernel's. + * sysdeps/unix/sysv/linux/s390/bits/siginfo.h: Likewise. + 2009-08-18 Anders Johansson * nscd/aicache.c: Fix mixing up dataset and dataset->resp diff --git a/sysdeps/unix/sysv/linux/ia64/bits/siginfo.h b/sysdeps/unix/sysv/linux/ia64/bits/siginfo.h index 66310c65b3..240ebbc9e1 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/siginfo.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/siginfo.h @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Linux/ia64 version. - Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2000-2004, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang . @@ -310,6 +310,10 @@ typedef struct sigevent { int _pad[__SIGEV_PAD_SIZE]; + /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the + thread to receive the signal. */ + __pid_t _tid; + struct { void (*_function) (sigval_t); /* Function to start. */ diff --git a/sysdeps/unix/sysv/linux/s390/bits/siginfo.h b/sysdeps/unix/sysv/linux/s390/bits/siginfo.h index 0b79853137..55b3f88c0a 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/siginfo.h +++ b/sysdeps/unix/sysv/linux/s390/bits/siginfo.h @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. S/390 version. - Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2009 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 @@ #if (!defined __have_sigval_t \ && (defined _SIGNAL_H || defined __need_siginfo_t \ - || defined __need_sigevent_t)) + || defined __need_sigevent_t)) # define __have_sigval_t 1 /* Type for data associated with a signal. */ @@ -96,7 +96,7 @@ typedef struct siginfo struct { void *si_addr; /* Faulting insn/memory ref. */ - int si_trapno; + int si_trapno; } _sigfault; /* SIGPOLL. */ @@ -282,6 +282,10 @@ typedef struct sigevent { int _pad[__SIGEV_PAD_SIZE]; + /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the + thread to receive the signal. */ + __pid_t _tid; + struct { void (*_function) (sigval_t); /* Function to start. */ From bf20990de0c0478cd974717237c5738d036ad8dc Mon Sep 17 00:00:00 2001 From: Nicolo' Chieffo Date: Thu, 29 Oct 2009 22:49:17 -0700 Subject: [PATCH 32/47] Fix date_fmt for it_IT and it_CH locales. --- localedata/ChangeLog | 5 +++++ localedata/locales/it_CH | 6 +++--- localedata/locales/it_IT | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index bfb384d9e4..08695423ba 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,5 +1,10 @@ 2009-10-29 Ulrich Drepper + [BZ #10425] + * locales/it_IT: Fix date_fmt. + * locales/it_CH: Likewise. + Patch by Nicolo' Chieffo . + * locales/POSIX: Define yesstr and nostr. * locales/en_US: Likewise. Patch by Petr Machata . diff --git a/localedata/locales/it_CH b/localedata/locales/it_CH index 4fdc50a4b8..7ea13ad106 100644 --- a/localedata/locales/it_CH +++ b/localedata/locales/it_CH @@ -97,9 +97,9 @@ d_fmt "" t_fmt "" am_pm "";"" t_fmt_ampm "" -date_fmt "/ -/ -" +date_fmt "\ +\ +" END LC_TIME LC_PAPER diff --git a/localedata/locales/it_IT b/localedata/locales/it_IT index 105f40c9f4..ec8151c68a 100644 --- a/localedata/locales/it_IT +++ b/localedata/locales/it_IT @@ -121,9 +121,9 @@ d_fmt "" t_fmt "" am_pm "";"" t_fmt_ampm "" -date_fmt "/ -/ -" +date_fmt "\ +\ +" END LC_TIME LC_PAPER From 75ded9bcdff960829743aca4a984a4cbf40a3585 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 23:01:58 -0700 Subject: [PATCH 33/47] Initialize local variable in resolver. When the DNS server doesn't reply at all we possibly tested an unitialized variable. --- ChangeLog | 3 +++ resolv/res_send.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3d869910a9..c622ad5d42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-10-29 Ulrich Drepper + [BZ #10391] + * resolv/res_send.c (send_dg): Initialize resplen. + [BZ #10446] * sysdeps/unix/sysv/linux/ia64/bits/siginfo.h: Match sigevent definition to the kernel's. diff --git a/resolv/res_send.c b/resolv/res_send.c index fa48bd98d1..e2bbfcc83f 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -1005,7 +1005,8 @@ send_dg(res_state statp, struct pollfd pfd[1]; int ptimeout; struct sockaddr_in6 from; - int resplen, n; + int resplen = 0; + int n; /* * Compute time for the total operation. From 471d4931f83644cf86ae2f044cc29c95b9d12109 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 2009 23:21:18 -0700 Subject: [PATCH 34/47] Add sml entry to ISO 639 list. --- ChangeLog | 2 ++ locale/iso-639.def | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index c622ad5d42..247856944e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2009-10-29 Ulrich Drepper + * locale/iso-639.def: Add sml entry. + [BZ #10391] * resolv/res_send.c (send_dg): Initialize resplen. diff --git a/locale/iso-639.def b/locale/iso-639.def index de78aa1c0d..bb12d82692 100644 --- a/locale/iso-639.def +++ b/locale/iso-639.def @@ -84,6 +84,7 @@ DEFINE_LANGUAGE_CODE3 ("Caucasian (Other)", cau, cau) DEFINE_LANGUAGE_CODE3 ("Cebuano", ceb, ceb) DEFINE_LANGUAGE_CODE3 ("Celtic (Other)", cel, cel) DEFINE_LANGUAGE_CODE3 ("Central American Indian (Other)", cai, cai) +DEFINE_LANGUAGE_CODE3 ("Central Sama", sml, sml) DEFINE_LANGUAGE_CODE3 ("Chagatai", chg, chg) DEFINE_LANGUAGE_CODE3 ("Chamic languages", cmc, cmc) DEFINE_LANGUAGE_CODE ("Chamorro", ch, cha, cha) From 7f3146e7895f248dd2f655e9e5895abebb2bf506 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Oct 2009 00:11:07 -0700 Subject: [PATCH 35/47] Implement mkstemps and mkstemps64. --- ChangeLog | 24 ++++++++++++++++++++++ NEWS | 6 +++--- include/stdio.h | 3 ++- libio/oldtmpfile.c | 4 ++-- misc/Makefile | 2 +- misc/Versions | 3 +++ misc/mkdtemp.c | 4 ++-- misc/mkostemp.c | 4 ++-- misc/mkostemp64.c | 4 ++-- misc/mkstemp.c | 4 ++-- misc/mkstemp64.c | 4 ++-- misc/mkstemps.c | 43 ++++++++++++++++++++++++++++++++++++++++ misc/mkstemps64.c | 40 +++++++++++++++++++++++++++++++++++++ misc/mktemp.c | 4 ++-- stdio-common/tempnam.c | 4 ++-- stdio-common/tempname.c | 5 +++-- stdio-common/tmpfile.c | 4 ++-- stdio-common/tmpnam.c | 4 ++-- stdio-common/tmpnam_r.c | 4 ++-- stdlib/stdlib.h | 27 +++++++++++++++++++++++-- sysdeps/posix/tempname.c | 14 ++++++------- 21 files changed, 173 insertions(+), 38 deletions(-) create mode 100644 misc/mkstemps.c create mode 100644 misc/mkstemps64.c diff --git a/ChangeLog b/ChangeLog index 247856944e..fb2c8ebf06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2009-10-30 Ulrich Drepper + + [BZ #10349] + * sysdeps/posix/tempname.c (__gen_tempname): Take new second + parameter, specifying length of prefix. + * stdio-common/tempname.c: Likewise. + * include/stdio.h: Adjust prototypes. + * libio/oldtmpfile.c: Adjust caller. + * misc/mkdtemp.c: Likewise. + * misc/mkostemp.c: Likewise. + * misc/mkostemp64.c: Likewise. + * misc/mkstemp.c: Likewise. + * misc/mkstemp64.c: Likewise. + * misc/mktemp.c: Likewise. + * stdio-common/tempnam.c: Likewise. + * stdio-common/tmpfile.c: Likewise. + * stdio-common/tmpnam.c: Likewise. + * stdio-common/tmpnam_r.c: Likewise. + * misc/mkstemps.c: New file. + * misc/mkstemps64.c: New file. + * stdlib/stdlib.h: Add prototypes. + * misc/Makefile (routines): Add mkstemps and mkstemps64. + * misc/Versions: Export mkstemps and mkstemps64 for GLIBC_2.11. + 2009-10-29 Ulrich Drepper * locale/iso-639.def: Add sml entry. diff --git a/NEWS b/NEWS index 9044ec0f49..04a6b8c6bf 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2009-10-15 +GNU C Library NEWS -- history of user-visible changes. 2009-10-29 Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc. See the end for copying conditions. @@ -7,7 +7,7 @@ using `glibc' in the "product" field. Version 2.11 -* New interfaces: execvpe, pthread_sigqueue +* New interfaces: execvpe, pthread_sigqueue, mkstemps, mkstemps64 Implemented by Ulrich Drepper. * Checking version of longjmp added that fails if an uninitialized stack @@ -18,7 +18,7 @@ Version 2.11 * New optimized string functions for x86-64: strstr, strcasestr, memcmp, strcspn, strpbrk, strspn, strcpy, stpcpy, strncpy, strcmp (SSE2, SSE4.2), - strncmp (SSE2, SSE4.2). + strncmp (SSE2, SSE4.2), strchr (SSE4.2), strrchr (SSE4.2). Contributed by H.J. Lu. strlen, rawmemchr, strcmp (SSSE3), strncmp (SSSE3). diff --git a/include/stdio.h b/include/stdio.h index 444aa39006..6b053b8aee 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -80,7 +80,8 @@ extern int __path_search (char *__tmpl, size_t __tmpl_len, __const char *__dir, __const char *__pfx, int __try_tempdir); -extern int __gen_tempname (char *__tmpl, int __flags, int __kind); +extern int __gen_tempname (char *__tmpl, int __suffixlen, int __flags, + int __kind); /* The __kind argument to __gen_tempname may be one of: */ # define __GT_FILE 0 /* create a file */ # define __GT_DIR 1 /* create a directory */ diff --git a/libio/oldtmpfile.c b/libio/oldtmpfile.c index d85467a392..c9e4750cba 100644 --- a/libio/oldtmpfile.c +++ b/libio/oldtmpfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1993,1996-2000,2003,2004,2007 +/* Copyright (C) 1991,1993,1996-2000,2003,2004,2007,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -39,7 +39,7 @@ __old_tmpfile (void) if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0)) return NULL; - fd = __gen_tempname (buf, 0, __GT_FILE); + fd = __gen_tempname (buf, 0, 0, __GT_FILE); if (fd < 0) return NULL; diff --git a/misc/Makefile b/misc/Makefile index 13576347b9..6243647d1d 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -45,7 +45,7 @@ routines := brk sbrk sstk ioctl \ gethostid sethostid \ revoke vhangup \ swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \ - mkostemp mkostemp64 \ + mkostemp mkostemp64 mkstemps mkstemps64 \ ualarm usleep \ gtty stty \ ptrace \ diff --git a/misc/Versions b/misc/Versions index c930eea944..b883e3df25 100644 --- a/misc/Versions +++ b/misc/Versions @@ -140,4 +140,7 @@ libc { GLIBC_2.10 { preadv; preadv64; pwritev; pwritev64; } + GLIBC_2.11 { + mkstemps; mkstemps64; + } } diff --git a/misc/mkdtemp.c b/misc/mkdtemp.c index 7cd3a44f94..6200e9e4fb 100644 --- a/misc/mkdtemp.c +++ b/misc/mkdtemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ char * mkdtemp (template) char *template; { - if (__gen_tempname (template, 0, __GT_DIR)) + if (__gen_tempname (template, 0, 0, __GT_DIR)) return NULL; else return template; diff --git a/misc/mkostemp.c b/misc/mkostemp.c index 372e4f3c0f..a2023ab470 100644 --- a/misc/mkostemp.c +++ b/misc/mkostemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2007, 2009 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 @@ -32,5 +32,5 @@ mkostemp (template, flags) char *template; int flags; { - return __gen_tempname (template, flags, __GT_FILE); + return __gen_tempname (template, 0, flags, __GT_FILE); } diff --git a/misc/mkostemp64.c b/misc/mkostemp64.c index 2ae730991e..18a506dd60 100644 --- a/misc/mkostemp64.c +++ b/misc/mkostemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2007, 2009 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,5 +29,5 @@ mkostemp64 (template, flags) char *template; int flags; { - return __gen_tempname (template, flags | O_LARGEFILE, __GT_FILE); + return __gen_tempname (template, 0, flags | O_LARGEFILE, __GT_FILE); } diff --git a/misc/mkstemp.c b/misc/mkstemp.c index d3edca0791..bd3bbc88b2 100644 --- a/misc/mkstemp.c +++ b/misc/mkstemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2007, 2009 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 @@ -31,5 +31,5 @@ int mkstemp (template) char *template; { - return __gen_tempname (template, 0, __GT_FILE); + return __gen_tempname (template, 0, 0, __GT_FILE); } diff --git a/misc/mkstemp64.c b/misc/mkstemp64.c index 400bf47d06..c384bc71e6 100644 --- a/misc/mkstemp64.c +++ b/misc/mkstemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2007, 2009 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,5 +28,5 @@ int mkstemp64 (template) char *template; { - return __gen_tempname (template, O_LARGEFILE, __GT_FILE); + return __gen_tempname (template, 0, O_LARGEFILE, __GT_FILE); } diff --git a/misc/mkstemps.c b/misc/mkstemps.c new file mode 100644 index 0000000000..e5ff089443 --- /dev/null +++ b/misc/mkstemps.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2009 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. */ + +#include +#include +#include + +#ifndef __GT_FILE +# define __GT_FILE 0 +#endif + +/* Generate a unique temporary file name from TEMPLATE. The last six + characters before a suffix of length SUFFIXLEN of TEMPLATE must be + "XXXXXX"; they are replaced with a string that makes the filename + unique. Then open the file and return a fd. */ +int +mkstemps (template, suffixlen) + char *template; + int suffixlen; +{ + if (suffixlen < 0) + { + __set_errno (EINVAL); + return -1; + } + + return __gen_tempname (template, suffixlen, 0, __GT_FILE); +} diff --git a/misc/mkstemps64.c b/misc/mkstemps64.c new file mode 100644 index 0000000000..cf7562b48f --- /dev/null +++ b/misc/mkstemps64.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2000, 2007, 2009 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. */ + +#include +#include +#include +#include + +/* Generate a unique temporary file name from TEMPLATE. The last six + characters before a suffix of length SUFFIXLEN of TEMPLATE must be + "XXXXXX"; they are replaced with a string that makes the filename + unique. Then open the file and return a fd. */ +int +mkstemps64 (template, suffixlen) + char *template; + int suffixlen; +{ + if (suffixlen < 0) + { + __set_errno (EINVAL); + return -1; + } + + return __gen_tempname (template, suffixlen, O_LARGEFILE, __GT_FILE); +} diff --git a/misc/mktemp.c b/misc/mktemp.c index f600d7ea7c..c42fd5ec44 100644 --- a/misc/mktemp.c +++ b/misc/mktemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2007, 2009 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 @@ char * mktemp (template) char *template; { - if (__gen_tempname (template, 0, __GT_NOCREATE) < 0) + if (__gen_tempname (template, 0, 0, __GT_NOCREATE) < 0) /* We return the null string if we can't find a unique file name. */ template[0] = '\0'; diff --git a/stdio-common/tempnam.c b/stdio-common/tempnam.c index 055604fb79..3604a2d267 100644 --- a/stdio-common/tempnam.c +++ b/stdio-common/tempnam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1993,1996-2000,2007 Free Software Foundation, Inc. +/* Copyright (C) 1991,1993,1996-2000,2007,2009 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 @@ -34,7 +34,7 @@ tempnam (const char *dir, const char *pfx) if (__path_search (buf, FILENAME_MAX, dir, pfx, 1)) return NULL; - if (__gen_tempname (buf, 0, __GT_NOCREATE)) + if (__gen_tempname (buf, 0, 0, __GT_NOCREATE)) return NULL; return __strdup (buf); diff --git a/stdio-common/tempname.c b/stdio-common/tempname.c index 2c7bcdee0f..02ee34fe8e 100644 --- a/stdio-common/tempname.c +++ b/stdio-common/tempname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 95-98, 99, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 95-99, 2007, 2009 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 @@ -47,8 +47,9 @@ stub_warning (__path_search) */ int -__gen_tempname (tmpl, flags, kind) +__gen_tempname (tmpl, suffixlen, flags, kind) char *tmpl; + int suffixlen; int flags; int kind; { diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c index b90051346b..69963fd4a9 100644 --- a/stdio-common/tmpfile.c +++ b/stdio-common/tmpfile.c @@ -1,5 +1,5 @@ /* Open a stdio stream on an anonymous temporary file. Generic/POSIX version. - Copyright (C) 1991,1993,1996-2000,2002,2003,2007 + Copyright (C) 1991,1993,1996-2000,2002,2003,2007,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -48,7 +48,7 @@ tmpfile (void) #ifdef FLAGS flags = FLAGS; #endif - fd = __gen_tempname (buf, flags, __GT_FILE); + fd = __gen_tempname (buf, 0, flags, __GT_FILE); if (fd < 0) return NULL; diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c index f1c16446d5..93d47a1212 100644 --- a/stdio-common/tmpnam.c +++ b/stdio-common/tmpnam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1993,1996-1999,2000,2007 Free Software Foundation, Inc. +/* Copyright (C) 1991,1993,1996-2000,2007,2009 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 @@ -39,7 +39,7 @@ tmpnam (char *s) 0)) return NULL; - if (__builtin_expect (__gen_tempname (tmpbuf, 0, __GT_NOCREATE), 0)) + if (__builtin_expect (__gen_tempname (tmpbuf, 0, 0, __GT_NOCREATE), 0)) return NULL; if (s == NULL) diff --git a/stdio-common/tmpnam_r.c b/stdio-common/tmpnam_r.c index 60c42866a7..d252bafbb2 100644 --- a/stdio-common/tmpnam_r.c +++ b/stdio-common/tmpnam_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1993,1996-1999,2000,2007 Free Software Foundation, Inc. +/* Copyright (C) 1991,1993,1996-2000,2007,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ tmpnam_r (char *s) if (__path_search (s, L_tmpnam, NULL, NULL, 0)) return NULL; - if (__gen_tempname (s, 0, __GT_NOCREATE)) + if (__gen_tempname (s, 0, 0, __GT_NOCREATE)) return NULL; return s; diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 1b88ce6a52..6fe6a03bf3 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -50,7 +50,7 @@ __BEGIN_DECLS # if defined __GNUC__ && !defined __cplusplus # define __WAIT_INT(status) \ (__extension__ (((union { __typeof(status) __in; int __i; }) \ - { .__in = (status) }).__i)) + { .__in = (status) }).__i)) # else # define __WAIT_INT(status) (*(int *) &(status)) # endif @@ -609,7 +609,7 @@ extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur; Returns a file descriptor open on the file for reading and writing, or -1 if it cannot create a uniquely-named file. - This function is a possible cancellation points and therefore not + This function is a possible cancellation point and therefore not marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int mkstemp (char *__template) __nonnull ((1)) __wur; @@ -626,6 +626,29 @@ extern int mkstemp64 (char *__template) __nonnull ((1)) __wur; # endif #endif +#ifdef __USE_MISC +/* Similar to mkstemp, but the template can have a suffix after the + XXXXXX. The length of the suffix is specified in the second + parameter. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen), + mkstemps64) __nonnull ((1)) __wur; +# else +# define mkstemps mkstemps64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkstemps64 (char *__template, int __suffixlen) + __nonnull ((1)) __wur; +# endif +#endif + #if defined __USE_BSD || defined __USE_XOPEN2K8 /* Create a unique temporary directory from TEMPLATE. The last six characters of TEMPLATE must be "XXXXXX"; diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index be979d8c8a..57ce5a942c 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2001, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1991-2001, 2006, 2007, 2009 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 @@ -210,9 +210,9 @@ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /* Generate a temporary file name based on TMPL. TMPL must match the - rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed - does not exist at the time of the call to __gen_tempname. TMPL is - overwritten with the result. + rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). + The name constructed does not exist at the time of the call to + __gen_tempname. TMPL is overwritten with the result. KIND may be one of: __GT_NOCREATE: simply verify that the name does not exist @@ -223,7 +223,7 @@ static const char letters[] = We use a clever algorithm to get hard-to-predict names. */ int -__gen_tempname (char *tmpl, int flags, int kind) +__gen_tempname (char *tmpl, int suffixlen, int flags, int kind) { int len; char *XXXXXX; @@ -251,14 +251,14 @@ __gen_tempname (char *tmpl, int flags, int kind) #endif len = strlen (tmpl); - if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX")) + if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6)) { __set_errno (EINVAL); return -1; } /* This is where the Xs start. */ - XXXXXX = &tmpl[len - 6]; + XXXXXX = &tmpl[len - 6 - suffixlen]; /* Get some more or less random data. */ #ifdef RANDOM_BITS From 675a462ba31fe48fd8513c186287b8fa5d26f655 Mon Sep 17 00:00:00 2001 From: Neskie Manuel Date: Fri, 30 Oct 2009 00:22:34 -0700 Subject: [PATCH 36/47] Fix accents in shs_CA locale. --- localedata/ChangeLog | 6 +++++ localedata/locales/shs_CA | 56 +++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 08695423ba..b91a5fa6c3 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,9 @@ +2009-10-30 Ulrich Drepper + + [BZ #10319] + * locales/shs_CA: Fix accents. + Patch by Neskie Manuel . + 2009-10-29 Ulrich Drepper [BZ #10425] diff --git a/localedata/locales/shs_CA b/localedata/locales/shs_CA index e6c52c7672..6c1b77f19d 100644 --- a/localedata/locales/shs_CA +++ b/localedata/locales/shs_CA @@ -55,10 +55,10 @@ reorder-after % Present in iso14651_t1, but these definitions seem to have been % removed from latest iso14651 tables. reorder-after - "";"";"";IGNORE + "";"";"";IGNORE reorder-after - "";"";"";IGNORE + "";"";"";IGNORE reorder-end @@ -80,41 +80,41 @@ LC_TIME abday "";/ "";/ "";/ - "";/ - "";/ - "";/ - "" -day "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "" + "";/ + "";/ + "";/ + "" +day "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" abmon "";/ "";/ "";/ - "";/ + "";/ "";/ "";/ "";/ - "";/ + "";/ "";/ - "";/ + "";/ "";/ "" -mon "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "";/ - "" +mon "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "";/ + "" d_t_fmt "" d_fmt "" t_fmt "" From 0d2f180dd0f933ab651058d5dc691bcd4f7f1c28 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Oct 2009 00:27:27 -0700 Subject: [PATCH 37/47] Add a few defines to . --- ChangeLog | 5 +++++ sysdeps/gnu/netinet/udp.h | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fb2c8ebf06..5fd0861f23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-30 Ulrich Drepper + [BZ #10315] + * sysdeps/gnu/netinet/udp.h: Define UDP_CORK, UDP_ENCAP, + UDP_ENCAP_ESPINUDP_NON_IKE, UDP_ENCAP_ESPINUDP, and + UDP_ENCAP_L2TPINUDP. + [BZ #10349] * sysdeps/posix/tempname.c (__gen_tempname): Take new second parameter, specifying length of prefix. diff --git a/sysdeps/gnu/netinet/udp.h b/sysdeps/gnu/netinet/udp.h index 45b69f7499..ae1beb9e1a 100644 --- a/sysdeps/gnu/netinet/udp.h +++ b/sysdeps/gnu/netinet/udp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 95, 96, 97, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993,1995-1997,2004,2009 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 @@ -74,6 +74,16 @@ struct udphdr }; #endif +/* UDP socket options */ +#define UDP_CORK 1 /* Never send partially complete segments. */ +#define UDP_ENCAP 100 /* Set the socket to accept + encapsulated packets. */ + +/* UDP encapsulation types */ +#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ +#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ +#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */ + #define SOL_UDP 17 /* sockopt level for UDP */ #endif /* netinet/udp.h */ From 9fd76770c304ac30a344150d6a56bd6f873b2be0 Mon Sep 17 00:00:00 2001 From: Jorge Guerrero Date: Fri, 30 Oct 2009 00:31:32 -0700 Subject: [PATCH 38/47] Define am_pm , t_fmt_ampm, first_weekday for es_CO locale. --- localedata/ChangeLog | 4 ++++ localedata/locales/es_CO | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index b91a5fa6c3..01edd7d1f5 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,5 +1,9 @@ 2009-10-30 Ulrich Drepper + [BZ #10312] + * locales/es_CO: Define am_pm , t_fmt_ampm, first_weekday. + Patch by Jorge Guerrero . + [BZ #10319] * locales/shs_CA: Fix accents. Patch by Neskie Manuel . diff --git a/localedata/locales/es_CO b/localedata/locales/es_CO index bb983d7e7f..4c1de136be 100644 --- a/localedata/locales/es_CO +++ b/localedata/locales/es_CO @@ -117,11 +117,14 @@ mon "";/ d_t_fmt "" d_fmt "" t_fmt "" -am_pm "";"" -t_fmt_ampm "" +am_pm "";"" +t_fmt_ampm "/ +" date_fmt "/ / " +% FIXME: found in CLDR +first_weekday 2 END LC_TIME LC_PAPER From 77799d9d9b3f9c937bd6de035b724b9b272c9227 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 30 Oct 2009 00:39:38 -0700 Subject: [PATCH 39/47] Implement IFUNC for PPC. --- ChangeLog | 22 +++++++++- elf/elf.h | 23 ++++++---- sysdeps/powerpc/powerpc32/dl-irel.h | 45 ++++++++++++++++++++ sysdeps/powerpc/powerpc32/dl-machine.c | 6 ++- sysdeps/powerpc/powerpc32/dl-machine.h | 8 +++- sysdeps/powerpc/powerpc64/dl-irel.h | 58 ++++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/dl-machine.h | 39 ++++++++++++++++- 7 files changed, 187 insertions(+), 14 deletions(-) create mode 100644 sysdeps/powerpc/powerpc32/dl-irel.h create mode 100644 sysdeps/powerpc/powerpc64/dl-irel.h diff --git a/ChangeLog b/ChangeLog index 5fd0861f23..3359bc20bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,24 @@ -2009-10-30 Ulrich Drepper +2009-07-30 Alan Modra + + * elf/elf.h (R_PPC_NUM, R_PPC64_NUM): Delete unused and incorrect. + (R_PPC_REL16*): Correct comments. + (R_PPC_IRELATIVE, R_PPC64_IRELATIVE, R_PPC64_JMP_IREL): Define. + (R_PPC64_REL16, R_PPC64_REL16_LO, R_PPC64_REL16_HI, + R_PPC64_REL16_HA): Define. + * sysdeps/powerpc/powerpc32/dl-irel.h: New file. + * sysdeps/powerpc/powerpc64/dl-irel.h: New file. + * sysdeps/powerpc/powerpc32/dl-machine.c (__elf_machine_fixup_plt): + Delete unused "reloc" param. + (__process_machine_rela): Handle R_PPC_IRELATIVE. + * sysdeps/powerpc/powerpc32/dl-machine.h (__elf_machine_fixup_plt): + Delete "reloc" param. + (elf_machine_rela): Handle STT_GNU_IFUNC functions and + R_PPC_IRELATIVE. + * sysdeps/powerpc/powerpc64/dl-machine.h (resolve_ifunc): New function. + (elf_machine_rela): Handle STT_GNU_IFUNC functions and new ifunc + relocations. + +d2009-10-30 Ulrich Drepper [BZ #10315] * sysdeps/gnu/netinet/udp.h: Define UDP_CORK, UDP_ENCAP, diff --git a/elf/elf.h b/elf/elf.h index ce6de07e91..c772ff41ad 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -2041,9 +2041,6 @@ typedef Elf32_Addr Elf32_Conflict; #define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ #define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ -/* Keep this the last entry. */ -#define R_PPC_NUM 95 - /* The remaining relocs are from the Embedded ELF ABI, and are not in the SVR4 ELF ABI. */ #define R_PPC_EMB_NADDR32 101 @@ -2071,11 +2068,14 @@ typedef Elf32_Addr Elf32_Conflict; #define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ #define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ +/* GNU extension to support local ifunc. */ +#define R_PPC_IRELATIVE 248 + /* GNU relocs used in PIC code sequences. */ -#define R_PPC_REL16 249 /* word32 (sym-.) */ -#define R_PPC_REL16_LO 250 /* half16 (sym-.)@l */ -#define R_PPC_REL16_HI 251 /* half16 (sym-.)@h */ -#define R_PPC_REL16_HA 252 /* half16 (sym-.)@ha */ +#define R_PPC_REL16 249 /* half16 (sym+add-.) */ +#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */ +#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */ +#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */ /* This is a phony reloc to handle any old fashioned TOC16 references that may still be in object files. */ @@ -2197,8 +2197,13 @@ typedef Elf32_Addr Elf32_Conflict; #define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ #define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ -/* Keep this the last entry. */ -#define R_PPC64_NUM 107 +/* GNU extension to support local ifunc. */ +#define R_PPC64_JMP_IREL 247 +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 /* half16 (sym+add-.) */ +#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */ +#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */ +#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */ /* PowerPC64 specific values for the Dyn d_tag field. */ #define DT_PPC64_GLINK (DT_LOPROC + 0) diff --git a/sysdeps/powerpc/powerpc32/dl-irel.h b/sysdeps/powerpc/powerpc32/dl-irel.h new file mode 100644 index 0000000000..3f204cd7ae --- /dev/null +++ b/sysdeps/powerpc/powerpc32/dl-irel.h @@ -0,0 +1,45 @@ +/* Machine-dependent ELF indirect relocation inline functions. + PowerPC version. + Copyright (C) 2009 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. */ + +#ifndef _DL_IREL_H +#define _DL_IREL_H + +#include +#include + +#define ELF_MACHINE_IRELA 1 + +static inline void +__attribute ((always_inline)) +elf_irela (const Elf32_Rela *reloc) +{ + unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + + if (__builtin_expect (r_type == R_PPC_IRELATIVE, 1)) + { + Elf32_Addr *const reloc_addr = (void *) reloc->r_offset; + Elf32_Addr value = ((Elf32_Addr (*) (void)) reloc->r_addend) (); + *reloc_addr = value; + } + else + __libc_fatal ("unexpected reloc type in static binary"); +} + +#endif /* dl-irel.h */ diff --git a/sysdeps/powerpc/powerpc32/dl-machine.c b/sysdeps/powerpc/powerpc32/dl-machine.c index 71540bd185..ee4c3e0c1c 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.c +++ b/sysdeps/powerpc/powerpc32/dl-machine.c @@ -337,7 +337,7 @@ __elf_machine_runtime_setup (struct link_map *map, int lazy, int profile) } Elf32_Addr -__elf_machine_fixup_plt (struct link_map *map, const Elf32_Rela *reloc, +__elf_machine_fixup_plt (struct link_map *map, Elf32_Addr *reloc_addr, Elf32_Addr finaladdr) { Elf32_Sword delta = finaladdr - (Elf32_Word) reloc_addr; @@ -430,6 +430,10 @@ __process_machine_rela (struct link_map *map, *reloc_addr = finaladdr; return; + case R_PPC_IRELATIVE: + *reloc_addr = ((Elf32_Addr (*) (void)) finaladdr) (); + return; + case R_PPC_UADDR32: ((char *) reloc_addr)[0] = finaladdr >> 24; ((char *) reloc_addr)[1] = finaladdr >> 16; diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h index a50ffdd1c2..6f8d0f506e 100644 --- a/sysdeps/powerpc/powerpc32/dl-machine.h +++ b/sysdeps/powerpc/powerpc32/dl-machine.h @@ -226,7 +226,6 @@ elf_machine_runtime_setup (struct link_map *map, /* Change the PLT entry whose reloc is 'reloc' to call the actual routine. */ extern Elf32_Addr __elf_machine_fixup_plt (struct link_map *map, - const Elf32_Rela *reloc, Elf32_Addr *reloc_addr, Elf32_Addr finaladdr); @@ -237,7 +236,7 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t, { if (map->l_info[DT_PPC(GOT)] == 0) /* Handle old style PLT. */ - return __elf_machine_fixup_plt (map, reloc, reloc_addr, finaladdr); + return __elf_machine_fixup_plt (map, reloc_addr, finaladdr); *reloc_addr = finaladdr; return finaladdr; @@ -317,6 +316,11 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, value = reloc->r_addend; #endif + if (sym != NULL + && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0) + && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)) + value = ((Elf32_Addr (*) (void)) value) (); + /* A small amount of code is duplicated here for speed. In libc, more than 90% of the relocs are R_PPC_RELATIVE; in the X11 shared libraries, 60% are R_PPC_RELATIVE, 24% are R_PPC_GLOB_DAT or diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h new file mode 100644 index 0000000000..6cded5091d --- /dev/null +++ b/sysdeps/powerpc/powerpc64/dl-irel.h @@ -0,0 +1,58 @@ +/* Machine-dependent ELF indirect relocation inline functions. + PowerPC64 version. + Copyright (C) 2009 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. */ + +#ifndef _DL_IREL_H +#define _DL_IREL_H + +#include +#include + +#define ELF_MACHINE_IRELA 1 + +typedef struct +{ + Elf64_Addr fd_func; + Elf64_Addr fd_toc; + Elf64_Addr fd_aux; +} Elf64_FuncDesc; + +static inline void +__attribute ((always_inline)) +elf_irela (const Elf64_Rela *reloc) +{ + unsigned int r_type = ELF64_R_TYPE (reloc->r_info); + + if (__builtin_expect (r_type == R_PPC64_IRELATIVE, 1)) + { + Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; + Elf64_Addr value = ((Elf64_Addr (*) (void)) reloc->r_addend) (); + *reloc_addr = value; + } + else if (__builtin_expect (r_type == R_PPC64_JMP_IREL, 1)) + { + Elf64_Addr *const reloc_addr = (void *) reloc->r_offset; + Elf64_Addr value = ((Elf64_Addr (*) (void)) reloc->r_addend) (); + *(Elf64_FuncDesc *) reloc_addr = *(Elf64_FuncDesc *) value; + } + else + __libc_fatal ("unexpected reloc type in static binary"); +} + +#endif /* dl-irel.h */ diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index b674dbef43..8a720ae9c2 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -526,6 +526,29 @@ elf_machine_tprel (struct link_map *map, } #endif +/* Call function at address VALUE (an OPD entry) to resolve ifunc relocs. */ +auto inline Elf64_Addr __attribute__ ((always_inline)) +resolve_ifunc (Elf64_Addr value, + const struct link_map *map, const struct link_map *sym_map) +{ + /* The function we are calling may not yet have its opd entry relocated. */ + Elf64_FuncDesc opd; + if (map != sym_map +#if !defined RTLD_BOOTSTRAP && defined SHARED + /* Bootstrap map doesn't have l_relocated set for it. */ + && sym_map != &GL(dl_rtld_map) +#endif + && !sym_map->l_relocated) + { + Elf64_FuncDesc *func = (Elf64_FuncDesc *) value; + opd.fd_func = func->fd_func + sym_map->l_addr; + opd.fd_toc = func->fd_toc + sym_map->l_addr; + opd.fd_aux = func->fd_aux; + value = (Elf64_Addr) &opd; + } + return ((Elf64_Addr (*) (void)) value) (); +} + /* Perform the relocation specified by RELOC and SYM (which is fully resolved). MAP is the object containing the reloc. */ auto inline void __attribute__ ((always_inline)) @@ -550,11 +573,17 @@ elf_machine_rela (struct link_map *map, if (__builtin_expect (r_type == R_PPC64_NONE, 0)) return; - /* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt. */ + /* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt + and STT_GNU_IFUNC. */ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); Elf64_Addr value = ((sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value) + reloc->r_addend); + if (sym != NULL + && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0) + && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)) + value = resolve_ifunc (value, map, sym_map); + /* For relocs that don't edit code, return. For relocs that might edit instructions, break from the switch. */ switch (r_type) @@ -564,6 +593,14 @@ elf_machine_rela (struct link_map *map, *reloc_addr = value; return; + case R_PPC64_IRELATIVE: + value = resolve_ifunc (value, map, sym_map); + *reloc_addr = value; + return; + + case R_PPC64_JMP_IREL: + value = resolve_ifunc (value, map, sym_map); + /* Fall thru */ case R_PPC64_JMP_SLOT: #ifdef RESOLVE_CONFLICT_FIND_MAP elf_machine_plt_conflict (reloc_addr, value); From 51a71cf063505d689337cf998670691a0a4b2410 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Oct 2009 00:41:33 -0700 Subject: [PATCH 40/47] Mention IFUNC for PPC. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 04a6b8c6bf..30af08de26 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ Version 2.11 * STT_GNU_IFUNC is now supported in static executables. Implemented by H.J. Lu. +* STT_GNU_IFUNC implemented for PPC by Alan Modra. + * New optimized string functions for x86-64: strstr, strcasestr, memcmp, strcspn, strpbrk, strspn, strcpy, stpcpy, strncpy, strcmp (SSE2, SSE4.2), strncmp (SSE2, SSE4.2), strchr (SSE4.2), strrchr (SSE4.2). From 31c759bf37a7a41faf8b13800deb769e8a5f3871 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 30 Oct 2009 00:48:54 -0700 Subject: [PATCH 41/47] Uglify IFUNC tests for PPC. --- ChangeLog | 20 ++++++++++++++ elf/ifuncdep2.c | 34 +++++------------------- elf/ifuncmain1.c | 2 -- elf/ifuncmain1vis.c | 2 -- elf/ifuncmain2.c | 2 -- elf/ifuncmain5.c | 2 -- elf/ifuncmain6pie.c | 3 ++- elf/ifuncmain7.c | 3 ++- elf/ifuncmod1.c | 41 +++++++---------------------- elf/ifuncmod3.c | 1 - elf/ifuncmod5.c | 33 ++++------------------- sysdeps/generic/elf/ifunc-sel.h | 26 +++++++++++++++++++ sysdeps/powerpc/elf/ifunc-sel.h | 46 +++++++++++++++++++++++++++++++++ 13 files changed, 116 insertions(+), 99 deletions(-) create mode 100644 sysdeps/generic/elf/ifunc-sel.h create mode 100644 sysdeps/powerpc/elf/ifunc-sel.h diff --git a/ChangeLog b/ChangeLog index 3359bc20bf..ebae859280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2009-10-28 Alan Modra + + * elf/ifuncdep2.c: Include ifunc-sel.h. + (global): Delete. + (foo1_ifunc, foo2_ifunc, foo3_ifunc): Use ifunc_sel. + * elf/ifuncmain1.c (global): Delete. + * elf/ifuncmain1vis.c: Likewise. + * elf/ifuncmain2.c: Likewise. + * elf/ifuncmain5.c: Likewise. + * elf/ifuncmod3.c: Likewise. + * elf/ifuncmain6pie.c: Include ifunc-sel.h. + (foo_ifunc): Use ifunc_one. + * elf/ifuncmain7.c: Likewise. + * elf/ifuncmod1.c: Include ifunc-sel.h. + (global): Define protected var. + (foo_ifunc, foo_hidden_ifunc, foo_protected_ifunc): Use ifunc_sel. + * elf/ifuncmod5.c: Likewise. + * sysdeps/generic/elf/ifunc-sel.h: New file. + * sysdeps/powerpc/elf/ifunc-sel.h: New file. + 2009-07-30 Alan Modra * elf/elf.h (R_PPC_NUM, R_PPC64_NUM): Delete unused and incorrect. diff --git a/elf/ifuncdep2.c b/elf/ifuncdep2.c index fb21eef5cb..758bae1932 100644 --- a/elf/ifuncdep2.c +++ b/elf/ifuncdep2.c @@ -1,6 +1,8 @@ /* Test 3 STT_GNU_IFUNC symbols. */ -extern int global; +#include "ifunc-sel.h" + +int global __attribute__ ((visibility ("protected"))) = -1; static int one (void) @@ -26,15 +28,7 @@ __asm__(".type foo1, %gnu_indirect_function"); void * foo1_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return minus_one; - default: - return zero; - } + return ifunc_sel (one, minus_one, zero); } void * foo2_ifunc (void) __asm__ ("foo2"); @@ -43,15 +37,7 @@ __asm__(".type foo2, %gnu_indirect_function"); void * foo2_ifunc (void) { - switch (global) - { - case 1: - return minus_one; - case -1: - return one; - default: - return zero; - } + return ifunc_sel (minus_one, one, zero); } void * foo3_ifunc (void) __asm__ ("foo3"); @@ -60,13 +46,5 @@ __asm__(".type foo3, %gnu_indirect_function"); void * foo3_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return zero; - default: - return minus_one; - } + return ifunc_sel (one, zero, minus_one); } diff --git a/elf/ifuncmain1.c b/elf/ifuncmain1.c index de7ffe8779..cc1e5ec5ba 100644 --- a/elf/ifuncmain1.c +++ b/elf/ifuncmain1.c @@ -7,8 +7,6 @@ #include -int global = -1; - int ret_foo; int ret_foo_hidden; int ret_foo_protected; diff --git a/elf/ifuncmain1vis.c b/elf/ifuncmain1vis.c index a239d2dd0d..81cd12288e 100644 --- a/elf/ifuncmain1vis.c +++ b/elf/ifuncmain1vis.c @@ -7,8 +7,6 @@ #include -int global = -1; - int ret_foo; int ret_foo_hidden; int ret_foo_protected; diff --git a/elf/ifuncmain2.c b/elf/ifuncmain2.c index cd9b2c8352..db3ba56a02 100644 --- a/elf/ifuncmain2.c +++ b/elf/ifuncmain2.c @@ -3,8 +3,6 @@ #include -int global = -1; - extern int foo1 (void); int diff --git a/elf/ifuncmain5.c b/elf/ifuncmain5.c index 7f128d006e..f398085cb4 100644 --- a/elf/ifuncmain5.c +++ b/elf/ifuncmain5.c @@ -2,8 +2,6 @@ #include -int global = -1; - extern int foo (void); extern int foo_protected (void); diff --git a/elf/ifuncmain6pie.c b/elf/ifuncmain6pie.c index 06f179bf9d..8478d4c408 100644 --- a/elf/ifuncmain6pie.c +++ b/elf/ifuncmain6pie.c @@ -6,6 +6,7 @@ */ #include +#include "ifunc-sel.h" typedef int (*foo_p) (void); extern foo_p foo_ptr; @@ -22,7 +23,7 @@ __asm__(".type foo, %gnu_indirect_function"); void * foo_ifunc (void) { - return one; + return ifunc_one (one); } extern int foo (void); diff --git a/elf/ifuncmain7.c b/elf/ifuncmain7.c index 099e929ffc..617a596d5e 100644 --- a/elf/ifuncmain7.c +++ b/elf/ifuncmain7.c @@ -5,6 +5,7 @@ */ #include +#include "ifunc-sel.h" extern int foo (void); @@ -21,7 +22,7 @@ static void * __attribute__ ((used)) foo_ifunc (void) { - return one; + return ifunc_one (one); } typedef int (*foo_p) (void); diff --git a/elf/ifuncmod1.c b/elf/ifuncmod1.c index a1697b596d..2b8195ce55 100644 --- a/elf/ifuncmod1.c +++ b/elf/ifuncmod1.c @@ -4,8 +4,9 @@ 2. Function pointer. 3. Visibility. */ +#include "ifunc-sel.h" -extern int global; +int global __attribute__ ((visibility ("protected"))) = -1; static int one (void) @@ -20,7 +21,7 @@ minus_one (void) } static int -zero (void) +zero (void) { return 0; } @@ -28,52 +29,28 @@ zero (void) void * foo_ifunc (void) __asm__ ("foo"); __asm__(".type foo, %gnu_indirect_function"); -void * +void * foo_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return minus_one; - default: - return zero; - } + return ifunc_sel (one, minus_one, zero); } void * foo_hidden_ifunc (void) __asm__ ("foo_hidden"); __asm__(".type foo_hidden, %gnu_indirect_function"); -void * +void * foo_hidden_ifunc (void) { - switch (global) - { - case 1: - return minus_one; - case -1: - return one; - default: - return zero; - } + return ifunc_sel (minus_one, one, zero); } void * foo_protected_ifunc (void) __asm__ ("foo_protected"); __asm__(".type foo_protected, %gnu_indirect_function"); -void * +void * foo_protected_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return zero; - default: - return minus_one; - } + return ifunc_sel (one, zero, minus_one); } /* Test hidden indirect function. */ diff --git a/elf/ifuncmod3.c b/elf/ifuncmod3.c index 379d2c8d53..ca2d962600 100644 --- a/elf/ifuncmod3.c +++ b/elf/ifuncmod3.c @@ -5,4 +5,3 @@ int ret_foo; int ret_foo_hidden; int ret_foo_protected; -int global = -1; diff --git a/elf/ifuncmod5.c b/elf/ifuncmod5.c index 2ca1c71541..9a08e8cf53 100644 --- a/elf/ifuncmod5.c +++ b/elf/ifuncmod5.c @@ -1,6 +1,7 @@ /* Test STT_GNU_IFUNC symbols without direct function call. */ +#include "ifunc-sel.h" -extern int global; +int global __attribute__ ((visibility ("protected"))) = -1; static int one (void) @@ -26,15 +27,7 @@ __asm__(".type foo, %gnu_indirect_function"); void * foo_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return minus_one; - default: - return zero; - } + return ifunc_sel (one, minus_one, zero); } void * foo_hidden_ifunc (void) __asm__ ("foo_hidden"); @@ -43,15 +36,7 @@ __asm__(".type foo_hidden, %gnu_indirect_function"); void * foo_hidden_ifunc (void) { - switch (global) - { - case 1: - return minus_one; - case -1: - return one; - default: - return zero; - } + return ifunc_sel (minus_one, one, zero); } void * foo_protected_ifunc (void) __asm__ ("foo_protected"); @@ -60,15 +45,7 @@ __asm__(".type foo_protected, %gnu_indirect_function"); void * foo_protected_ifunc (void) { - switch (global) - { - case 1: - return one; - case -1: - return zero; - default: - return minus_one; - } + return ifunc_sel (one, zero, minus_one); } /* Test hidden indirect function. */ diff --git a/sysdeps/generic/elf/ifunc-sel.h b/sysdeps/generic/elf/ifunc-sel.h new file mode 100644 index 0000000000..6a27b69c5b --- /dev/null +++ b/sysdeps/generic/elf/ifunc-sel.h @@ -0,0 +1,26 @@ +/* Used by the elf ifunc tests. */ +#ifndef ELF_IFUNC_SEL_H +#define ELF_IFUNC_SEL_H 1 + +extern int global; + +static inline void * +ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void)) +{ + switch (global) + { + case 1: + return f1; + case -1: + return f2; + default: + return f3; + } +} + +static inline void * +ifunc_one (int (*f1) (void)) +{ + return f1; +} +#endif diff --git a/sysdeps/powerpc/elf/ifunc-sel.h b/sysdeps/powerpc/elf/ifunc-sel.h new file mode 100644 index 0000000000..526d8ed88b --- /dev/null +++ b/sysdeps/powerpc/elf/ifunc-sel.h @@ -0,0 +1,46 @@ +/* Used by the elf ifunc tests. */ +#ifndef ELF_IFUNC_SEL_H +#define ELF_IFUNC_SEL_H 1 + +extern int global; + +static inline void * +ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void)) +{ + register void *ret __asm__ ("r3"); + __asm__ ("mflr 12\n\t" + "bcl 20,31,1f\n" + "1:\tmflr 11\n\t" + "mtlr 12\n\t" + "addis 12,11,global-1b@ha\n\t" + "lwz 12,global-1b@l(12)\n\t" + "addis %0,11,%2-1b@ha\n\t" + "addi %0,%0,%2-1b@l\n\t" + "cmpwi 12,1\n\t" + "beqlr\n\t" + "addis %0,11,%3-1b@ha\n\t" + "addi %0,%0,%3-1b@l\n\t" + "cmpwi 12,-1\n\t" + "beqlr\n\t" + "addis %0,11,%4-1b@ha\n\t" + "addi %0,%0,%4-1b@l" + : "=r" (ret) + : "X" (&global), "X" (f1), "X" (f2), "X" (f3)); + return ret; +} + +static inline void * +ifunc_one (int (*f1) (void)) +{ + register void *ret __asm__ ("r3"); + __asm__ ("mflr 12\n\t" + "bcl 20,31,1f\n" + "1:\tmflr %0\n\t" + "mtlr 12\n\t" + "addis %0,%0,%1-1b@ha\n\t" + "addi %0,%0,%1-1b@l" + : "=r" (ret) + : "X" (f1)); + return ret; +} +#endif From 25db0f6ca996f799de308aa2dc7c62caa99ee9dc Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Fri, 30 Oct 2009 01:00:44 -0700 Subject: [PATCH 42/47] Fix races in setXid implementation. --- nptl/ChangeLog | 8 +++ nptl/allocatestack.c | 123 ++++++++++++++++++++++++++++++++++++------- nptl/nptl-init.c | 16 ++++-- 3 files changed, 123 insertions(+), 24 deletions(-) diff --git a/nptl/ChangeLog b/nptl/ChangeLog index d211635a41..f61cb5c9a3 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,11 @@ +2009-10-30 Ulrich Drepper + + [BZ #3270] + * allocatestack.c (__nptl_setxid): Perform the operation in multiple + steps to avoid races with creation and terminations. + * nptl-init.c (sighandler_setxid): Adjust. + Patch by Daniel Jacobowitz. + 2009-09-07 Andreas Schwab * sysdeps/pthread/bits/libc-lock.h (BP_SYM): Remove space before paren. diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 67ea0c68f8..3c3585fe37 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -965,22 +965,53 @@ __find_thread_by_id (pid_t tid) static void internal_function -setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) +setxid_mark_thread (struct xid_command *cmdp, struct pthread *t) { - if (! IS_DETACHED (t)) + int ch; + + /* Don't let the thread exit before the setxid handler runs. */ + t->setxid_futex = 0; + + do { - int ch; - do - { - ch = t->cancelhandling; + ch = t->cancelhandling; - /* If the thread is exiting right now, ignore it. */ - if ((ch & EXITING_BITMASK) != 0) - return; - } - while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling, - ch | SETXID_BITMASK, ch)); + /* If the thread is exiting right now, ignore it. */ + if ((ch & EXITING_BITMASK) != 0) + return; } + while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling, + ch | SETXID_BITMASK, ch)); +} + + +static void +internal_function +setxid_unmark_thread (struct xid_command *cmdp, struct pthread *t) +{ + int ch; + + do + { + ch = t->cancelhandling; + if ((ch & SETXID_BITMASK) == 0) + return; + } + while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling, + ch & ~SETXID_BITMASK, ch)); + + /* Release the futex just in case. */ + t->setxid_futex = 1; + lll_futex_wake (&t->setxid_futex, 1, LLL_PRIVATE); +} + + +static int +internal_function +setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) +{ + if ((t->cancelhandling & SETXID_BITMASK) == 0) + return 0; int val; INTERNAL_SYSCALL_DECL (err); @@ -997,8 +1028,14 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID); #endif + /* If this failed, it must have had not started yet or else exited. */ if (!INTERNAL_SYSCALL_ERROR_P (val, err)) - atomic_increment (&cmdp->cntr); + { + atomic_increment (&cmdp->cntr); + return 1; + } + else + return 0; } @@ -1006,6 +1043,7 @@ int attribute_hidden __nptl_setxid (struct xid_command *cmdp) { + int signalled; int result; lll_lock (stack_cache_lock, LLL_PRIVATE); @@ -1022,7 +1060,7 @@ __nptl_setxid (struct xid_command *cmdp) if (t == self) continue; - setxid_signal_thread (cmdp, t); + setxid_mark_thread (cmdp, t); } /* Now the list with threads using user-allocated stacks. */ @@ -1032,14 +1070,61 @@ __nptl_setxid (struct xid_command *cmdp) if (t == self) continue; - setxid_signal_thread (cmdp, t); + setxid_mark_thread (cmdp, t); } - int cur = cmdp->cntr; - while (cur != 0) + /* Iterate until we don't succeed in signalling anyone. That means + we have gotten all running threads, and their children will be + automatically correct once started. */ + do { - lll_futex_wait (&cmdp->cntr, cur, LLL_PRIVATE); - cur = cmdp->cntr; + signalled = 0; + + list_for_each (runp, &stack_used) + { + struct pthread *t = list_entry (runp, struct pthread, list); + if (t == self) + continue; + + signalled += setxid_signal_thread (cmdp, t); + } + + list_for_each (runp, &__stack_user) + { + struct pthread *t = list_entry (runp, struct pthread, list); + if (t == self) + continue; + + signalled += setxid_signal_thread (cmdp, t); + } + + int cur = cmdp->cntr; + while (cur != 0) + { + lll_futex_wait (&cmdp->cntr, cur, LLL_PRIVATE); + cur = cmdp->cntr; + } + } + while (signalled != 0); + + /* Clean up flags, so that no thread blocks during exit waiting + for a signal which will never come. */ + list_for_each (runp, &stack_used) + { + struct pthread *t = list_entry (runp, struct pthread, list); + if (t == self) + continue; + + setxid_unmark_thread (cmdp, t); + } + + list_for_each (runp, &__stack_user) + { + struct pthread *t = list_entry (runp, struct pthread, list); + if (t == self) + continue; + + setxid_unmark_thread (cmdp, t); } /* This must be last, otherwise the current thread might not have diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 5e9c250ff7..851bab2bf1 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -240,17 +240,23 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, err, 3, __xidcmd->id[0], __xidcmd->id[1], __xidcmd->id[2]); - if (atomic_decrement_val (&__xidcmd->cntr) == 0) - lll_futex_wake (&__xidcmd->cntr, 1, LLL_PRIVATE); - /* Reset the SETXID flag. */ struct pthread *self = THREAD_SELF; - int flags = THREAD_GETMEM (self, cancelhandling); - THREAD_SETMEM (self, cancelhandling, flags & ~SETXID_BITMASK); + int flags, newval; + do + { + flags = THREAD_GETMEM (self, cancelhandling); + newval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, + flags & ~SETXID_BITMASK, flags); + } + while (flags != newval); /* And release the futex. */ self->setxid_futex = 1; lll_futex_wake (&self->setxid_futex, 1, LLL_PRIVATE); + + if (atomic_decrement_val (&__xidcmd->cntr) == 0) + lll_futex_wake (&__xidcmd->cntr, 1, LLL_PRIVATE); } From 6cfe8609b890f33e6c7235549cb02c3c6a0f3820 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 28 Oct 2009 15:27:43 -0700 Subject: [PATCH 43/47] New simplified make dist using git archive. --- ChangeLog | 13 ++++++++++++ Makefile | 63 ++++++++++++++++++++++--------------------------------- Makerules | 3 ++- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index ebae859280..7a6136b73e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-10-28 Roland McGrath + + * Makefile (dist-prepare): New target. + (tag-for-dist): Target removed. + (glibc-%.tar): Pattern rule removed. + (%.tar): New pattern rule, does simple use of git archive. + (dist-version): Remove variable definition. + (dist): Just depend on that. Add .tar.xz dependency. + If dist-version variable not set on command line, depend on + dist-prepare, re-invoke with dist-version set via git describe. + + * Makerules (%.xz): New pattern rule. + 2009-10-28 Alan Modra * elf/ifuncdep2.c: Include ifunc-sel.h. diff --git a/Makefile b/Makefile index 6a384ade3c..61cfa436c4 100644 --- a/Makefile +++ b/Makefile @@ -347,51 +347,38 @@ TAGS: | $(ETAGS) -o $@ - # Make the distribution tarfile. -.PHONY: dist tag-for-dist +.PHONY: dist dist-prepare generated := $(generated) stubs.h -files-for-dist := README FAQ INSTALL NOTES configure - -tag-of-stem = glibc-$(subst .,_,$*) -dist-selector = -r $(tag-of-stem) - -# Add-ons in the main repository but distributed in their own tar files. -dist-separate = libidn - -glibc-%.tar $(dist-separate:%=glibc-%-%.tar): $(files-for-dist) \ - $(foreach D,$(dist-separate),\ - $D/configure) - @rm -fr glibc-$* - $(MAKE) -q `find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \ - -name configure` - cvs $(CVSOPTS) -Q export -d glibc-$* $(dist-selector) libc -# Touch all the configure scripts going into the tarball since cvs export -# might have delivered configure.in newer than configure. - find glibc-$* -name configure -print | xargs touch - $(dist-do-separate-dirs) - tar cf glibc-$*.tar glibc-$* - rm -fr glibc-$* -define dist-do-separate-dirs -$(foreach dir,$(dist-separate), - @rm -fr glibc-$(dir)-$* - mv glibc-$*/$(dir) glibc-$(dir)-$* - tar cf glibc-$(dir)-$*.tar glibc-$(dir)-$* - rm -fr glibc-$(dir)-$* -) -endef +files-for-dist := README FAQ INSTALL NOTES configure ChangeLog NEWS + +# Regenerate stuff, then error if these things are not committed yet. +dist-prepare: $(files-for-dist) + conf=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \ + -name configure`; \ + $(MAKE) $$conf && \ + git diff --stat HEAD -- $^ $$conf \ + | $(AWK) '{ print; rc=1 } END { exit rc }' + +%.tar: FORCE + git archive --prefix=$*/ $* > $@.new + mv -f $@.new $@ # Do `make dist dist-version=X.Y.Z' to make tar files of an older version. -dist-version = $(version) -dist: $(foreach Z,.bz2 .gz,glibc-$(dist-version).tar$Z \ - $(foreach D,$(dist-separate),\ - glibc-$D-$(dist-version).tar$Z)) +ifneq (,$(strip $(dist-version))) +dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z) md5sum $^ - -tag-for-dist: tag-$(dist-version) -tag-%: $(files-for-dist) - cvs $(CVSOPTS) -Q tag -c $(tag-of-stem) +else +dist: dist-prepare + @if v=`git describe`; then \ + echo Distribution version $$v; \ + $(MAKE) dist dist-version=$$v; \ + else \ + false; \ + fi +endif define format-me @rm -f $@ diff --git a/Makerules b/Makerules index ab36e2f178..43fa5a701b 100644 --- a/Makerules +++ b/Makerules @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 1991-2006,2007,2008,2009 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 @@ -1335,6 +1335,7 @@ echo-headers: %.bz2: %; bzip2 -9vk $< %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@ +%.xz: %; xz -9evk $< # Common cleaning targets. From de2cc8095bf7fa4202d0d4c038c8be61dc60fd41 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 30 Oct 2009 14:14:31 +0100 Subject: [PATCH 44/47] Fix typo in readlinkat --- ChangeLog | 4 ++++ sysdeps/unix/sysv/linux/readlinkat.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7a6136b73e..6562469777 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-30 Andreas Schwab + + * sysdeps/unix/sysv/linux/readlinkat.c: Fix last change. + 2009-10-28 Roland McGrath * Makefile (dist-prepare): New target. diff --git a/sysdeps/unix/sysv/linux/readlinkat.c b/sysdeps/unix/sysv/linux/readlinkat.c index 1e9a9b649f..55abff143d 100644 --- a/sysdeps/unix/sysv/linux/readlinkat.c +++ b/sysdeps/unix/sysv/linux/readlinkat.c @@ -59,7 +59,7 @@ readlinkat (fd, path, buf, len) if (fd != AT_FDCWD && path[0] != '/') { size_t pathlen = strlen (path); - if (__builtin_expect (filelen == 0, 0)) + if (__builtin_expect (pathlen == 0, 0)) { __set_errno (ENOENT); return -1; From 2c5c07f5fc27dab969c1bd885981d095580e53cd Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 30 Oct 2009 07:15:12 -0700 Subject: [PATCH 45/47] Add missing declarations. --- ChangeLog | 3 +++ locale/programs/locale-spec.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6562469777..8039e4bc49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-10-30 Andreas Schwab + * locale/programs/locale-spec.c: Include and + . + * sysdeps/unix/sysv/linux/readlinkat.c: Fix last change. 2009-10-28 Roland McGrath diff --git a/locale/programs/locale-spec.c b/locale/programs/locale-spec.c index 63a7a32e05..43df46bb38 100644 --- a/locale/programs/locale-spec.c +++ b/locale/programs/locale-spec.c @@ -21,6 +21,8 @@ # include #endif +#include +#include #include #include #include From b47525dd866cbeff9748f532b24a930c7b65d798 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Oct 2009 07:18:24 -0700 Subject: [PATCH 46/47] Fix first weekday for ast_ES locale. --- localedata/ChangeLog | 3 +++ localedata/locales/ast_ES | 1 + 2 files changed, 4 insertions(+) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 01edd7d1f5..0de7cccb87 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,5 +1,8 @@ 2009-10-30 Ulrich Drepper + [BZ #10286] + * locales/ast_ES: Define first_weekday. + [BZ #10312] * locales/es_CO: Define am_pm , t_fmt_ampm, first_weekday. Patch by Jorge Guerrero . diff --git a/localedata/locales/ast_ES b/localedata/locales/ast_ES index 249571cd3e..eb048d5bbb 100644 --- a/localedata/locales/ast_ES +++ b/localedata/locales/ast_ES @@ -109,6 +109,7 @@ t_fmt_ampm "" date_fmt "/ / " +first_weekday 2 END LC_TIME LC_PAPER From 3a83202db6e5591f2b72974c1ad98602c6620770 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Oct 2009 08:02:30 -0700 Subject: [PATCH 47/47] Implement mkostemps and mkostemps64. --- ChangeLog | 5 +++++ NEWS | 3 ++- misc/Makefile | 2 +- misc/Versions | 2 +- misc/mkostemps.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ misc/mkostemps64.c | 41 +++++++++++++++++++++++++++++++++++++++++ stdlib/stdlib.h | 23 +++++++++++++++++++++++ 7 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 misc/mkostemps.c create mode 100644 misc/mkostemps64.c diff --git a/ChangeLog b/ChangeLog index 8039e4bc49..4b4cf1fad2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-30 Ulrich Drepper + + * misc/mkostemps.c: New file. + * misc/mkostemps64.c: New file. + 2009-10-30 Andreas Schwab * locale/programs/locale-spec.c: Include and diff --git a/NEWS b/NEWS index 30af08de26..500936e80b 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,8 @@ using `glibc' in the "product" field. Version 2.11 -* New interfaces: execvpe, pthread_sigqueue, mkstemps, mkstemps64 +* New interfaces: execvpe, pthread_sigqueue, mkstemps, mkstemps64, mkostemps, + mkostemps64 Implemented by Ulrich Drepper. * Checking version of longjmp added that fails if an uninitialized stack diff --git a/misc/Makefile b/misc/Makefile index 6243647d1d..ee6936180b 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -45,7 +45,7 @@ routines := brk sbrk sstk ioctl \ gethostid sethostid \ revoke vhangup \ swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \ - mkostemp mkostemp64 mkstemps mkstemps64 \ + mkostemp mkostemp64 mkstemps mkstemps64 mkostemps mkostemps64 \ ualarm usleep \ gtty stty \ ptrace \ diff --git a/misc/Versions b/misc/Versions index b883e3df25..3ffe3d138d 100644 --- a/misc/Versions +++ b/misc/Versions @@ -141,6 +141,6 @@ libc { preadv; preadv64; pwritev; pwritev64; } GLIBC_2.11 { - mkstemps; mkstemps64; + mkstemps; mkstemps64; mkostemps; mkostemps64; } } diff --git a/misc/mkostemps.c b/misc/mkostemps.c new file mode 100644 index 0000000000..030367296e --- /dev/null +++ b/misc/mkostemps.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2009 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. */ + +#include +#include +#include + +#ifndef __GT_FILE +# define __GT_FILE 0 +#endif + +/* Generate a unique temporary file name from TEMPLATE. The last six + characters before a suffix of length SUFFIXLEN of TEMPLATE must be + "XXXXXX"; they are replaced with a string that makes the filename + unique. Then open the file and return a fd. */ +int +mkostemps (template, suffixlen, flags) + char *template; + int suffixlen; + int flags; +{ + if (suffixlen < 0) + { + __set_errno (EINVAL); + return -1; + } + + return __gen_tempname (template, suffixlen, flags, __GT_FILE); +} diff --git a/misc/mkostemps64.c b/misc/mkostemps64.c new file mode 100644 index 0000000000..0c6a2e7631 --- /dev/null +++ b/misc/mkostemps64.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2000, 2007, 2009 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. */ + +#include +#include +#include +#include + +/* Generate a unique temporary file name from TEMPLATE. The last six + characters before a suffix of length SUFFIXLEN of TEMPLATE must be + "XXXXXX"; they are replaced with a string that makes the filename + unique. Then open the file and return a fd. */ +int +mkostemps64 (template, suffixlen, flags) + char *template; + int suffixlen; + int flags; +{ + if (suffixlen < 0) + { + __set_errno (EINVAL); + return -1; + } + + return __gen_tempname (template, suffixlen, flags | O_LARGEFILE, __GT_FILE); +} diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 6fe6a03bf3..dc51d67170 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -678,6 +678,29 @@ extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64) # ifdef __USE_LARGEFILE64 extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur; # endif + +/* Similar to mkostemp, but the template can have a suffix after the + XXXXXX. The length of the suffix is specified in the second + parameter. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkostemps (char *__template, int __suffixlen, int __flags) + __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen, + int __flags), mkostemps64) + __nonnull ((1)) __wur; +# else +# define mkostemps mkostemps64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkostemps64 (char *__template, int __suffixlen, int __flags) + __nonnull ((1)) __wur; +# endif #endif