From drepper@redhat.com Thu Jul 1 17:41:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 01 Jul 2004 17:41:00 -0000 Subject: [PATCH] .plt slot reduction on s390 In-Reply-To: <20040630161301.GV5191@sunsite.ms.mff.cuni.cz> References: <20040630161301.GV5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E44BCD.9000701@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From roland@redhat.com Fri Jul 2 05:52:00 2004 From: roland@redhat.com (Roland McGrath) Date: Fri, 02 Jul 2004 05:52:00 -0000 Subject: BUGS file In-Reply-To: Jakub Jelinek's message of Wednesday, 30 June 2004 08:24:21 +0200 <20040630062421.GU5191@sunsite.ms.mff.cuni.cz> Message-ID: <200407020552.i625q2ep021386@magilla.sf.frob.com> > And update the bugreporting instructions in there: Yeah, http://sources.redhat.com/bugzilla/show_bug.cgi?id=234 is about this. That's what motivated me to look at the file. It all looks so stale that rather than just update those instructions I thought about nuking the file. Can we verify now which of these items still applies? [ **] Closing shared objects in statically linked binaries most of the times leads to crashes during the dlopen(). Hard to fix. Don't know. [ **] There are problems with signal handling when using LinuxThreads. Not planning to fix this, since we have NPTL now. [ **] The RPC code is not 64 bit clean. This is getting slowly fixed but expect incompatible changes on 64 bit platforms like Alpha. I think this may now be as fixed as it's going to get. [ **] If a DSO is using implicitly libpthread and the application itself does not there is a name lookup problem. E.g., the function fork() will be found in the libc.so instead of libpthread since the thread library is behind the libc. To correct this problem it must *not* be relied on the currently still enabled handling of weak symbols in the dynamic linker. Instead explicit tests for the availability of the libpthread version are needed. [PR libc/2325] I don't think this is a problem any more, since those functions that are duplicated between libc and libpthread now always forward to their counterpart. [ *] The precision of the `sinhl' and/or `asinhl' function do not seem to be the best. [ *] The libm-ieee `gamma' function gives wrong results (at least for -0.5). [ *] The libm-ieee `scalb' function gives wrong results for non-integral second parameters. I don't know the status of these, though libm has had various changes in the last two years since BUGS was updated. [ *] On Linux, there should be a way to prevent defining the symbol NGROUPS_MAX in the header file. In glibc it is defined in which must not make the other symbols in available. [PR libc/140] This is still the case. But it's really something that needs to be changed in the installed kernel header, and then libc will do the right thing. [ *] Several (most?) collation specifications are broken. I don't know anything about this stuff. [ *] Some of the functions which also handled IPv6 are currently broken. IPv6 and IPv4 lookups occasionally happen when not needed. This happens in getaddrinfo() and getnameinfo(). IPv4 handling of these functions is OK though and there are patches available to fix the IPv6 code as well. I believe this is fixed now. If anything remains to do here, it should have an active bugzilla report since it's something we don't want to have slide forever. Thanks, Roland From jakub@redhat.com Sun Jul 4 12:26:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 04 Jul 2004 12:26:00 -0000 Subject: [PATCH] Fix pthread_rwlock_timedrdlock on x86_64 Message-ID: <20040704101108.GY5191@sunsite.ms.mff.cuni.cz> Hi! struct timespec's tv_nsec is long int, but we were comparing only low 32 bits on x86-64. pthread_rwlock_timedwrlock was ok. 2004-07-04 Jakub Jelinek * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S (pthread_rwlock_timedrdlock): Use cmpq instead of cmpl to check for valid tv_nsec. * tst-rwlock14.c (do_test): Test for invalid tv_nsec equal to 1 billion and 64-bit tv_nsec which is valid when truncated to 32 bits. --- libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S.jj 2003-09-22 06:40:52.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S 2004-07-04 14:18:29.730168123 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -71,7 +71,7 @@ pthread_rwlock_timedrdlock: je 5f /* Check the value of the timeout parameter. */ -3: cmpl $1000000000, 8(%r13) +3: cmpq $1000000000, 8(%r13) jae 19f incl READERS_QUEUED(%r12) --- libc/nptl/tst-rwlock14.c.jj 2004-06-27 21:28:46.000000000 +0200 +++ libc/nptl/tst-rwlock14.c 2004-07-04 14:13:50.027351034 +0200 @@ -104,7 +104,7 @@ do_test (void) result = 1; } - ts.tv_nsec = 2000000000; + ts.tv_nsec = 1000000000; e = pthread_rwlock_timedrdlock (&r, &ts); if (e == 0) @@ -130,6 +130,34 @@ do_test (void) result = 1; } + ts.tv_nsec = 0x100001000LL; + if (ts.tv_nsec != 0x100001000LL) + ts.tv_nsec = 2000000000; + + e = pthread_rwlock_timedrdlock (&r, &ts); + if (e == 0) + { + puts ("third rwlock_timedrdlock did not fail"); + result = 1; + } + else if (e != EINVAL) + { + puts ("third rwlock_timedrdlock did not return EINVAL"); + result = 1; + } + + e = pthread_rwlock_timedrdlock (&r, &ts); + if (e == 0) + { + puts ("third rwlock_timedrdlock did not fail"); + result = 1; + } + else if (e != EINVAL) + { + puts ("third rwlock_timedrdlock did not return EINVAL"); + result = 1; + } + if (result == 0) puts ("no bugs"); Jakub From drepper@redhat.com Sun Jul 4 23:12:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 04 Jul 2004 23:12:00 -0000 Subject: [PATCH] Fix pthread_rwlock_timedrdlock on x86_64 In-Reply-To: <20040704101108.GY5191@sunsite.ms.mff.cuni.cz> References: <20040704101108.GY5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E88E32.80806@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Mon Jul 5 09:00:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jul 2004 09:00:00 -0000 Subject: [PATCH] Fix nscd_getgr_r.c Message-ID: <20040705064504.GA5191@sunsite.ms.mff.cuni.cz> Hi! On i686/x86_64/ia64 this header is included through hp-timing, but not on the rest of arches. 2004-07-05 Jakub Jelinek * nscd/nscd_getgr_r.c: Include stdio-common/_itoa.h. --- libc/nscd/nscd_getgr_r.c.jj 2004-06-11 14:45:54.000000000 +0200 +++ libc/nscd/nscd_getgr_r.c 2004-07-05 10:55:24.321822102 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include "nscd-client.h" #include "nscd_proto.h" Jakub From jakub@redhat.com Mon Jul 5 12:48:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jul 2004 12:48:00 -0000 Subject: [PATCH] Fix ppc64 libc Message-ID: <20040705103341.GB5191@sunsite.ms.mff.cuni.cz> Hi! The nptl change fixes NPTL ppc64 build after 2004-07-01 Makeconfig reordering of shlib-versions. All other platforms which have DEFAULT in main shlib-versions are listed there, so IMHO it certainly doesn't hurt. Maybe it would be better to first process all DEFAULT lines and then the other ones when processing shlib-versions though (say egrep '[^[:space:]]+[[:space:]]+DEFAULT' first, then egrep -v). The other changes are because I have noticed bogus: 5314: 0000000000175970 24 FUNC LOCAL DEFAULT 29 __libc_longjmp@GLIBC_2.3 5908: 0000000000175880 24 FUNC LOCAL DEFAULT 29 __setjmp@GLIBC_2.3 6440: 0000000000175988 24 FUNC LOCAL DEFAULT 29 __sigjmp_save@GLIBC_2.3 6760: 0000000000175940 24 FUNC LOCAL DEFAULT 29 __longjmp@GLIBC_2.3 8164: 0000000000175970 24 FUNC LOCAL DEFAULT 29 __libc_siglongjmp@GLIBC_2.3 in ppc* libc.so. __libc_longjmp and __libc_siglongjmp are both GLIBC_PRIVATE in Versions files, so only vmx versions ought to be exported and as GLIBC_PRIVATE, while the remaining 3 symbols are not exported. 2004-07-05 Jakub Jelinek * sysdeps/powerpc/novmx-longjmp.c (__libc_longjmp, __libc_siglongjmp): Remove symbol_version. * sysdeps/powerpc/longjmp.c (__libc_longjmp, __libc_siglongjmp): Export @@GLIBC_PRIVATE, not @@GLIBC_2.3.4. * sysdeps/powerpc/sigjmp.c (__sigjmp_save): Use strong_alias unconditionally. * sysdeps/powerpc/novmx-sigjmp.c (__sigjmp_save): Remove. * sysdeps/powerpc/powerpc32/__longjmp.S (__longjmp): Use strong_alias instead of default_symbol_version, remove symbol_version. * sysdeps/powerpc/powerpc64/__longjmp.S (__longjmp): Likewise. * sysdeps/powerpc/powerpc32/bsd-setjmp.S (__novmx__setjmp): Change into strong_alias to __novmxsetjmp. (__vmx__setjmp): Similarly with __vmxsetjmp. (__setjmp): Make it strong_alias to __vmx__setjmp, remove default_symbol_version and symbol_version. * sysdeps/powerpc/powerpc64/bsd-setjmp.S (__novmx__setjmp): Change into strong_alias to __novmxsetjmp. (__vmx__setjmp): Similarly with __vmxsetjmp. (__setjmp): Make it strong_alias to __vmx__setjmp, remove default_symbol_version and symbol_version. nptl/ * shlib-versions: Add powerpc64-.*-linux.*. --- libc/nptl/shlib-versions.jj 2002-11-26 23:49:15.000000000 +0100 +++ libc/nptl/shlib-versions 2004-07-05 13:03:15.322282213 +0200 @@ -6,4 +6,5 @@ hppa.*-.*-linux.* libpthread=0 GLIBC_2. s390x-.*-linux.* libpthread=0 GLIBC_2.2 cris-.*-linux.* libpthread=0 GLIBC_2.2 x86_64-.*-linux.* libpthread=0 GLIBC_2.2.5 +powerpc64-.*-linux.* libpthread=0 GLIBC_2.3 .*-.*-linux.* libpthread=0 --- libc/sysdeps/powerpc/novmx-longjmp.c.jj 2004-02-14 04:27:26.000000000 +0100 +++ libc/sysdeps/powerpc/novmx-longjmp.c 2004-07-05 13:14:32.693204025 +0200 @@ -53,14 +53,10 @@ weak_alias (__novmx__libc_siglongjmp, __ weak_alias (__novmx__libc_siglongjmp, __novmxsiglongjmp) # if __WORDSIZE == 64 -symbol_version (__novmx__libc_longjmp,__libc_longjmp,GLIBC_2.3); -symbol_version (__novmx__libc_siglongjmp,__libc_siglongjmp,GLIBC_2.3); symbol_version (__novmx_longjmp,_longjmp,GLIBC_2.3); symbol_version (__novmxlongjmp,longjmp,GLIBC_2.3); symbol_version (__novmxsiglongjmp,siglongjmp,GLIBC_2.3); # else -symbol_version (__novmx__libc_longjmp,__libc_longjmp,GLIBC_2.0); -symbol_version (__novmx__libc_siglongjmp,__libc_siglongjmp,GLIBC_2.0); symbol_version (__novmx_longjmp,_longjmp,GLIBC_2.0); symbol_version (__novmxlongjmp,longjmp,GLIBC_2.0); symbol_version (__novmxsiglongjmp,siglongjmp,GLIBC_2.0); --- libc/sysdeps/powerpc/powerpc64/__longjmp.S.jj 2004-03-13 10:23:15.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc64/__longjmp.S 2004-07-05 13:51:48.722100900 +0200 @@ -26,8 +26,7 @@ # include "__longjmp-common.S" #else /* !NOT_IN_libc */ -/* Build a versioned object for libc. */ -default_symbol_version (__vmx__longjmp,__longjmp,GLIBC_2.3.4) +strong_alias (__vmx__longjmp, __longjmp) # define __longjmp __vmx__longjmp # include "__longjmp-common.S" @@ -35,7 +34,6 @@ default_symbol_version (__vmx__longjmp,_ # define __NO_VMX__ # undef __longjmp # undef JB_SIZE -symbol_version(__novmx__longjmp,__longjmp,GLIBC_2.3) # define __longjmp __novmx__longjmp # include "__longjmp-common.S" # endif --- libc/sysdeps/powerpc/powerpc64/bsd-setjmp.S.jj 2004-03-23 15:51:35.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc64/bsd-setjmp.S 2004-07-05 13:57:06.813179949 +0200 @@ -23,33 +23,21 @@ #if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_3_4) -/* We need 2 copies of identical code for the setjmp's as gas complains - erroneously about having multiple versions of setjmp. This eliminates the - need for the strong alias of __setjmp to setjmp which - does not support versioning, i.e. another gas unimplemented feature. */ -symbol_version (__novmx__setjmp,__setjmp,GLIBC_2.3) -symbol_version (__novmxsetjmp,setjmp,GLIBC_2.3) -ENTRY (BP_SYM (__novmxsetjmp)) +ENTRY (__novmxsetjmp) li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__novmx__sigsetjmp)) -END (BP_SYM (__novmxsetjmp)) + b JUMPTARGET (__novmx__sigsetjmp) +END (__novmxsetjmp) +strong_alias (__novmxsetjmp, __novmx__setjmp) +symbol_version (__novmxsetjmp, setjmp, GLIBC_2.3) -ENTRY (BP_SYM (__novmx__setjmp)) - li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__novmx__sigsetjmp)) -END (BP_SYM (__novmx__setjmp)) #endif /* defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_3_4) */ -default_symbol_version (__vmx__setjmp,__setjmp,GLIBC_2.3.4) -default_symbol_version (__vmxsetjmp,setjmp,GLIBC_2.3.4) - -ENTRY (BP_SYM (__vmxsetjmp)) - li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__vmx__sigsetjmp)) -END (BP_SYM (__vmxsetjmp)) -ENTRY (BP_SYM (__vmx__setjmp)) +ENTRY (__vmxsetjmp) li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__vmx__sigsetjmp)) -END (BP_SYM (__vmx__setjmp)) + b JUMPTARGET (__vmx__sigsetjmp) +END (__vmxsetjmp) +strong_alias (__vmxsetjmp, __vmx__setjmp) +strong_alias (__vmx__sigsetjmp, __setjmp) +default_symbol_version (__vmxsetjmp, setjmp, GLIBC_2.3.4) --- libc/sysdeps/powerpc/powerpc32/__longjmp.S.jj 2004-03-13 10:23:15.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc32/__longjmp.S 2004-07-05 14:00:52.485508208 +0200 @@ -25,15 +25,13 @@ # include "__longjmp-common.S" #else /* !NOT_IN_libc */ -/* Build a versioned object for libc. */ -default_symbol_version (__vmx__longjmp,__longjmp,GLIBC_2.3.4); +strong_alias (__vmx__longjmp, __longjmp); # define __longjmp __vmx__longjmp # include "__longjmp-common.S" # if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) # define __NO_VMX__ # undef JB_SIZE -symbol_version (__novmx__longjmp,__longjmp,GLIBC_2.0); # undef __longjmp # define __longjmp __novmx__longjmp # include "__longjmp-common.S" --- libc/sysdeps/powerpc/powerpc32/bsd-setjmp.S.jj 2004-03-23 15:51:34.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc32/bsd-setjmp.S 2004-07-05 13:59:48.342784078 +0200 @@ -23,34 +23,19 @@ #if defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) - -/* We need 2 copies of identical code for the setjmp's as gas complains - erroneously about having multiple versions of setjmp. This eliminates the - need for the strong alias of __setjmp to setjmp which - does not support versioning, i.e. another gas unimplemented feature. */ -symbol_version (__novmx__setjmp,__setjmp,GLIBC_2.0) -symbol_version (__novmxsetjmp,setjmp,GLIBC_2.0) - -ENTRY (BP_SYM (__novmxsetjmp)) +ENTRY (__novmxsetjmp) li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__novmx__sigsetjmp)) -END (BP_SYM (__novmxsetjmp)) + b JUMPTARGET (__novmx__sigsetjmp) +END (__novmxsetjmp) +strong_alias (__novmxsetjmp, __novmx__setjmp) +symbol_version (__novmxsetjmp, setjmp, GLIBC_2.0) -ENTRY (BP_SYM (__novmx__setjmp)) - li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__novmx__sigsetjmp)) -END (BP_SYM (__novmx__setjmp)) #endif /* defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) ) */ -default_symbol_version (__vmx__setjmp,__setjmp,GLIBC_2.3.4) -default_symbol_version (__vmxsetjmp,setjmp,GLIBC_2.3.4) - -ENTRY (BP_SYM (__vmxsetjmp)) - li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__vmx__sigsetjmp)) -END (BP_SYM (__vmxsetjmp)) - -ENTRY (BP_SYM (__vmx__setjmp)) +ENTRY (__vmxsetjmp) li r4,1 /* Set second argument to 1. */ - b JUMPTARGET (BP_SYM (__vmx__sigsetjmp)) -END (BP_SYM (__vmx__setjmp)) + b JUMPTARGET (__vmx__sigsetjmp) +END (__vmxsetjmp) +strong_alias (__vmxsetjmp, __vmx__setjmp) +strong_alias (__vmx__setjmp, __setjmp) +default_symbol_version (__vmxsetjmp,setjmp,GLIBC_2.3.4) --- libc/sysdeps/powerpc/sigjmp.c.jj 2004-03-23 15:51:34.000000000 +0100 +++ libc/sysdeps/powerpc/sigjmp.c 2004-07-05 13:45:11.804878241 +0200 @@ -37,10 +37,4 @@ __vmx__sigjmp_save (sigjmp_buf env, int return 0; } -#if defined NOT_IN_libc -/* Build a non-versioned object for rtld-*. */ strong_alias (__vmx__sigjmp_save,__sigjmp_save) -#else -/* Build a versioned object for libc. */ -default_symbol_version (__vmx__sigjmp_save,__sigjmp_save,GLIBC_2.3.4); -#endif --- libc/sysdeps/powerpc/longjmp.c.jj 2004-03-13 10:23:15.000000000 +0100 +++ libc/sysdeps/powerpc/longjmp.c 2004-07-05 13:13:52.122336315 +0200 @@ -55,8 +55,8 @@ weak_alias (__vmx__libc_siglongjmp, __vm weak_alias (__vmx__libc_siglongjmp, __vmxsiglongjmp) -default_symbol_version (__vmx__libc_longjmp, __libc_longjmp, GLIBC_2.3.4); -default_symbol_version (__vmx__libc_siglongjmp, __libc_siglongjmp, GLIBC_2.3.4); +default_symbol_version (__vmx__libc_longjmp, __libc_longjmp, GLIBC_PRIVATE); +default_symbol_version (__vmx__libc_siglongjmp, __libc_siglongjmp, GLIBC_PRIVATE); default_symbol_version (__vmx_longjmp, _longjmp, GLIBC_2.3.4); default_symbol_version (__vmxlongjmp, longjmp, GLIBC_2.3.4); default_symbol_version (__vmxsiglongjmp, siglongjmp, GLIBC_2.3.4); --- libc/sysdeps/powerpc/novmx-sigjmp.c.jj 2004-02-14 04:27:57.000000000 +0100 +++ libc/sysdeps/powerpc/novmx-sigjmp.c 2004-07-05 14:19:07.628982470 +0200 @@ -41,10 +41,5 @@ __novmx__sigjmp_save (__novmx__sigjmp_bu return 0; } -# if __WORDSIZE == 64 -symbol_version (__novmx__sigjmp_save,__sigjmp_save,GLIBC_2.3); -# else -symbol_version (__novmx__sigjmp_save,__sigjmp_save,GLIBC_2.0); -# endif /* __WORDSIZE == 64 */ # endif /* SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) */ #endif /* !NOT_IN_libc && SHARED */ Jakub From drepper@redhat.com Mon Jul 5 17:10:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 05 Jul 2004 17:10:00 -0000 Subject: [PATCH] Fix nscd_getgr_r.c In-Reply-To: <20040705064504.GA5191@sunsite.ms.mff.cuni.cz> References: <20040705064504.GA5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E98ACA.7060904@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Mon Jul 5 17:10:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 05 Jul 2004 17:10:00 -0000 Subject: [PATCH] Fix ppc64 libc In-Reply-To: <20040705103341.GB5191@sunsite.ms.mff.cuni.cz> References: <20040705103341.GB5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E98AE2.6030602@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Mon Jul 5 17:10:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jul 2004 17:10:00 -0000 Subject: [PATCH] libc_hidden_builtin_* for ffs Message-ID: <20040705145512.GC5191@sunsite.ms.mff.cuni.cz> Hi! This is a follow-up for the s390 .plt slot removal patch. 2004-07-05 Jakub Jelinek * include/string.h (ffs): Add libc_hidden_builtin_proto. * sysdeps/rs6000/ffs.c (ffs): Add libc_hidden_builtin_def. * sysdeps/alpha/alphaev67/ffs.S (ffs): Likewise. * sysdeps/alpha/ffs.S (ffs): Likewise. * sysdeps/s390/ffs.c (ffs): Likewise. * sysdeps/powerpc/ffs.c (ffs): Likewise. * sysdeps/i386/ffs.c (ffs): Likewise. * sysdeps/i386/i686/ffs.c (ffs): Likewise. * sysdeps/m68k/ffs.c (ffs): Likewise. * sysdeps/generic/ffs.c (ffs): Likewise. * sysdeps/m88k/ffs.c (ffs): Likewise. * sysdeps/am29k/ffs.c (ffs): Likewise. * sysdeps/i960/ffs.c (ffs): Likewise. * sysdeps/x86_64/ffs.c (ffs): Likewise. --- libc/sysdeps/rs6000/ffs.c.jj 2001-07-06 06:56:02.000000000 +0200 +++ libc/sysdeps/rs6000/ffs.c 2004-07-05 09:00:52.095995998 +0200 @@ -1,6 +1,6 @@ /* ffs -- find first set bit in a word, counted from least significant end. For IBM rs6000. - Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -35,6 +35,7 @@ __ffs (x) return 32 - cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #else #include --- libc/sysdeps/alpha/alphaev67/ffs.S.jj 2001-07-06 06:55:47.000000000 +0200 +++ libc/sysdeps/alpha/alphaev67/ffs.S 2004-07-05 09:01:22.728610289 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2004 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 @@ -48,3 +48,4 @@ ENTRY(__ffs) END(__ffs) weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) --- libc/sysdeps/alpha/ffs.S.jj 2001-07-06 06:55:45.000000000 +0200 +++ libc/sysdeps/alpha/ffs.S 2004-07-05 09:01:35.806311016 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 2004 Free Software Foundation, Inc. Contributed by David Mosberger (davidm@cs.arizona.edu). This file is part of the GNU C Library. @@ -86,5 +86,6 @@ $ffsl..ng: END(ffsl) weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) weak_extern (ffsl) weak_alias (ffsl, ffsll) --- libc/sysdeps/s390/ffs.c.jj 2004-04-17 12:14:26.000000000 +0200 +++ libc/sysdeps/s390/ffs.c 2004-07-05 09:02:01.151854850 +0200 @@ -64,6 +64,7 @@ __ffs (x) } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #if ULONG_MAX == UINT_MAX #undef ffsl weak_alias (__ffs, ffsl) --- libc/sysdeps/powerpc/ffs.c.jj 2004-04-13 10:42:55.000000000 +0200 +++ libc/sysdeps/powerpc/ffs.c 2004-07-05 09:02:13.574670713 +0200 @@ -36,6 +36,7 @@ __ffs (int x) return 32 - cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #if ULONG_MAX == UINT_MAX #undef ffsl weak_alias (__ffs, ffsl) --- libc/sysdeps/i386/ffs.c.jj 2001-07-06 06:55:52.000000000 +0200 +++ libc/sysdeps/i386/ffs.c 2004-07-05 09:02:28.903975564 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For Intel 80x86, x>=3. This file is part of the GNU C Library. - Copyright (C) 1991, 92, 93, 94, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 93, 94, 97, 98, 2004 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). The GNU C Library is free software; you can redistribute it and/or @@ -42,6 +42,7 @@ __ffs (x) return cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #undef ffsl weak_alias (__ffs, ffsl) --- libc/sysdeps/i386/i686/ffs.c.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/i686/ffs.c 2004-07-05 09:02:47.277745146 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For Intel 80x86, x>=6. This file is part of the GNU C Library. - Copyright (C) 1991, 92, 93, 94, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 93, 94, 97, 98, 2004 Free Software Foundation, Inc. Contributed by Ulrich Drepper . The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +40,7 @@ __ffs (x) return cnt + 1; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #undef ffsl weak_alias (__ffs, ffsl) --- libc/sysdeps/m68k/ffs.c.jj 2001-07-06 06:55:55.000000000 +0200 +++ libc/sysdeps/m68k/ffs.c 2004-07-05 09:03:02.501068626 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For mc68020, mc68030, mc68040. This file is part of the GNU C Library. - Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1997, 1998, 2004 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). The GNU C Library is free software; you can redistribute it and/or @@ -37,6 +37,7 @@ __ffs (x) return 32 - cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #undef ffsl weak_alias (__ffs, ffsl) --- libc/sysdeps/generic/ffs.c.jj 2001-07-06 06:55:49.000000000 +0200 +++ libc/sysdeps/generic/ffs.c 2004-07-05 09:03:18.445265364 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1997, 1998, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -47,6 +47,7 @@ __ffs (i) return table[x >> a] + a; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #if ULONG_MAX == UINT_MAX #undef ffsl --- libc/sysdeps/m88k/ffs.c.jj 2001-07-06 06:55:56.000000000 +0200 +++ libc/sysdeps/m88k/ffs.c 2004-07-05 09:03:28.242542833 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For Motorola 88000. This file is part of the GNU C Library. - Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). The GNU C Library is free software; you can redistribute it and/or @@ -38,6 +38,7 @@ __ffs (x) return cnt + 1; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #else #include --- libc/sysdeps/am29k/ffs.c.jj 2001-07-06 06:55:47.000000000 +0200 +++ libc/sysdeps/am29k/ffs.c 2004-07-05 09:03:39.142626410 +0200 @@ -1,6 +1,6 @@ /* ffs -- find first set bit in a word, counted from least significant end. For Amd 290x0. - Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -36,6 +36,7 @@ __ffs (x) return 32 - cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #else #include --- libc/sysdeps/i960/ffs.c.jj 2001-07-06 06:55:54.000000000 +0200 +++ libc/sysdeps/i960/ffs.c 2004-07-05 09:03:48.763934818 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For i960 Core architecture This file is part of the GNU C Library. - Copyright (C) 1994, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1997, 2004 Free Software Foundation, Inc. Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), On-Line Applications Research Corporation. @@ -37,6 +37,7 @@ __ffs (x) return cnt; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) #else --- libc/sysdeps/x86_64/ffs.c.jj 2001-09-19 12:12:08.000000000 +0200 +++ libc/sysdeps/x86_64/ffs.c 2004-07-05 09:04:03.252387494 +0200 @@ -1,7 +1,7 @@ /* ffs -- find first set bit in a word, counted from least significant end. For AMD x86-64. This file is part of the GNU C Library. - Copyright (C) 1991,92,93,94,97,98,2001 Free Software Foundation, Inc. + Copyright (C) 1991,92,93,94,97,98,2001,2004 Free Software Foundation, Inc. Contributed by Ulrich Drepper . The GNU C Library is free software; you can redistribute it and/or @@ -36,3 +36,4 @@ __ffs (int x) return cnt + 1; } weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) --- libc/include/string.h.jj 2004-06-11 14:45:47.000000000 +0200 +++ libc/include/string.h 2004-07-05 08:58:46.458085101 +0200 @@ -100,6 +100,7 @@ libc_hidden_builtin_proto (stpcpy) libc_hidden_builtin_proto (strrchr) libc_hidden_builtin_proto (strspn) libc_hidden_builtin_proto (strstr) +libc_hidden_builtin_proto (ffs) # ifndef _ISOMAC # ifndef index Jakub From jakub@redhat.com Mon Jul 5 17:11:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jul 2004 17:11:00 -0000 Subject: [PATCH] Fix make check-abi Message-ID: <20040705145602.GD5191@sunsite.ms.mff.cuni.cz> Hi! Current diff doesn't like -pu0: diff: `-0' option is obsolete; use `-U 0' diff: Try `diff --help' for more information. 2004-07-05 Jakub Jelinek * Makerules (check-abi): Use diff -p -U 0 instead of diff -pu0. --- libc/Makerules.jj 2004-04-13 10:42:50.000000000 +0200 +++ libc/Makerules 2004-07-05 14:50:46.602142300 +0200 @@ -1191,7 +1191,7 @@ define check-abi LC_ALL=C \ $(AWK) -f $< -v 'config=$(check-abi-config)' \ $(filter %.abilist,$^) \ - | { diff -pu0 - $(filter %.symlist,$^) $(check-abi-warn) ; } + | { diff -p -U 0 - $(filter %.symlist,$^) $(check-abi-warn) ; } endef ifeq ($(enable-check-abi),warn) check-abi-warn = || echo '*** WARNING: $*.so failed ABI check' Jakub From jakub@redhat.com Mon Jul 5 17:12:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 05 Jul 2004 17:12:00 -0000 Subject: [PATCH] Get rid of matching constraint does not allow a register warnings Message-ID: <20040705145648.GE5191@sunsite.ms.mff.cuni.cz> Hi! 2004-07-05 Jakub Jelinek nptl/ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_unlock): Use constraint "m" instead of "0" for futex. linuxthreads/ * sysdeps/s390/pspinlock.c (__pthread_spin_lock, __pthread_spin_trylock): Use constraint "m" instead of "0" for futex. * sysdeps/ia64/pt-machine.h (__compare_and_swap, __compare_and_swap_with_release_semantic, testandset): Use constraint "m" instead of "0" for futex. --- libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h.jj 2004-03-24 12:17:01.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h 2004-07-05 15:47:25.369634756 +0200 @@ -272,7 +272,7 @@ extern int lll_unlock_wake_cb (int *__fu ".previous\n" \ "2:" \ : "=m" (futex), "=&D" (ignore) \ - : "0" (futex) \ + : "m" (futex) \ : "ax", "cx", "r11", "cc", "memory"); }) #endif --- libc/linuxthreads/sysdeps/s390/pspinlock.c.jj 2003-04-12 00:06:02.000000000 +0200 +++ libc/linuxthreads/sysdeps/s390/pspinlock.c 2004-07-05 15:50:53.737004225 +0200 @@ -1,5 +1,5 @@ /* POSIX spinlock implementation. S/390 version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2004 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -39,7 +39,7 @@ __pthread_spin_lock (pthread_spinlock_t " cs 0,1,%1\n" " jl 0b\n" : "=m" (*lock) - : "0" (*lock) : "0", "1", "cc" ); + : "m" (*lock) : "0", "1", "cc" ); return 0; } weak_alias (__pthread_spin_lock, pthread_spin_lock) @@ -53,7 +53,7 @@ __pthread_spin_trylock (pthread_spinlock " basr 1,0\n" "0: cs %1,1,%0" : "=m" (*lock), "=&d" (oldval) - : "0" (*lock) : "1", "cc" ); + : "m" (*lock) : "1", "cc" ); return oldval == 0 ? 0 : EBUSY; } weak_alias (__pthread_spin_trylock, pthread_spin_trylock) --- libc/linuxthreads/sysdeps/ia64/pt-machine.h.jj 2004-03-23 15:51:13.000000000 +0100 +++ libc/linuxthreads/sysdeps/ia64/pt-machine.h 2004-07-05 15:48:55.424803303 +0200 @@ -89,7 +89,7 @@ __compare_and_swap (long int *p, long in ("mov ar.ccv=%4;;\n\t" "cmpxchg8.acq %0=%1,%2,ar.ccv" : "=r" (readval), "=m" (__atomic_fool_gcc (p)) - : "r"(newval), "1" (__atomic_fool_gcc (p)), "r" (oldval) + : "r"(newval), "m" (__atomic_fool_gcc (p)), "r" (oldval) : "memory"); return readval == oldval; } @@ -105,7 +105,7 @@ __compare_and_swap_with_release_semantic ("mov ar.ccv=%4;;\n\t" "cmpxchg8.rel %0=%1,%2,ar.ccv" : "=r" (readval), "=m" (__atomic_fool_gcc (p)) - : "r"(newval), "1" (__atomic_fool_gcc (p)), "r" (oldval) + : "r"(newval), "m" (__atomic_fool_gcc (p)), "r" (oldval) : "memory"); return readval == oldval; } @@ -121,7 +121,7 @@ testandset (int *spinlock) __asm__ __volatile__( "xchg4 %0=%1,%2" : "=r"(ret), "=m"(__atomic_fool_gcc (spinlock)) - : "r"(1), "1"(__atomic_fool_gcc (spinlock)) + : "r"(1), "m"(__atomic_fool_gcc (spinlock)) : "memory"); return ret; Jakub From drepper@redhat.com Mon Jul 5 17:32:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 05 Jul 2004 17:32:00 -0000 Subject: [PATCH] Get rid of matching constraint does not allow a register warnings In-Reply-To: <20040705145648.GE5191@sunsite.ms.mff.cuni.cz> References: <20040705145648.GE5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E98FE8.9030906@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Mon Jul 5 17:33:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 05 Jul 2004 17:33:00 -0000 Subject: [PATCH] Fix make check-abi In-Reply-To: <20040705145602.GD5191@sunsite.ms.mff.cuni.cz> References: <20040705145602.GD5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E99037.1030206@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Mon Jul 5 17:38:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 05 Jul 2004 17:38:00 -0000 Subject: [PATCH] libc_hidden_builtin_* for ffs In-Reply-To: <20040705145512.GC5191@sunsite.ms.mff.cuni.cz> References: <20040705145512.GC5191@sunsite.ms.mff.cuni.cz> Message-ID: <40E99160.70200@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Tue Jul 6 20:40:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 06 Jul 2004 20:40:00 -0000 Subject: [PATCH] Fix has_holes mprotect in dl-load.c Message-ID: <20040706182508.GF5191@sunsite.ms.mff.cuni.cz> Hi! l_text_end is not set at this point yet and even if it would, if first PT_LOAD segment is not executable, it would still be 0. Doing mprotect (0, up to few MB, PROT_NONE) is bad and mprotecting l->l_laddr + c->mapend is really what is needed. Before this patch ld.so did: strace /lib64/ld-linux-x86-64.so.2 /bin/echo ... open("/lib64/tls/libc.so.6", O_RDONLY) = 4 ... mmap(0x3072d00000, 2137672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x3072d00000 mprotect(0, 970312, PROT_NONE) = -1 ENOMEM (Cannot allocate memory) mmap(0x3072f00000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0x200000) = 0x3072f00000 ... mprotect(0x3072f00000, 16384, PROT_READ) = 0 ... for libc.so.6: readelf -Wl /lib64/tls/libc.so.6 | egrep LOAD\|RELRO LOAD 0x000000 0x0000003072d00000 0x0000003072d00000 0x11c72b 0x11c72b R E 0x100000 LOAD 0x200f30 0x0000003072f00f30 0x0000003072f00f30 0x004ad0 0x008f18 RW 0x100000 GNU_RELRO 0x200f30 0x0000003072f00f30 0x0000003072f00f30 0x0030d0 0x0030d0 R 0x1 With this patch: strace elf/ld.so /bin/echo ... open("/lib64/tls/libc.so.6", O_RDONLY) = 4 ... mmap(0x3072d00000, 2137672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x3072d00000 mprotect(0x3072e1d000, 970312, PROT_NONE) = 0 mmap(0x3072f00000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0x200000) = 0x3072f00000 ... mprotect(0x3072f00000, 16384, PROT_READ) = 0 ... 2004-07-06 Jakub Jelinek * elf/dl-load.c (_dl_map_object_from_fd): If has_holes, mprotect l->l_addr + c->mapend instead of l->l_text_end. --- libc/elf/dl-load.c.jj 2004-05-26 16:04:38.000000000 +0200 +++ libc/elf/dl-load.c 2004-07-06 22:21:04.054995231 +0200 @@ -1117,7 +1117,7 @@ cannot allocate TLS data structures for unallocated. Then jump into the normal segment-mapping loop to handle the portion of the segment past the end of the file mapping. */ - __mprotect ((caddr_t) l->l_text_end, + __mprotect ((caddr_t) (l->l_addr + c->mapend), loadcmds[nloadcmds - 1].allocend - c->mapend, PROT_NONE); Jakub From schwab@suse.de Tue Jul 6 22:42:00 2004 From: schwab@suse.de (Andreas Schwab) Date: Tue, 06 Jul 2004 22:42:00 -0000 Subject: [PATCH] Fix has_holes mprotect in dl-load.c In-Reply-To: <20040706182508.GF5191@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Tue, 6 Jul 2004 20:25:08 +0200") References: <20040706182508.GF5191@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Hi! > > l_text_end is not set at this point yet and even if it would, > if first PT_LOAD segment is not executable, it would still be 0. > Doing mprotect (0, up to few MB, PROT_NONE) is bad and > mprotecting l->l_laddr + c->mapend is really what is needed. See . Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstra??e 5, 90409 N??rnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From roland@redhat.com Tue Jul 6 22:57:00 2004 From: roland@redhat.com (Roland McGrath) Date: Tue, 06 Jul 2004 22:57:00 -0000 Subject: AC_DEFINE(HAVE_INLINED_SYSCALLS) Message-ID: <200407062257.i66MvuEE019744@magilla.sf.frob.com> Using config.h defines should really be avoided whenever possible, and preferably reserved entirely for things set by autoconf checks. Unless there is a special reason I am overlooking, please revert this: * sysdeps/unix/sysv/linux/configure.in: Define HAVE_INLINED_SYSCALLS. * config.h.in: Add entry for HAVE_INLINED_SYSCALLS. and instead put #define HAVE_INLINED_SYSCALLS into sysdep.h files. Thanks, Roland From roland@redhat.com Tue Jul 6 23:00:00 2004 From: roland@redhat.com (Roland McGrath) Date: Tue, 06 Jul 2004 23:00:00 -0000 Subject: Fix mapping of DSOs with holes In-Reply-To: Andreas Schwab's message of Tuesday, 18 May 2004 02:39:58 +0200 Message-ID: <200407062300.i66N03Fl019799@magilla.sf.frob.com> > 2004-05-18 Andreas Schwab > > * elf/dl-load.c (_dl_map_object_from_fd): Use the end address of > the first segment for mprotect, not l_text_end. I've put this in now. Thanks, Roland From drepper@redhat.com Wed Jul 7 06:05:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 07 Jul 2004 06:05:00 -0000 Subject: AC_DEFINE(HAVE_INLINED_SYSCALLS) In-Reply-To: <200407062257.i66MvuEE019744@magilla.sf.frob.com> References: <200407062257.i66MvuEE019744@magilla.sf.frob.com> Message-ID: <40EB9252.3060802@redhat.com> The reason for using config.h is to not requiring to include sysdep.h in files where it is not needed. That is a potentially quite expensive to use header. And I honestly don't see problems with using config.h. I think such general platform-specific defines are indeed well kept in this file. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Wed Jul 7 17:50:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 07 Jul 2004 17:50:00 -0000 Subject: [PATCH] dl-fini.c fix Message-ID: <20040707153459.GK5191@sunsite.ms.mff.cuni.cz> Hi! I believe we must store GL(dl_nloaded) into a local variable before releasing GL(dl_load_lock), as after unlock GL(dl_nloaded) can be e.g. increased at any time and we wouldn't know exactly what size the maps array exactly had. 2004-07-07 Jakub Jelinek * elf/dl-fini.c (_dl_fini): Add nloaded variable, load GL(dl_nloaded) into it while still in critical section. --- libc/elf/dl-fini.c.jj 2004-07-07 19:37:01.000000000 +0200 +++ libc/elf/dl-fini.c 2004-07-07 19:42:11.640215410 +0200 @@ -42,23 +42,24 @@ _dl_fini (void) using `dlopen' there are possibly several other modules with its dependencies to be taken into account. Therefore we have to start determining the order of the modules once again from the beginning. */ - unsigned int i; + unsigned int i, nloaded; struct link_map *l; struct link_map **maps; /* Protect against concurrent loads and unloads. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); + nloaded = GL(dl_nloaded); + /* XXX Could it be (in static binaries) that there is no object loaded? */ - assert (GL(dl_nloaded) > 0); + assert (nloaded > 0); /* Now we can allocate an array to hold all the pointers and copy the pointers in. */ - maps = (struct link_map **) alloca (GL(dl_nloaded) - * sizeof (struct link_map *)); + maps = (struct link_map **) alloca (nloaded * sizeof (struct link_map *)); for (l = GL(dl_loaded), i = 0; l != NULL; l = l->l_next) { - assert (i < GL(dl_nloaded)); + assert (i < nloaded); maps[i++] = l; @@ -66,7 +67,7 @@ _dl_fini (void) from underneath us. */ ++l->l_opencount; } - assert (i == GL(dl_nloaded)); + assert (i == nloaded); /* Now we have to do the sorting. */ for (l = GL(dl_loaded)->l_next; l != NULL; l = l->l_next) @@ -80,7 +81,7 @@ _dl_fini (void) /* Find all object for which the current one is a dependency and move the found object (if necessary) in front. */ - for (k = j + 1; k < GL(dl_nloaded); ++k) + for (k = j + 1; k < nloaded; ++k) { struct link_map **runp = maps[k]->l_initfini; if (runp != NULL) @@ -136,7 +137,7 @@ _dl_fini (void) /* 'maps' now contains the objects in the right order. Now call the destructors. We have to process this array from the front. */ - for (i = 0; i < GL(dl_nloaded); ++i) + for (i = 0; i < nloaded; ++i) { l = maps[i]; Jakub From drepper@redhat.com Thu Jul 8 03:20:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 08 Jul 2004 03:20:00 -0000 Subject: [PATCH] dl-fini.c fix In-Reply-To: <20040707153459.GK5191@sunsite.ms.mff.cuni.cz> References: <20040707153459.GK5191@sunsite.ms.mff.cuni.cz> Message-ID: <40ECBD0D.90902@redhat.com> I overlooked that one variable access. With the patch the code should be fine. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Thu Jul 8 23:17:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 08 Jul 2004 23:17:00 -0000 Subject: [PATCH] Fix linuxthreads clock_[gs]ettime Message-ID: <20040707135007.GJ5191@sunsite.ms.mff.cuni.cz> Hi! On 2003-06-24, clock_[gs]ettime and __pthread_clock_[gs]ettime in NPTL have been changed to pass additional argument to __pthread_clock_[gs]ettime, but linuxthreads was not updated. Even a simple proglet like: #include int main (void) { struct timespec ts; clock_gettime (CLOCK_THREAD_CPUTIME_ID, &ts); return 0; } segfaults with LinuxThreads. While looking into this, I have noticed that: a) x86_64 has HP_TIMING_AVAIL, but due to missing Versions in linuxthreads __pthread_clock_[gs]ettime is not exported from libpthread.so.0 b) neither x86_64 nor ia64 in linuxthreads signal that they have _POSIX_THREAD_CPUTIME and _POSIX_CPUTIME (the headers below are copies of linuxthreads/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h). 2004-07-07 Jakub Jelinek * sysdeps/pthread/getcpuclockid.c (pthread_getcpuclockid): Allow using other thread's clock. * ptclock_gettime.c (__pthread_clock_gettime): Likewise. * ptclock_settime.c (__pthread_clock_settime): Likewise. * internals.h (__pthread_clock_gettime, __pthread_clock_settime): Remove prototypes. Reported by Bernd Schmidt . * Makefile (librt-tests): Add tst-clock1. * tst-clock1.c: New test. * sysdeps/x86_64/Versions: New file. * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: New file. * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: New file. --- libc/linuxthreads/ptclock_settime.c.jj 2002-08-27 00:39:45.000000000 +0200 +++ libc/linuxthreads/ptclock_settime.c 2004-07-07 13:11:46.081380554 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2004 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 @@ -16,18 +16,40 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include #include "internals.h" +#include "spinlock.h" #if HP_TIMING_AVAIL -void -__pthread_clock_settime (hp_timing_t offset) +int +__pthread_clock_settime (clockid_t clock_id, hp_timing_t offset) { pthread_descr self = thread_self (); + pthread_t thread = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE; + const unsigned int mask = ~0U >> CLOCK_IDFIELD_SIZE; - /* Compute the offset since the start time of the process. */ - THREAD_SETMEM (self, p_cpuclock_offset, offset); + if (thread == 0 || (THREAD_GETMEM (self, p_tid) & mask) == thread) + /* Our own clock. */ + THREAD_SETMEM (self, p_cpuclock_offset, offset); + else + { + pthread_descr th; + pthread_handle handle = thread_handle (thread); + __pthread_lock (&handle->h_lock, NULL); + th = handle->h_descr; + if (th == NULL || (th->p_tid & mask) != thread || th->p_terminated) + { + __pthread_unlock (&handle->h_lock); + __set_errno (EINVAL); + return -1; + } + th->p_cpuclock_offset = offset; + __pthread_unlock (&handle->h_lock); + } + + return 0; } #endif --- libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h.jj 2004-07-07 13:23:06.000000000 +0200 +++ libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h 2004-07-07 13:23:35.916140671 +0200 @@ -0,0 +1,144 @@ +/* Define POSIX options for Linux/ia64. + Copyright (C) 1996-2001, 2002, 2003, 2004 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; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _POSIX_OPT_H +#define _POSIX_OPT_H 1 + +/* Job control is supported. */ +#define _POSIX_JOB_CONTROL 1 + +/* Processes have a saved set-user-ID and a saved set-group-ID. */ +#define _POSIX_SAVED_IDS 1 + +/* Priority scheduling is supported. */ +#define _POSIX_PRIORITY_SCHEDULING 200112L + +/* Synchronizing file data is supported. */ +#define _POSIX_SYNCHRONIZED_IO 200112L + +/* The fsync function is present. */ +#define _POSIX_FSYNC 200112L + +/* Mapping of files to memory is supported. */ +#define _POSIX_MAPPED_FILES 200112L + +/* Locking of all memory is supported. */ +#define _POSIX_MEMLOCK 200112L + +/* Locking of ranges of memory is supported. */ +#define _POSIX_MEMLOCK_RANGE 200112L + +/* Setting of memory protections is supported. */ +#define _POSIX_MEMORY_PROTECTION 200112L + +/* Only root can change owner of file. */ +#define _POSIX_CHOWN_RESTRICTED 1 + +/* `c_cc' member of 'struct termios' structure can be disabled by + using the value _POSIX_VDISABLE. */ +#define _POSIX_VDISABLE '\0' + +/* Filenames are not silently truncated. */ +#define _POSIX_NO_TRUNC 1 + +/* X/Open realtime support is available. */ +#define _XOPEN_REALTIME 1 + +/* X/Open realtime thread support is available. */ +#define _XOPEN_REALTIME_THREADS 1 + +/* XPG4.2 shared memory is supported. */ +#define _XOPEN_SHM 1 + +/* Tell we have POSIX threads. */ +#define _POSIX_THREADS 200112L + +/* We have the reentrant functions described in POSIX. */ +#define _POSIX_REENTRANT_FUNCTIONS 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +/* We provide priority scheduling for threads. */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L + +/* We support user-defined stack sizes. */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + +/* We support user-defined stacks. */ +#define _POSIX_THREAD_ATTR_STACKADDR 200112L + +/* We support POSIX.1b semaphores, but only the non-shared form for now. */ +#define _POSIX_SEMAPHORES 200112L + +/* Real-time signals are supported. */ +#define _POSIX_REALTIME_SIGNALS 200112L + +/* We support asynchronous I/O. */ +#define _POSIX_ASYNCHRONOUS_IO 200112L +#define _POSIX_ASYNC_IO 1 +/* Alternative name for Unix98. */ +#define _LFS_ASYNCHRONOUS_IO 1 + +/* The LFS support in asynchronous I/O is also available. */ +#define _LFS64_ASYNCHRONOUS_IO 1 + +/* The rest of the LFS is also available. */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 + +/* POSIX shared memory objects are implemented. */ +#define _POSIX_SHARED_MEMORY_OBJECTS 200112L + +/* CPU-time clocks supported. */ +#define _POSIX_CPUTIME 200112L + +/* We support the clock also in threads. */ +#define _POSIX_THREAD_CPUTIME 200112L + +/* GNU libc provides regular expression handling. */ +#define _POSIX_REGEXP 1 + +/* Reader/Writer locks are available. */ +#define _POSIX_READER_WRITER_LOCKS 200112L + +/* We have a POSIX shell. */ +#define _POSIX_SHELL 1 + +/* We support the Timeouts option. */ +#define _POSIX_TIMEOUTS 200112L + +/* We support spinlocks. */ +#define _POSIX_SPIN_LOCKS 200112L + +/* The `spawn' function family is supported. */ +#define _POSIX_SPAWN 200112L + +/* We have POSIX timers. */ +#define _POSIX_TIMERS 200112L + +/* The barrier functions are available. */ +#define _POSIX_BARRIERS 200112L + +/* POSIX message queues are available. */ +#define _POSIX_MESSAGE_PASSING 200112L + +/* The monotonic clock might be available. */ +#define _POSIX_MONOTONIC_CLOCK 0 + +#endif /* posix_opt.h */ --- libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h.jj 2004-07-07 13:23:06.240379068 +0200 +++ libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h 2004-07-07 13:23:00.121459109 +0200 @@ -0,0 +1,144 @@ +/* Define POSIX options for Linux/x86_64. + Copyright (C) 1996-2001, 2002, 2003, 2004 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; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _POSIX_OPT_H +#define _POSIX_OPT_H 1 + +/* Job control is supported. */ +#define _POSIX_JOB_CONTROL 1 + +/* Processes have a saved set-user-ID and a saved set-group-ID. */ +#define _POSIX_SAVED_IDS 1 + +/* Priority scheduling is supported. */ +#define _POSIX_PRIORITY_SCHEDULING 200112L + +/* Synchronizing file data is supported. */ +#define _POSIX_SYNCHRONIZED_IO 200112L + +/* The fsync function is present. */ +#define _POSIX_FSYNC 200112L + +/* Mapping of files to memory is supported. */ +#define _POSIX_MAPPED_FILES 200112L + +/* Locking of all memory is supported. */ +#define _POSIX_MEMLOCK 200112L + +/* Locking of ranges of memory is supported. */ +#define _POSIX_MEMLOCK_RANGE 200112L + +/* Setting of memory protections is supported. */ +#define _POSIX_MEMORY_PROTECTION 200112L + +/* Only root can change owner of file. */ +#define _POSIX_CHOWN_RESTRICTED 1 + +/* `c_cc' member of 'struct termios' structure can be disabled by + using the value _POSIX_VDISABLE. */ +#define _POSIX_VDISABLE '\0' + +/* Filenames are not silently truncated. */ +#define _POSIX_NO_TRUNC 1 + +/* X/Open realtime support is available. */ +#define _XOPEN_REALTIME 1 + +/* X/Open realtime thread support is available. */ +#define _XOPEN_REALTIME_THREADS 1 + +/* XPG4.2 shared memory is supported. */ +#define _XOPEN_SHM 1 + +/* Tell we have POSIX threads. */ +#define _POSIX_THREADS 200112L + +/* We have the reentrant functions described in POSIX. */ +#define _POSIX_REENTRANT_FUNCTIONS 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +/* We provide priority scheduling for threads. */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L + +/* We support user-defined stack sizes. */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + +/* We support user-defined stacks. */ +#define _POSIX_THREAD_ATTR_STACKADDR 200112L + +/* We support POSIX.1b semaphores, but only the non-shared form for now. */ +#define _POSIX_SEMAPHORES 200112L + +/* Real-time signals are supported. */ +#define _POSIX_REALTIME_SIGNALS 200112L + +/* We support asynchronous I/O. */ +#define _POSIX_ASYNCHRONOUS_IO 200112L +#define _POSIX_ASYNC_IO 1 +/* Alternative name for Unix98. */ +#define _LFS_ASYNCHRONOUS_IO 1 + +/* The LFS support in asynchronous I/O is also available. */ +#define _LFS64_ASYNCHRONOUS_IO 1 + +/* The rest of the LFS is also available. */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 + +/* POSIX shared memory objects are implemented. */ +#define _POSIX_SHARED_MEMORY_OBJECTS 200112L + +/* CPU-time clocks supported. */ +#define _POSIX_CPUTIME 200112L + +/* We support the clock also in threads. */ +#define _POSIX_THREAD_CPUTIME 200112L + +/* GNU libc provides regular expression handling. */ +#define _POSIX_REGEXP 1 + +/* Reader/Writer locks are available. */ +#define _POSIX_READER_WRITER_LOCKS 200112L + +/* We have a POSIX shell. */ +#define _POSIX_SHELL 1 + +/* We support the Timeouts option. */ +#define _POSIX_TIMEOUTS 200112L + +/* We support spinlocks. */ +#define _POSIX_SPIN_LOCKS 200112L + +/* The `spawn' function family is supported. */ +#define _POSIX_SPAWN 200112L + +/* We have POSIX timers. */ +#define _POSIX_TIMERS 200112L + +/* The barrier functions are available. */ +#define _POSIX_BARRIERS 200112L + +/* POSIX message queues are available. */ +#define _POSIX_MESSAGE_PASSING 200112L + +/* The monotonic clock might be available. */ +#define _POSIX_MONOTONIC_CLOCK 0 + +#endif /* posix_opt.h */ --- libc/linuxthreads/sysdeps/pthread/getcpuclockid.c.jj 2002-08-27 00:39:43.000000000 +0200 +++ libc/linuxthreads/sysdeps/pthread/getcpuclockid.c 2004-07-07 13:11:46.063383746 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2004 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,18 +19,27 @@ #include #include #include +#include #include int pthread_getcpuclockid (pthread_t thread_id, clockid_t *clock_id) { - /* We don't allow any process ID but our own. */ - if (thread_handle (thread_id)->h_descr != thread_self ()) - return EPERM; - #ifdef CLOCK_THREAD_CPUTIME_ID + /* We need to store the thread ID in the CLOCKID variable together + with a number identifying the clock. We reserve the low 3 bits + for the clock ID and the rest for the thread ID. This is + problematic if the thread ID is too large. But 29 bits should be + fine. + + If some day more clock IDs are needed the ID part can be + enlarged. The IDs are entirely internal. */ + if (2 * PTHREAD_THREADS_MAX + >= 1 << (8 * sizeof (*clock_id) - CLOCK_IDFIELD_SIZE)) + return ERANGE; + /* Store the number. */ - *clock_id = CLOCK_THREAD_CPUTIME_ID; + *clock_id = CLOCK_THREAD_CPUTIME_ID | (thread_id << CLOCK_IDFIELD_SIZE); return 0; #else --- libc/linuxthreads/sysdeps/x86_64/Versions.jj 2004-07-07 10:00:39.312983969 +0200 +++ libc/linuxthreads/sysdeps/x86_64/Versions 2004-07-07 13:11:46.063383746 +0200 @@ -0,0 +1,5 @@ +libpthread { + GLIBC_PRIVATE { + __pthread_clock_gettime; __pthread_clock_settime; + } +} --- libc/linuxthreads/internals.h.jj 2004-05-02 12:56:23.000000000 +0200 +++ libc/linuxthreads/internals.h 2004-07-07 13:11:46.080380731 +0200 @@ -405,9 +405,6 @@ extern int __pthread_spin_unlock (pthrea extern int __pthread_spin_init (pthread_spinlock_t *__lock, int __pshared); extern int __pthread_spin_destroy (pthread_spinlock_t *__lock); -extern int __pthread_clock_gettime (hp_timing_t freq, struct timespec *tp); -extern void __pthread_clock_settime (hp_timing_t offset); - /* Global pointers to old or new suspend functions */ extern void (*__pthread_restart)(pthread_descr); --- libc/linuxthreads/Makefile.jj 2004-05-02 12:56:58.000000000 +0200 +++ libc/linuxthreads/Makefile 2004-07-07 13:35:07.798052327 +0200 @@ -105,7 +105,7 @@ omit-deps += crti crtn CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time) endif -librt-tests = ex10 ex11 +librt-tests = ex10 ex11 tst-clock1 tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \ tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ ex17 ex18 tst-cancel tst-context bug-sleep \ --- libc/linuxthreads/tst-clock1.c.jj 2004-07-07 13:12:50.551944932 +0200 +++ libc/linuxthreads/tst-clock1.c 2004-04-13 10:42:53.000000000 +0200 @@ -0,0 +1,194 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + 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 +#include +#include + + +#if _POSIX_THREAD_CPUTIME +static pthread_barrier_t b2; +static pthread_barrier_t bN; + + +static void * +tf (void *arg) +{ + int e = pthread_barrier_wait (&b2); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + exit (1); + } + + e = pthread_barrier_wait (&bN); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + exit (1); + } + + return NULL; +} +#endif + + +int +do_test (void) +{ +#if _POSIX_THREAD_CPUTIME +# define N 10 + + if (pthread_barrier_init (&b2, NULL, 2) != 0 + || pthread_barrier_init (&bN, NULL, N + 1) != 0) + { + puts ("barrier_init failed"); + return 1; + } + + struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 }; + TEMP_FAILURE_RETRY (nanosleep (&ts, &ts)); + + pthread_t th[N + 1]; + clockid_t cl[N + 1]; +# ifndef CLOCK_THREAD_CPUTIME_ID + if (pthread_getcpuclockid (pthread_self (), &cl[0]) != 0) + { + puts ("own pthread_getcpuclockid failed"); + return 1; + } +# else + cl[0] = CLOCK_THREAD_CPUTIME_ID; +# endif + + pthread_attr_t at; + + if (pthread_attr_init (&at) != 0) + { + puts ("attr_init failed"); + return 1; + } + + if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0) + { + puts ("attr_setstacksize failed"); + return 1; + } + + int i; + int e; + for (i = 0; i < N; ++i) + { + if (pthread_create (&th[i], &at, tf, NULL) != 0) + { + puts ("create failed"); + return 1; + } + + e = pthread_barrier_wait (&b2); + if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) + { + puts ("barrier_wait failed"); + return 1; + } + + ts.tv_sec = 0; + ts.tv_nsec = 100000000; + TEMP_FAILURE_RETRY (nanosleep (&ts, &ts)); + + if (pthread_getcpuclockid (th[i], &cl[i + 1]) != 0) + { + puts ("pthread_getcpuclockid failed"); + return 1; + } + } + + if (pthread_attr_destroy (&at) != 0) + { + puts ("attr_destroy failed"); + return 1; + } + + struct timespec t[N + 1]; + for (i = 0; i < N + 1; ++i) + if (clock_gettime (cl[i], &t[i]) != 0) + { + printf ("clock_gettime round %d failed\n", i); + return 1; + } + + for (i = 0; i < N; ++i) + { + struct timespec diff; + + diff.tv_sec = t[i].tv_sec - t[i + 1].tv_sec; + diff.tv_nsec = t[i].tv_nsec - t[i + 1].tv_nsec; + if (diff.tv_nsec < 0) + { + diff.tv_nsec += 1000000000; + --diff.tv_sec; + } + + if (diff.tv_sec < 0 || (diff.tv_sec == 0 && diff.tv_nsec < 100000000)) + { + printf ("\ +difference between thread %d and %d too small (%ld.%09ld)\n", + i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec); + return 1; + } + + printf ("diff %d->%d: %ld.%09ld\n", + i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec); + } + + ts.tv_sec = 0; + ts.tv_nsec = 0; + for (i = 0; i < N + 1; ++i) + if (clock_settime (cl[i], &ts) != 0) + { + printf ("clock_settime(%d) round %d failed\n", cl[i], i); + return 1; + } + + for (i = 0; i < N + 1; ++i) + { + if (clock_gettime (cl[i], &ts) != 0) + { + puts ("clock_gettime failed"); + return 1; + } + + if (ts.tv_sec > t[i].tv_sec + || (ts.tv_sec == t[i].tv_sec && ts.tv_nsec > t[i].tv_nsec)) + { + puts ("clock_settime didn't reset clock"); + return 1; + } + } +#endif + + return 0; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" --- libc/linuxthreads/ptclock_gettime.c.jj 2002-08-27 00:39:45.000000000 +0200 +++ libc/linuxthreads/ptclock_gettime.c 2004-07-07 13:11:46.080380731 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2004 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 @@ -16,23 +16,46 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include #include "internals.h" +#include "spinlock.h" #if HP_TIMING_AVAIL int -__pthread_clock_gettime (hp_timing_t freq, struct timespec *tp) +__pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq, + struct timespec *tp) { - hp_timing_t tsc; + hp_timing_t tsc, cpuclock_offset; pthread_descr self = thread_self (); + pthread_t thread = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE; + const unsigned int mask = ~0U >> CLOCK_IDFIELD_SIZE; + + if (thread == 0 || (THREAD_GETMEM (self, p_tid) & mask) == thread) + cpuclock_offset = THREAD_GETMEM (self, p_cpuclock_offset); + else + { + pthread_descr th; + pthread_handle handle = thread_handle (thread); + __pthread_lock (&handle->h_lock, NULL); + th = handle->h_descr; + if (th == NULL || (th->p_tid & mask) != thread || th->p_terminated) + { + __pthread_unlock (&handle->h_lock); + __set_errno (EINVAL); + return -1; + } + cpuclock_offset = th->p_cpuclock_offset; + __pthread_unlock (&handle->h_lock); + } /* Get the current counter. */ HP_TIMING_NOW (tsc); /* Compute the offset since the start time of the process. */ - tsc -= THREAD_GETMEM (self, p_cpuclock_offset); + tsc -= cpuclock_offset; /* Compute the seconds. */ tp->tv_sec = tsc / freq; Jakub From drepper@redhat.com Fri Jul 9 00:02:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 09 Jul 2004 00:02:00 -0000 Subject: [PATCH] Fix linuxthreads clock_[gs]ettime In-Reply-To: <20040707135007.GJ5191@sunsite.ms.mff.cuni.cz> References: <20040707135007.GJ5191@sunsite.ms.mff.cuni.cz> Message-ID: <40EDE020.3060005@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Wed Jul 14 11:33:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 14 Jul 2004 11:33:00 -0000 Subject: [PATCH] Fix l64a description in glibc manual [BZ #266] Message-ID: <20040714091812.GP5191@sunsite.ms.mff.cuni.cz> Hi! 2004-07-14 Jakub Jelinek [BZ #266] * manual/string.texi (l64a): Note that the static buffer is 7 bytes long. Rewrite example code so that it takes account l64a output shorter than 6 characters. Reported by Julian Graham . --- libc/manual/string.texi.jj 2004-05-25 18:35:42.000000000 +0200 +++ libc/manual/string.texi 2004-07-14 13:30:21.102893652 +0200 @@ -2296,7 +2296,7 @@ this task. @comment XPG @deftypefun {char *} l64a (long int @var{n}) This function encodes a 32-bit input value using characters from the -basic character set. It returns a pointer to a 6 character buffer which +basic character set. It returns a pointer to a 7 character buffer which contains an encoded version of @var{n}. To encode a series of bytes the user must copy the returned string to a destination buffer. It returns the empty string if @var{n} is zero, which is somewhat bizarre but @@ -2321,13 +2321,17 @@ encode (const void *buf, size_t len) /* @r{We know in advance how long the buffer has to be.} */ unsigned char *in = (unsigned char *) buf; char *out = malloc (6 + ((len + 3) / 4) * 6 + 1); - char *cp = out; + char *cp = out, *p; /* @r{Encode the length.} */ /* @r{Using `htonl' is necessary so that the data can be} - @r{decoded even on machines with different byte order.} */ + @r{decoded even on machines with different byte order.} + @r{`l64a' can return a string shorter than 6 bytes, so } + @r{we pad it with encoding of 0 (}'.'@r{) at the end by } + @r{hand.} */ - cp = mempcpy (cp, l64a (htonl (len)), 6); + p = stpcpy (cp, l64a (htonl (len))); + cp = mempcpy (p, "......", 6 - (p - cp)); while (len > 3) @{ @@ -2336,12 +2340,8 @@ encode (const void *buf, size_t len) n = (n << 8) | *in++; n = (n << 8) | *in++; len -= 4; - if (n) - cp = mempcpy (cp, l64a (htonl (n)), 6); - else - /* @r{`l64a' returns the empty string for n==0, so we } - @r{must generate its encoding (}"......"@r{) by hand.} */ - cp = stpcpy (cp, "......"); + p = stpcpy (cp, l64a (htonl (n))); + cp = mempcpy (p, "......", 6 - (p - cp)); @} if (len > 0) @{ @@ -2352,8 +2352,7 @@ encode (const void *buf, size_t len) if (--len > 0) n = (n << 8) | *in; @} - memcpy (cp, l64a (htonl (n)), 6); - cp += 6; + cp = stpcpy (cp, l64a (htonl (n))); @} *cp = '\0'; return out; Jakub From kkojima@rr.iij4u.or.jp Wed Jul 14 13:02:00 2004 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Wed, 14 Jul 2004 13:02:00 -0000 Subject: [PATCH] SH: Tidy dl-machine.h Message-ID: <20040714.215927.77058290.kkojima@rr.iij4u.or.jp> Hi, The attached patch is mainly to remove _dl_starting_up from the dl-machine.h. It also removes an unused variable. Regards, kaz -- 2004-07-14 Kaz Kojima * sysdeps/sh/dl-machine.h: Don't reset _dl_starting_up here. (elf_machine_rela_relative): Remove unused valiable. diff -u3prN ORIG/libc/sysdeps/sh/dl-machine.h LOCAL/libc/sysdeps/sh/dl-machine.h --- ORIG/libc/sysdeps/sh/dl-machine.h Sat May 22 09:45:57 2004 +++ LOCAL/libc/sysdeps/sh/dl-machine.h Wed Jul 14 12:25:09 2004 @@ -364,12 +364,7 @@ _dl_start_user:\n\ add r1,r0\n\ jsr @r0\n\ nop\n\ -1: ! Clear the startup flag.\n\ - mov.l .L_dl_starting_up,r0\n\ - mov.l @(r0,r12),r0\n\ - mov #0,r2\n\ - mov.l r2,@r0\n\ - ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\ +1: ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\ mov.l .L_dl_fini,r0\n\ mov.l @(r0,r12),r4\n\ ! Jump to the user's entry point.\n\ @@ -384,8 +379,6 @@ _dl_start_user:\n\ .long _dl_init_internal@PLT\n\ .L_dl_loaded:\n\ .long _rtld_local@GOT\n\ -.L_dl_starting_up:\n\ - .long _dl_starting_up@GOT\n\ .L_dl_fini:\n\ .long _dl_fini@GOT\n\ .previous\n\ @@ -629,7 +622,6 @@ static inline void elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, void *const reloc_addr_arg) { - Elf32_Addr *const reloc_addr = reloc_addr_arg; Elf32_Addr value; if (reloc->r_addend) From kkojima@rr.iij4u.or.jp Wed Jul 14 13:02:00 2004 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Wed, 14 Jul 2004 13:02:00 -0000 Subject: [PATCH] SH: A tiny NPTL update Message-ID: <20040714.220202.107685257.kkojima@rr.iij4u.or.jp> Hi, The patch below is similar with that for x86. Regards, kaz -- 2004-07-14 Kaz Kojima * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S (__pthread_cond_timedwait): Check for invalid nanosecond in timeout value. diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S --- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S Tue Jun 29 16:26:54 2004 +++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S Wed Jul 14 14:47:16 2004 @@ -62,6 +62,12 @@ __pthread_cond_timedwait: add r0, r12 #endif + mov.l @(4,r13), r0 + mov.l .L1g, r1 + cmp/hs r1, r0 + bt/s 18f + mov #EINVAL, r0 + /* Get internal lock. */ mov #0, r3 mov #1, r4 From kkojima@rr.iij4u.or.jp Wed Jul 14 13:54:00 2004 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Wed, 14 Jul 2004 13:54:00 -0000 Subject: [PATCH] SH linuxthreads: Fix cancellation for librt Message-ID: <20040714.225400.98861576.kkojima@rr.iij4u.or.jp> Hi, The appended patch defines missing stuff for cancellation in librt. Without it, librt.so fails to build with 2.6.7 kernel headers. Regards, kaz -- 2004-07-14 Kaz Kojima * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (__local_multiple_threads): Define for librt. (SINGLE_THREAD_P): Likewise. diff -u3prN ORIG/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h LOCAL/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h --- ORIG/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h Mon Jul 5 11:14:03 2004 +++ LOCAL/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h Wed Jul 14 18:54:01 2004 @@ -99,6 +99,7 @@ # else # define __local_enable_asynccancel __librt_enable_asynccancel # define __local_disable_asynccancel __librt_disable_asynccancel +# define __local_multiple_threads __librt_multiple_threads # endif # if defined IS_IN_librt && defined PIC @@ -183,7 +184,8 @@ extern int __local_multiple_threads attr 1: # else -# define SINGLE_THREAD_P \ +# if !defined NOT_IN_libc || defined IS_IN_libpthread +# define SINGLE_THREAD_P \ mov r12,r2; \ mov.l 0f,r12; \ mova 0f,r0; \ @@ -197,6 +199,23 @@ extern int __local_multiple_threads attr 0: .long _GLOBAL_OFFSET_TABLE_; \ 1: .long __local_multiple_threads@GOTOFF; \ 2: +# else +# define SINGLE_THREAD_P \ + mov r12,r2; \ + mov.l 0f,r12; \ + mova 0f,r0; \ + add r0,r12; \ + mov.l 1f,r0; \ + mov.l @(r0,r12),r0; \ + mov.l @r0,r0; \ + mov r2,r12; \ + bra 2f; \ + tst r0,r0; \ + .align 2; \ + 0: .long _GLOBAL_OFFSET_TABLE_; \ + 1: .long __local_multiple_threads@GOT; \ + 2: +# endif # endif # endif From drepper@redhat.com Wed Jul 14 16:46:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 14 Jul 2004 16:46:00 -0000 Subject: [PATCH] SH: A tiny NPTL update In-Reply-To: <20040714.220202.107685257.kkojima@rr.iij4u.or.jp> References: <20040714.220202.107685257.kkojima@rr.iij4u.or.jp> Message-ID: <40F562E5.9060600@redhat.com> I've put in the three patches. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Wed Jul 14 17:33:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 14 Jul 2004 17:33:00 -0000 Subject: [PATCH] Fix l64a description in glibc manual [BZ #266] In-Reply-To: <20040714091812.GP5191@sunsite.ms.mff.cuni.cz> References: <20040714091812.GP5191@sunsite.ms.mff.cuni.cz> Message-ID: <40F56661.500@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From jakub@redhat.com Wed Jul 14 18:17:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 14 Jul 2004 18:17:00 -0000 Subject: [PATCH] Fix powl on x86_64 [BZ #258] Message-ID: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> Hi! i386 will need similar treatment. Not sure if fld*/f{,u}comi{,p}/j? is faster than fcompl/fnstw/testing %ah/j? or vice versa, maybe the comparisons could be coded more efficiently. 2004-07-14 Jakub Jelinek [BZ #258] * math/libm-test.inc (max_value, min_value): New variables. (initialize): Initialize them. (pow_test): Add a couple of new tests. * sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Don't generate invalid exception if |y| is >= 1L<<63. If y*log2(x) overflows to +-inf, return still +inf/+0 instead of NaN. Replace fldl MO(zero) with fldz and fldl MO(one) with fld1. --- libc/math/libm-test.inc.jj 2004-02-13 12:28:07.000000000 +0100 +++ libc/math/libm-test.inc 2004-07-14 20:09:24.475429821 +0200 @@ -169,7 +169,7 @@ static int output_points; /* Should the static int ignore_max_ulp; /* Should we ignore max_ulp? */ static FLOAT minus_zero, plus_zero; -static FLOAT plus_infty, minus_infty, nan_value; +static FLOAT plus_infty, minus_infty, nan_value, max_value, min_value; static FLOAT max_error, real_max_error, imag_max_error; @@ -3593,6 +3593,25 @@ pow_test (void) TEST_ff_f (pow, -1, plus_infty, 1); TEST_ff_f (pow, 1, minus_infty, 1); TEST_ff_f (pow, -1, minus_infty, 1); + TEST_ff_f (pow, 1, 1, 1); + TEST_ff_f (pow, 1, -1, 1); + TEST_ff_f (pow, 1, 1.25, 1); + TEST_ff_f (pow, 1, -1.25, 1); + TEST_ff_f (pow, 1, 0x1p72L, 1); + + /* pow (x, +-0) == 1. */ + TEST_ff_f (pow, plus_infty, 0, 1); + TEST_ff_f (pow, plus_infty, minus_zero, 1); + TEST_ff_f (pow, minus_infty, 0, 1); + TEST_ff_f (pow, minus_infty, minus_zero, 1); + TEST_ff_f (pow, 32.75L, 0, 1); + TEST_ff_f (pow, 32.75L, minus_zero, 1); + TEST_ff_f (pow, -32.75L, 0, 1); + TEST_ff_f (pow, -32.75L, minus_zero, 1); + TEST_ff_f (pow, 0x1p72L, 0, 1); + TEST_ff_f (pow, 0x1p72L, minus_zero, 1); + TEST_ff_f (pow, 0x1p-72L, 0, 1); + TEST_ff_f (pow, 0x1p-72L, minus_zero, 1); TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION); TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION); @@ -3609,6 +3628,10 @@ pow_test (void) TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); + TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty); + TEST_ff_f (pow, 10, -0x1p72L, 0); + TEST_ff_f (pow, max_value, max_value, plus_infty); + TEST_ff_f (pow, 10, -max_value, 0); TEST_ff_f (pow, 0, 1, 0); TEST_ff_f (pow, 0, 11, 0); @@ -3623,6 +3646,8 @@ pow_test (void) TEST_ff_f (pow, minus_zero, 2, 0); TEST_ff_f (pow, minus_zero, 11.1L, 0); + TEST_ff_f (pow, 0, plus_infty, 0); + TEST_ff_f (pow, minus_zero, plus_infty, 0); #ifndef TEST_INLINE /* pow (x, +inf) == +inf for |x| > 1. */ @@ -3667,6 +3692,11 @@ pow_test (void) /* pow (-0, y) == +0 for y > 0 and not an odd integer. */ TEST_ff_f (pow, minus_zero, 4, 0.0); + TEST_ff_f (pow, 16, 0.25L, 2); + TEST_ff_f (pow, 0x1p64L, 0.125L, 256); + TEST_ff_f (pow, 2, 4, 16); + TEST_ff_f (pow, 256, 8, 0x1p64L); + TEST_ff_f (pow, 0.75L, 1.25L, 0.697953644326574699205914060237425566L); #if defined TEST_DOUBLE || defined TEST_LDOUBLE @@ -4312,12 +4342,18 @@ initialize (void) HUGE_VALL, HUGE_VAL, HUGE_VALF); minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF, -HUGE_VALL, -HUGE_VAL, -HUGE_VALF); + max_value = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX, + LDBL_MAX, DBL_MAX, FLT_MAX); + min_value = CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN, + LDBL_MIN, DBL_MIN, FLT_MIN); (void) &plus_zero; (void) &nan_value; (void) &minus_zero; (void) &plus_infty; (void) &minus_infty; + (void) &max_value; + (void) &min_value; /* Clear all exceptions. From now on we must not get random exceptions. */ feclearexcept (FE_ALL_EXCEPT); --- libc/sysdeps/x86_64/fpu/e_powl.S.jj 2001-09-19 12:24:08.000000000 +0200 +++ libc/sysdeps/x86_64/fpu/e_powl.S 2004-07-14 20:02:06.717899272 +0200 @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +48,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##(%rip) @@ -87,6 +90,14 @@ ENTRY(__ieee754_powl) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fldl MO(p63) // 1L<<63 : y : x + fld %st(1) // y : 1L<<63 : y : x + fabs // |y| : 1L<<63 : y : x + fcomip %st(1), %st // 1L<<63 : y : x + fstp %st(0) // y : x + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -105,7 +116,7 @@ ENTRY(__ieee754_powl) negl %eax adcl $0, %edx negl %edx -4: fldl MO(one) // 1 : x +4: fld1 // 1 : x fxch 6: shrdl $1, %edx, %eax @@ -123,7 +134,7 @@ ENTRY(__ieee754_powl) /* y is ??NAN */ 30: fldt 8(%rsp) // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fucomip %st(1),%st // x : y je 31f fxch // y : x @@ -133,7 +144,7 @@ ENTRY(__ieee754_powl) .align ALIGNARG(4) 2: /* y is a real number. */ fxch // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fld %st(1) // x : 1.0 : x : y fsub %st(1) // x-1 : 1.0 : x : y fabs // |x-1| : 1.0 : x : y @@ -148,6 +159,11 @@ ENTRY(__ieee754_powl) 7: fyl2x // log2(x) : y 8: fmul %st(1) // y*log2(x) : y + fxam + fnstsw + andb $0x45, %ah + cmpb $0x05, %ah // is y*log2(x) == ??inf ? + je 28f fst %st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) @@ -158,11 +174,16 @@ ENTRY(__ieee754_powl) fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret +28: fstp %st(1) // y*log2(x) + fld1 // 1 : y*log2(x) + fscale // 2^(y*log2(x)) : y*log2(x) + fstp %st(1) // 2^(y*log2(x)) + ret // pow(x,??0) = 1 .align ALIGNARG(4) 11: fstp %st(0) // pop y - fldl MO(one) + fld1 ret // y == ??inf @@ -191,7 +212,7 @@ ENTRY(__ieee754_powl) ret .align ALIGNARG(4) -14: fldl MO(one) +14: fld1 ret .align ALIGNARG(4) @@ -275,7 +296,7 @@ ENTRY(__ieee754_powl) jz 27f // jump if not odd // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) + fld1 fdivl MO(zero) fchs ret @@ -283,7 +304,7 @@ ENTRY(__ieee754_powl) 25: fstp %st(0) 26: 27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) + fld1 fdivl MO(zero) ret @@ -310,7 +331,7 @@ ENTRY(__ieee754_powl) 22: fstp %st(0) 23: -24: fldl MO(zero) +24: fldz ret END(__ieee754_powl) Jakub From jakub@redhat.com Thu Jul 15 11:51:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 15 Jul 2004 11:51:00 -0000 Subject: [PATCH] Fix powl on i386/x86_64 [BZ #258] (take 2) In-Reply-To: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> References: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> Message-ID: <20040715093555.GA9816@sunsite.ms.mff.cuni.cz> On Wed, Jul 14, 2004 at 06:02:03PM +0200, Jakub Jelinek wrote: > i386 will need similar treatment. > Not sure if fld*/f{,u}comi{,p}/j? is faster than fcompl/fnstw/testing %ah/j? > or vice versa, maybe the comparisons could be coded more efficiently. Here is an updated version which fixes i386 too. I have done also some benchmarking and e.g. on P3 pow{f,,l} is now from 22 ticks slower to 106 ticks faster depending on input, on x86_64 (Opteron) I saw slowdowns at most 16 ticks for powl (powf and pow aren't done in assembly, so there is no change for x86_64), on Opteron -m32 from 10 ticks slower to 29 ticks faster. But more importantly it is correct. 2004-07-15 Jakub Jelinek [BZ #258] * math/libm-test.inc (max_value, min_value): New variables. (initialize): Initialize them. (pow_test): Add a couple of new tests. * sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Don't generate invalid exception if |y| >= 1U<<31. Replace fldl MO(zero) with fldz and fldl MO(one) with fld1. * sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Don't generate invalid exception if |y| >= 1L<<63. Replace fldl MO(zero) with fldz and fldl MO(one) with fld1. * sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise. If y*log2(x) overflows to +-inf, return still +inf/+0 instead of NaN. * sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Likewise. --- libc/math/libm-test.inc.jj 2004-02-13 12:28:07.000000000 +0100 +++ libc/math/libm-test.inc 2004-07-15 12:34:17.395663150 +0200 @@ -169,7 +169,7 @@ static int output_points; /* Should the static int ignore_max_ulp; /* Should we ignore max_ulp? */ static FLOAT minus_zero, plus_zero; -static FLOAT plus_infty, minus_infty, nan_value; +static FLOAT plus_infty, minus_infty, nan_value, max_value, min_value; static FLOAT max_error, real_max_error, imag_max_error; @@ -3593,6 +3593,28 @@ pow_test (void) TEST_ff_f (pow, -1, plus_infty, 1); TEST_ff_f (pow, 1, minus_infty, 1); TEST_ff_f (pow, -1, minus_infty, 1); + TEST_ff_f (pow, 1, 1, 1); + TEST_ff_f (pow, 1, -1, 1); + TEST_ff_f (pow, 1, 1.25, 1); + TEST_ff_f (pow, 1, -1.25, 1); + TEST_ff_f (pow, 1, 0x1p62L, 1); + TEST_ff_f (pow, 1, 0x1p63L, 1); + TEST_ff_f (pow, 1, 0x1p64L, 1); + TEST_ff_f (pow, 1, 0x1p72L, 1); + + /* pow (x, +-0) == 1. */ + TEST_ff_f (pow, plus_infty, 0, 1); + TEST_ff_f (pow, plus_infty, minus_zero, 1); + TEST_ff_f (pow, minus_infty, 0, 1); + TEST_ff_f (pow, minus_infty, minus_zero, 1); + TEST_ff_f (pow, 32.75L, 0, 1); + TEST_ff_f (pow, 32.75L, minus_zero, 1); + TEST_ff_f (pow, -32.75L, 0, 1); + TEST_ff_f (pow, -32.75L, minus_zero, 1); + TEST_ff_f (pow, 0x1p72L, 0, 1); + TEST_ff_f (pow, 0x1p72L, minus_zero, 1); + TEST_ff_f (pow, 0x1p-72L, 0, 1); + TEST_ff_f (pow, 0x1p-72L, minus_zero, 1); TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION); TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION); @@ -3609,6 +3631,10 @@ pow_test (void) TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); + TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty); + TEST_ff_f (pow, 10, -0x1p72L, 0); + TEST_ff_f (pow, max_value, max_value, plus_infty); + TEST_ff_f (pow, 10, -max_value, 0); TEST_ff_f (pow, 0, 1, 0); TEST_ff_f (pow, 0, 11, 0); @@ -3623,6 +3649,8 @@ pow_test (void) TEST_ff_f (pow, minus_zero, 2, 0); TEST_ff_f (pow, minus_zero, 11.1L, 0); + TEST_ff_f (pow, 0, plus_infty, 0); + TEST_ff_f (pow, minus_zero, plus_infty, 0); #ifndef TEST_INLINE /* pow (x, +inf) == +inf for |x| > 1. */ @@ -3667,6 +3695,11 @@ pow_test (void) /* pow (-0, y) == +0 for y > 0 and not an odd integer. */ TEST_ff_f (pow, minus_zero, 4, 0.0); + TEST_ff_f (pow, 16, 0.25L, 2); + TEST_ff_f (pow, 0x1p64L, 0.125L, 256); + TEST_ff_f (pow, 2, 4, 16); + TEST_ff_f (pow, 256, 8, 0x1p64L); + TEST_ff_f (pow, 0.75L, 1.25L, 0.697953644326574699205914060237425566L); #if defined TEST_DOUBLE || defined TEST_LDOUBLE @@ -4312,12 +4345,18 @@ initialize (void) HUGE_VALL, HUGE_VAL, HUGE_VALF); minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF, -HUGE_VALL, -HUGE_VAL, -HUGE_VALF); + max_value = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX, + LDBL_MAX, DBL_MAX, FLT_MAX); + min_value = CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN, + LDBL_MIN, DBL_MIN, FLT_MIN); (void) &plus_zero; (void) &nan_value; (void) &minus_zero; (void) &plus_infty; (void) &minus_infty; + (void) &max_value; + (void) &min_value; /* Clear all exceptions. From now on we must not get random exceptions. */ feclearexcept (FE_ALL_EXCEPT); --- libc/sysdeps/i386/fpu/e_powf.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_powf.S 2004-07-15 13:23:15.977438871 +0200 @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1999, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +48,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p31,@object) +p31: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x41 + ASM_SIZE_DIRECTIVE(p31) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +99,14 @@ ENTRY(__ieee754_powf) fxch // y : x + /* fistpl raises invalid exception for |y| >= 1L<<31. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p31) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -113,7 +124,7 @@ ENTRY(__ieee754_powf) jns 4f // y >= 0, jump fdivrl MO(one) // 1/x (now referred to as x) negl %edx -4: fldl MO(one) // 1 : x +4: fld1 // 1 : x fxch 6: shrl $1, %edx @@ -129,7 +140,7 @@ ENTRY(__ieee754_powf) /* y is ??NAN */ 30: flds 4(%esp) // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fucomp %st(1) // x : y fnstsw sahf @@ -141,7 +152,7 @@ ENTRY(__ieee754_powf) .align ALIGNARG(4) 2: /* y is a real number. */ fxch // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fld %st(1) // x : 1.0 : x : y fsub %st(1) // x-1 : 1.0 : x : y fabs // |x-1| : 1.0 : x : y @@ -171,7 +182,7 @@ ENTRY(__ieee754_powf) // pow(x,??0) = 1 .align ALIGNARG(4) 11: fstp %st(0) // pop y - fldl MO(one) + fld1 ret // y == ??inf @@ -195,7 +206,7 @@ ENTRY(__ieee754_powf) ret .align ALIGNARG(4) -14: fldl MO(one) +14: fld1 ret .align ALIGNARG(4) @@ -276,7 +287,7 @@ ENTRY(__ieee754_powf) jbe 27f // does not fit in mantissa bits // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) + fld1 fdivl MO(zero) fchs ret @@ -284,7 +295,7 @@ ENTRY(__ieee754_powf) 25: fstp %st(0) 26: addl $4, %esp 27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) + fld1 fdivl MO(zero) ret @@ -314,7 +325,7 @@ ENTRY(__ieee754_powf) 22: fstp %st(0) 23: addl $4, %esp // Don't use pop. -24: fldl MO(zero) +24: fldz ret END(__ieee754_powf) --- libc/sysdeps/i386/fpu/e_powl.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_powl.S 2004-07-15 12:56:07.678735978 +0200 @@ -1,5 +1,6 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +49,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +100,14 @@ ENTRY(__ieee754_powl) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p63) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -116,7 +128,7 @@ ENTRY(__ieee754_powl) negl %eax adcl $0, %edx negl %edx -4: fldl MO(one) // 1 : x +4: fld1 // 1 : x fxch 6: shrdl $1, %edx, %eax @@ -134,7 +146,7 @@ ENTRY(__ieee754_powl) /* y is ??NAN */ 30: fldt 4(%esp) // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fucomp %st(1) // x : y fnstsw sahf @@ -146,7 +158,7 @@ ENTRY(__ieee754_powl) .align ALIGNARG(4) 2: /* y is a real number. */ fxch // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fld %st(1) // x : 1.0 : x : y fsub %st(1) // x-1 : 1.0 : x : y fabs // |x-1| : 1.0 : x : y @@ -161,6 +173,11 @@ ENTRY(__ieee754_powl) 7: fyl2x // log2(x) : y 8: fmul %st(1) // y*log2(x) : y + fxam + fnstsw + andb $0x45, %ah + cmpb $0x05, %ah // is y*log2(x) == ??inf ? + je 28f fst %st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) @@ -172,11 +189,17 @@ ENTRY(__ieee754_powl) fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret +28: fstp %st(1) // y*log2(x) + fld1 // 1 : y*log2(x) + fscale // 2^(y*log2(x)) : y*log2(x) + addl $8, %esp + fstp %st(1) // 2^(y*log2(x)) + ret // pow(x,??0) = 1 .align ALIGNARG(4) 11: fstp %st(0) // pop y - fldl MO(one) + fld1 ret // y == ??inf @@ -200,7 +223,7 @@ ENTRY(__ieee754_powl) ret .align ALIGNARG(4) -14: fldl MO(one) +14: fld1 ret .align ALIGNARG(4) @@ -273,7 +296,7 @@ ENTRY(__ieee754_powl) jz 27f // jump if not odd // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) + fld1 fdivl MO(zero) fchs ret @@ -281,7 +304,7 @@ ENTRY(__ieee754_powl) 25: fstp %st(0) 26: addl $8, %esp 27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) + fld1 fdivl MO(zero) ret @@ -309,7 +332,7 @@ ENTRY(__ieee754_powl) 22: fstp %st(0) 23: addl $8, %esp // Don't use 2 x pop -24: fldl MO(zero) +24: fldz ret END(__ieee754_powl) --- libc/sysdeps/i386/fpu/e_pow.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_pow.S 2004-07-15 13:05:41.601640612 +0200 @@ -1,5 +1,6 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +49,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +100,14 @@ ENTRY(__ieee754_pow) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p63) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -116,7 +128,7 @@ ENTRY(__ieee754_pow) negl %eax adcl $0, %edx negl %edx -4: fldl MO(one) // 1 : x +4: fld1 // 1 : x fxch 6: shrdl $1, %edx, %eax @@ -134,7 +146,7 @@ ENTRY(__ieee754_pow) /* y is ??NAN */ 30: fldl 4(%esp) // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fucomp %st(1) // x : y fnstsw sahf @@ -146,7 +158,7 @@ ENTRY(__ieee754_pow) .align ALIGNARG(4) 2: /* y is a real number. */ fxch // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fld %st(1) // x : 1.0 : x : y fsub %st(1) // x-1 : 1.0 : x : y fabs // |x-1| : 1.0 : x : y @@ -176,7 +188,7 @@ ENTRY(__ieee754_pow) // pow(x,??0) = 1 .align ALIGNARG(4) 11: fstp %st(0) // pop y - fldl MO(one) + fld1 ret // y == ??inf @@ -200,7 +212,7 @@ ENTRY(__ieee754_pow) ret .align ALIGNARG(4) -14: fldl MO(one) +14: fld1 ret .align ALIGNARG(4) @@ -283,7 +295,7 @@ ENTRY(__ieee754_pow) jbe 27f // does not fit in mantissa bits // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) + fld1 fdivl MO(zero) fchs ret @@ -291,7 +303,7 @@ ENTRY(__ieee754_pow) 25: fstp %st(0) 26: addl $8, %esp 27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) + fld1 fdivl MO(zero) ret @@ -322,7 +334,7 @@ ENTRY(__ieee754_pow) 22: fstp %st(0) 23: addl $8, %esp // Don't use 2 x pop -24: fldl MO(zero) +24: fldz ret END(__ieee754_pow) --- libc/sysdeps/x86_64/fpu/e_powl.S.jj 2001-09-19 12:24:08.000000000 +0200 +++ libc/sysdeps/x86_64/fpu/e_powl.S 2004-07-14 20:02:06.000000000 +0200 @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +48,10 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: + .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##(%rip) @@ -87,6 +91,14 @@ ENTRY(__ieee754_powl) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fldl MO(p63) // 1L<<63 : y : x + fld %st(1) // y : 1L<<63 : y : x + fabs // |y| : 1L<<63 : y : x + fcomip %st(1), %st // 1L<<63 : y : x + fstp %st(0) // y : x + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -105,7 +117,7 @@ ENTRY(__ieee754_powl) negl %eax adcl $0, %edx negl %edx -4: fldl MO(one) // 1 : x +4: fld1 // 1 : x fxch 6: shrdl $1, %edx, %eax @@ -123,7 +135,7 @@ ENTRY(__ieee754_powl) /* y is ??NAN */ 30: fldt 8(%rsp) // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fucomip %st(1),%st // x : y je 31f fxch // y : x @@ -133,7 +145,7 @@ ENTRY(__ieee754_powl) .align ALIGNARG(4) 2: /* y is a real number. */ fxch // x : y - fldl MO(one) // 1.0 : x : y + fld1 // 1.0 : x : y fld %st(1) // x : 1.0 : x : y fsub %st(1) // x-1 : 1.0 : x : y fabs // |x-1| : 1.0 : x : y @@ -148,6 +160,11 @@ ENTRY(__ieee754_powl) 7: fyl2x // log2(x) : y 8: fmul %st(1) // y*log2(x) : y + fxam + fnstsw + andb $0x45, %ah + cmpb $0x05, %ah // is y*log2(x) == ??inf ? + je 28f fst %st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) @@ -158,11 +175,16 @@ ENTRY(__ieee754_powl) fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret +28: fstp %st(1) // y*log2(x) + fld1 // 1 : y*log2(x) + fscale // 2^(y*log2(x)) : y*log2(x) + fstp %st(1) // 2^(y*log2(x)) + ret // pow(x,??0) = 1 .align ALIGNARG(4) 11: fstp %st(0) // pop y - fldl MO(one) + fld1 ret // y == ??inf @@ -191,7 +213,7 @@ ENTRY(__ieee754_powl) ret .align ALIGNARG(4) -14: fldl MO(one) +14: fld1 ret .align ALIGNARG(4) @@ -275,7 +297,7 @@ ENTRY(__ieee754_powl) jz 27f // jump if not odd // It's an odd integer. // Raise divide-by-zero exception and get minus infinity value. - fldl MO(one) + fld1 fdivl MO(zero) fchs ret @@ -283,7 +305,7 @@ ENTRY(__ieee754_powl) 25: fstp %st(0) 26: 27: // Raise divide-by-zero exception and get infinity value. - fldl MO(one) + fld1 fdivl MO(zero) ret @@ -310,7 +332,7 @@ ENTRY(__ieee754_powl) 22: fstp %st(0) 23: -24: fldl MO(zero) +24: fldz ret END(__ieee754_powl) Jakub From jakub@redhat.com Thu Jul 15 12:48:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 15 Jul 2004 12:48:00 -0000 Subject: [PATCH] Allow main to come from a shared library for PIE [BZ #262] Message-ID: <20040715103304.GA30497@sunsite.ms.mff.cuni.cz> Hi! 2004-07-15 Jakub Jelinek [BZ #262] * sysdeps/i386/elf/start.S (_start): Use @GOT instead of @GOTOFF for main. Patch by Solar Designer . * elf/Makefile: Add rules to build and run tst-pie1. * elf/tst-pie1.c: New test. * elf/tst-piemod1.c: New file. --- libc/sysdeps/i386/elf/start.S.jj 2004-07-15 14:41:46.000000000 +0200 +++ libc/sysdeps/i386/elf/start.S 2004-07-15 14:42:37.000000000 +0200 @@ -1,5 +1,6 @@ /* Startup code compliant to the ELF i386 ABI. - Copyright (C) 1995-1998,2000,2001,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004 + 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 @@ -81,8 +82,7 @@ _start: pushl %ecx /* Push second argument: argv. */ pushl %esi /* Push first argument: argc. */ - leal BP_SYM (main)@GOTOFF(%ebx), %eax - pushl %eax + pushl BP_SYM (main)@GOT(%ebx) /* Call the user's main function, and exit with its value. But let the libc call main. */ --- libc/elf/tst-pie1.c.jj 2004-07-15 14:37:41.000000000 +0200 +++ libc/elf/tst-pie1.c 2004-07-15 14:37:41.000000000 +0200 @@ -0,0 +1,5 @@ +int +foo (void) +{ + return 34; +} --- libc/elf/Makefile.jj 2004-06-17 17:08:46.000000000 +0200 +++ libc/elf/Makefile 2004-07-15 14:47:43.000000000 +0200 @@ -80,7 +80,7 @@ distribute := rtld-Rules \ nodel2mod1.c nodel2mod2.c nodel2mod3.c \ reldep9.c reldep9mod1.c reldep9mod2.c reldep9mod3.c \ tst-array1.exp tst-array2.exp tst-array4.exp \ - tst-array2dep.c \ + tst-array2dep.c tst-piemod1.c \ tst-execstack-mod.c tst-dlmodcount.c \ check-textrel.c dl-sysdep.h @@ -160,6 +160,9 @@ tests-nodelete-yes = nodelete nodelete2 tests-nodlopen-yes = nodlopen nodlopen2 tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog endif +ifeq (yesyes,$(have-fpie)$(build-shared)) +tests: $(objpfx)tst-pie1.out +endif modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ testobj1_1 failobj constload2 constload3 unloadmod \ dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \ @@ -185,6 +188,9 @@ modules-names = testobj1 testobj2 testob ifeq (yes,$(have-initfini-array)) modules-names += tst-array2dep endif +ifeq (yesyes,$(have-fpie)$(build-shared)) +modules-names += tst-piemod1 +endif modules-vis-yes = vismod1 vismod2 vismod3 modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \ nodel2mod1 nodel2mod2 nodel2mod3 @@ -705,6 +711,25 @@ $(objpfx)tst-array4.out: $(objpfx)tst-ar $< > $@ cmp $@ tst-array4.exp > /dev/null +ifeq (yesyes,$(have-fpie)$(build-shared)) +CFLAGS-tst-pie1.c += -fpie + +$(objpfx)tst-pie1.out: $(objpfx)tst-pie1 + $(elf-objpfx)$(rtld-installed-name) \ + --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \ + $< > $@ + +$(objpfx)tst-pie1: $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so + $(LINK.o) -pie -Wl,-O1 \ + $(sysdep-LDFLAGS) $(config-LDFLAGS) \ + $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \ + $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \ + $(LDFLAGS) $(LDFLAGS-$(@F)) \ + -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \ + -o $@ $(objpfx)tst-pie1.o $(objpfx)tst-piemod1.so \ + $(common-objpfx)libc_nonshared.a +endif + check-textrel-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE $(objpfx)check-textrel: check-textrel.c $(native-compile) --- libc/elf/tst-piemod1.c.jj 2004-07-15 14:37:41.000000000 +0200 +++ libc/elf/tst-piemod1.c 2004-07-15 14:37:41.000000000 +0200 @@ -0,0 +1,20 @@ +#include + +int +foo (void) +{ + return 21; +} + +int +main (void) +{ + int val = foo (); + if (val != 34) + { + printf ("foo () returned %d\n", val); + return 1; + } + + return 0; +} Jakub From roland@redhat.com Thu Jul 15 22:02:00 2004 From: roland@redhat.com (Roland McGrath) Date: Thu, 15 Jul 2004 22:02:00 -0000 Subject: [PATCH] Allow main to come from a shared library for PIE [BZ #262] In-Reply-To: Jakub Jelinek's message of Thursday, 15 July 2004 12:33:04 +0200 <20040715103304.GA30497@sunsite.ms.mff.cuni.cz> Message-ID: <200407152202.i6FM2jKk020602@magilla.sf.frob.com> > +ifeq (yesyes,$(have-fpie)$(build-shared)) > +tests: $(objpfx)tst-pie1.out > +endif This should be tests += tst-pie1. From jakub@redhat.com Thu Jul 15 22:05:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 15 Jul 2004 22:05:00 -0000 Subject: [PATCH] Allow main to come from a shared library for PIE [BZ #262] In-Reply-To: <200407152202.i6FM2jKk020602@magilla.sf.frob.com> References: <20040715103304.GA30497@sunsite.ms.mff.cuni.cz> <200407152202.i6FM2jKk020602@magilla.sf.frob.com> Message-ID: <20040715194924.GE30497@sunsite.ms.mff.cuni.cz> On Thu, Jul 15, 2004 at 03:02:45PM -0700, Roland McGrath wrote: > > +ifeq (yesyes,$(have-fpie)$(build-shared)) > > +tests: $(objpfx)tst-pie1.out > > +endif > > This should be tests += tst-pie1. No, when it is tests += tst-pie1, the elf/Makefile $(objpfx)/tst-pie1 rule is overriding the default one. I used tests += tst-pie1 initially but changed it afterwards. Maybe if we have more PIE tests in the future the Makefiles could have some common rule how to build them, but for one test I think what the patch does is enough. Jakub From jakub@redhat.com Fri Jul 16 14:32:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 16 Jul 2004 14:32:00 -0000 Subject: [PATCH] Fix locking issue in newlocale In-Reply-To: <40F79EAB.1060107@suse.de> References: <40F79EAB.1060107@suse.de> Message-ID: <20040716121639.GJ30497@sunsite.ms.mff.cuni.cz> On Fri, Jul 16, 2004 at 11:23:55AM +0200, Paolo Carlini wrote: > > And in fact, in one crash I have analysed, it looks as if glibc-internal > > data structures are corrupted. Indeed, you're right. I have been able to reproduce this with on 4way x86-64: #define _GNU_SOURCE #include #include const char *locales[] = { "de_DE.ISO-8859-1", "en_US.ISO-8859-1" }; void * tf (void *arg) { int i; for (i = 0; i < 100000; ++i) { locale_t l = newlocale (LC_ALL_MASK, locales[i & 1], NULL); freelocale (l); } } void * tf2 (void *arg) { int i; for (i = 0; i < 100000; ++i) setlocale (LC_ALL, locales[(i % 27) & 1]); } int main (void) { pthread_t p[10]; int i; for (i = 0; i < 10; ++i) pthread_create (&p[i], NULL, i % 2 ? tf : tf2, NULL); for (i = 0; i < 10; ++i) pthread_join (p[i], NULL); return 0; } (not every time, but with while /tmp/test; do :; done it always crashed after a while). With the patch below it doesn't crash (at least for the 15 minutes I was running this test before stopping it). duplocale/freelocale already use this lock. 2004-07-16 Jakub Jelinek * locale/newlocale.c: Include bits/libc-lock.h. (__libc_setlocale_lock): Extern decl. (__newlocale): Use it. Reported by Ulrich Weigand . --- libc/locale/newlocale.c.jj 2004-07-16 09:33:23.000000000 -0400 +++ libc/locale/newlocale.c 2004-07-16 09:44:33.000000000 -0400 @@ -1,5 +1,6 @@ /* Return a reference to locale information record. - Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -19,6 +20,7 @@ 02111-1307 USA. */ #include +#include #include #include #include @@ -27,6 +29,10 @@ #include "localeinfo.h" +/* Lock for protecting global data. */ +__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden) + + /* Use this when we come along an error. */ #define ERROR_RETURN \ do { \ @@ -154,6 +160,9 @@ __newlocale (int category_mask, const ch ERROR_RETURN; } + /* Protect global data. */ + __libc_lock_lock (__libc_setlocale_lock); + /* Now process all categories we are interested in. */ names_len = 0; for (cnt = 0; cnt < __LC_LAST; ++cnt) @@ -171,6 +180,9 @@ __newlocale (int category_mask, const ch && result.__locales[cnt]->usage_count != UNDELETABLE) /* We can remove the data. */ _nl_remove_locale (cnt, result.__locales[cnt]); + + /* Critical section left. */ + __libc_lock_unlock (__libc_setlocale_lock); return NULL; } @@ -249,6 +261,9 @@ __newlocale (int category_mask, const ch free (base); } + /* Critical section left. */ + __libc_lock_unlock (__libc_setlocale_lock); + /* Update the special members. */ update: { Jakub From drepper@redhat.com Fri Jul 16 17:09:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 16 Jul 2004 17:09:00 -0000 Subject: [PATCH] Fix powl on i386/x86_64 [BZ #258] (take 2) In-Reply-To: <20040715093555.GA9816@sunsite.ms.mff.cuni.cz> References: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> <20040715093555.GA9816@sunsite.ms.mff.cuni.cz> Message-ID: <40F80B44.9020305@redhat.com> Jakub Jelinek wrote: > -4: fldl MO(one) // 1 : x > +4: fld1 // 1 : x I deliberately avoided the use of fld1 since all my measurements showed it is slower. Please some some measurements of your own. As far as I remember the only time when it paid off to use fld1 is when the fld was the only memory operation and therefore it could be avoided to load the PIC register. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From pere@hungry.com Sat Jul 17 07:42:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Sat, 17 Jul 2004 07:42:00 -0000 Subject: [PATCH] New charmap alias WINDOWS-874 for IBM874 [BZ #244] Message-ID: Here is a fix for bug #244. The request look sane to me, and I used a name with capital letters to match the names/aliases of GBK, SAMI-WS2 and WINDOWS-31J. 2004-07-17 Petter Reinholdtsen * charmaps/IBM874: Make new alias WINDOWS-874 for IBM874. The charset name is widely used in Thailand, according to James Clark. The charset specification for WINDOWS-874 is available from . [BZ #244] Index: localedata/charmaps/IBM874 =================================================================== RCS file: /cvs/glibc/libc/localedata/charmaps/IBM874,v retrieving revision 1.7 diff -u -3 -p -u -r1.7 IBM874 --- localedata/charmaps/IBM874 24 Jun 2000 05:32:51 -0000 1.7 +++ localedata/charmaps/IBM874 17 Jul 2004 07:29:05 -0000 @@ -4,6 +4,7 @@ % automatically generated from the charDB % alias CP874 +% alias WINDOWS-874 CHARMAP /x00 NULL /x01 START OF HEADING From pere@hungry.com Sun Jul 18 07:47:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Sun, 18 Jul 2004 07:47:00 -0000 Subject: [PATCH] Test sorting order for tr_TR Message-ID: I got a sorting order test from the tr_TR author. Please include in CVS. There is the changelog entry for localedata/ChangeLog: I hope the UTF-8 encoded file survived this email. 2004-07-17 Petter Reinholdtsen * Makefile (test-input): Add tr_TR.UTF-8 sorting test. Test case for BZ #19. * tr_TR.in: New file Index: localedata/Makefile =================================================================== RCS file: /cvs/glibc/libc/localedata/Makefile,v retrieving revision 1.100 diff -u -3 -p -u -r1.100 localedata/Makefile --- localedata/Makefile 20 Nov 2003 23:31:38 -0000 1.100 +++ localedata/Makefile 17 Jul 2004 10:52:32 -0000 @@ -41,7 +41,7 @@ test-srcs := collate-test xfrm-test tst- tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \ tst-ctype tst-wctype tst-langinfo tst-numeric test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 da_DK.ISO-8859-1 \ - hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 + hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 tr_TR.UTF-8 test-input-data = $(addsuffix .in, $(basename $(test-input))) test-output := $(foreach s, .out .xout, \ $(addsuffix $s, $(basename $(test-input)))) Index: localedata/Makefile =================================================================== diff -u -3 -p -u -r1.100 localedata/tr_TR.in --- localedata/tr_TR.in Thu Jan 1 01:00:00 1970 +++ localedata/tr_TR.in Sat Jul 17 12:45:29 2004 @@ -0,0 +1,126 @@ +A +a +?? +??? +alem +???lem +Amasya +ana +an??? +bakkal +bardak +Bolu +Ceyhan +cuma +cumhur +?? +??? +??ank???r??? +???ok +???orba +deniz +derin +Diyarbak???r +Edirne +ezel +eziyet +Fatsa +fincan +firavun +gan??? +gaz +G???m?????hane +?? +?? +hala +h???l??? +havlu +Havza +I +??? +I??d???r +???slak +???spanak +??? +i +?? +??? +iml??? +imza +???stanbul +jale +jandarma +Japonya +k????????t +K???r???kkale +kimlik +kiraz +l???le +limon +lira +L???leburgaz +Mardin +mesih +mes???h +meskup +mesk???p +m???h???r +m???stesna +neden +nezle +Ni??de +ok???u +Okta?? +okul +Ordu +?? +??? +??demi?? +???rdek +???rnek +p???rasa +p???rlanta +Plevne +quantum +Quebec +Recai +Rize +r???ya +r???zgar +Samsun +sel???m +s???p???rge +s???rahi +?? +?? +??emsiye +??erbet +??erefliko???hisar +t???mar +t???rnak +Trabzon +U +u +?? +??? +Urfa +uygar +uyluk +?? +??? +??sk???dar +???zg???n +???z???m +Van +vil???yet +virane +wall +Washington +xanadu +Xman +ya??mur +yar +Yozgat +zehir +zeki +Zonguldak From jakub@redhat.com Mon Jul 19 10:19:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 19 Jul 2004 10:19:00 -0000 Subject: [PATCH] Fix powl on i386/x86_64 [BZ #258] (take 2) In-Reply-To: <40F80B44.9020305@redhat.com> References: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> <20040715093555.GA9816@sunsite.ms.mff.cuni.cz> <40F80B44.9020305@redhat.com> Message-ID: <20040719080353.GL30497@sunsite.ms.mff.cuni.cz> On Fri, Jul 16, 2004 at 10:07:16AM -0700, Ulrich Drepper wrote: > Jakub Jelinek wrote: > > > -4: fldl MO(one) // 1 : x > > +4: fld1 // 1 : x > > I deliberately avoided the use of fld1 since all my measurements showed > it is slower. Please some some measurements of your own. As far as I > remember the only time when it paid off to use fld1 is when the fld was > the only memory operation and therefore it could be avoided to load the > PIC register. If there are no other memory references, it is surely noticeably faster, otherwise I see it the same speed (but the instruction is shorter). With following proglet I get 10 cycles in both cases on Opteron, 42 on P3, 92 on P4. AFAIK GCC uses fld1 and fldz in the code it generates in all cases. #include #include extern long double foo1 (void); extern long double foo2 (void); asm (".balign 16; foo1: .section .rodata; .balign 16; mzero: .byte 0, 0, 0, 0, 0, 0, 0, 0x80; .previous; fldz; faddl mzero; fxam; fnstsw; ret;"); asm (".balign 16; foo2: .section .rodata; .balign 16; zero: .double 0.0; .previous; fldl zero; faddl mzero; fxam; fnstsw; ret;"); int main (void) { unsigned long long st, en, m; int i; m = -1ULL; for (i = 0; i < 1000; ++i) { asm volatile ("rdtsc" : "=A" (st)); foo1 (); asm volatile ("rdtsc" : "=A" (en)); en -= st; if (en < m) m = en; } printf ("%lld\n", m); m = -1ULL; for (i = 0; i < 1000; ++i) { asm volatile ("rdtsc" : "=A" (st)); foo2 (); asm volatile ("rdtsc" : "=A" (en)); en -= st; if (en < m) m = en; } printf ("%lld\n", m); return 0; } Anyway, below is a patch variant without fldz and fld1, those changes weren't fixing anything and thus can be a separate change which can be argued about independently. 2004-07-19 Jakub Jelinek [BZ #258] * math/libm-test.inc (max_value, min_value): New variables. (initialize): Initialize them. (pow_test): Add a couple of new tests. * sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Don't generate invalid exception if |y| >= 1U<<31. * sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Don't generate invalid exception if |y| >= 1L<<63. * sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise. If y*log2(x) overflows to +-inf, return still +inf/+0 instead of NaN. * sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Likewise. --- libc/math/libm-test.inc.jj 2004-02-13 12:28:07.000000000 +0100 +++ libc/math/libm-test.inc 2004-07-15 12:34:17.395663150 +0200 @@ -169,7 +169,7 @@ static int output_points; /* Should the static int ignore_max_ulp; /* Should we ignore max_ulp? */ static FLOAT minus_zero, plus_zero; -static FLOAT plus_infty, minus_infty, nan_value; +static FLOAT plus_infty, minus_infty, nan_value, max_value, min_value; static FLOAT max_error, real_max_error, imag_max_error; @@ -3593,6 +3593,28 @@ pow_test (void) TEST_ff_f (pow, -1, plus_infty, 1); TEST_ff_f (pow, 1, minus_infty, 1); TEST_ff_f (pow, -1, minus_infty, 1); + TEST_ff_f (pow, 1, 1, 1); + TEST_ff_f (pow, 1, -1, 1); + TEST_ff_f (pow, 1, 1.25, 1); + TEST_ff_f (pow, 1, -1.25, 1); + TEST_ff_f (pow, 1, 0x1p62L, 1); + TEST_ff_f (pow, 1, 0x1p63L, 1); + TEST_ff_f (pow, 1, 0x1p64L, 1); + TEST_ff_f (pow, 1, 0x1p72L, 1); + + /* pow (x, +-0) == 1. */ + TEST_ff_f (pow, plus_infty, 0, 1); + TEST_ff_f (pow, plus_infty, minus_zero, 1); + TEST_ff_f (pow, minus_infty, 0, 1); + TEST_ff_f (pow, minus_infty, minus_zero, 1); + TEST_ff_f (pow, 32.75L, 0, 1); + TEST_ff_f (pow, 32.75L, minus_zero, 1); + TEST_ff_f (pow, -32.75L, 0, 1); + TEST_ff_f (pow, -32.75L, minus_zero, 1); + TEST_ff_f (pow, 0x1p72L, 0, 1); + TEST_ff_f (pow, 0x1p72L, minus_zero, 1); + TEST_ff_f (pow, 0x1p-72L, 0, 1); + TEST_ff_f (pow, 0x1p-72L, minus_zero, 1); TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION); TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION); @@ -3609,6 +3631,10 @@ pow_test (void) TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION); + TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty); + TEST_ff_f (pow, 10, -0x1p72L, 0); + TEST_ff_f (pow, max_value, max_value, plus_infty); + TEST_ff_f (pow, 10, -max_value, 0); TEST_ff_f (pow, 0, 1, 0); TEST_ff_f (pow, 0, 11, 0); @@ -3623,6 +3649,8 @@ pow_test (void) TEST_ff_f (pow, minus_zero, 2, 0); TEST_ff_f (pow, minus_zero, 11.1L, 0); + TEST_ff_f (pow, 0, plus_infty, 0); + TEST_ff_f (pow, minus_zero, plus_infty, 0); #ifndef TEST_INLINE /* pow (x, +inf) == +inf for |x| > 1. */ @@ -3667,6 +3695,11 @@ pow_test (void) /* pow (-0, y) == +0 for y > 0 and not an odd integer. */ TEST_ff_f (pow, minus_zero, 4, 0.0); + TEST_ff_f (pow, 16, 0.25L, 2); + TEST_ff_f (pow, 0x1p64L, 0.125L, 256); + TEST_ff_f (pow, 2, 4, 16); + TEST_ff_f (pow, 256, 8, 0x1p64L); + TEST_ff_f (pow, 0.75L, 1.25L, 0.697953644326574699205914060237425566L); #if defined TEST_DOUBLE || defined TEST_LDOUBLE @@ -4312,12 +4345,18 @@ initialize (void) HUGE_VALL, HUGE_VAL, HUGE_VALF); minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF, -HUGE_VALL, -HUGE_VAL, -HUGE_VALF); + max_value = CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX, + LDBL_MAX, DBL_MAX, FLT_MAX); + min_value = CHOOSE (LDBL_MIN, DBL_MIN, FLT_MIN, + LDBL_MIN, DBL_MIN, FLT_MIN); (void) &plus_zero; (void) &nan_value; (void) &minus_zero; (void) &plus_infty; (void) &minus_infty; + (void) &max_value; + (void) &min_value; /* Clear all exceptions. From now on we must not get random exceptions. */ feclearexcept (FE_ALL_EXCEPT); --- libc/sysdeps/i386/fpu/e_powf.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_powf.S 2004-07-15 13:23:15.977438871 +0200 @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1999, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +48,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p31,@object) +p31: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x41 + ASM_SIZE_DIRECTIVE(p31) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +99,14 @@ ENTRY(__ieee754_powf) fxch // y : x + /* fistpl raises invalid exception for |y| >= 1L<<31. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p31) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x --- libc/sysdeps/i386/fpu/e_powl.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_powl.S 2004-07-15 12:56:07.678735978 +0200 @@ -1,5 +1,6 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +49,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +100,14 @@ ENTRY(__ieee754_powl) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p63) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -161,6 +173,11 @@ ENTRY(__ieee754_powl) 7: fyl2x // log2(x) : y 8: fmul %st(1) // y*log2(x) : y + fxam + fnstsw + andb $0x45, %ah + cmpb $0x05, %ah // is y*log2(x) == ??inf ? + je 28f fst %st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) @@ -172,6 +189,12 @@ ENTRY(__ieee754_powl) fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret +28: fstp %st(1) // y*log2(x) + fldl MO(one) // 1 : y*log2(x) + fscale // 2^(y*log2(x)) : y*log2(x) + addl $8, %esp + fstp %st(1) // 2^(y*log2(x)) + ret // pow(x,??0) = 1 .align ALIGNARG(4) --- libc/sysdeps/i386/fpu/e_pow.S.jj 2001-07-06 06:55:53.000000000 +0200 +++ libc/sysdeps/i386/fpu/e_pow.S 2004-07-15 13:05:41.601640612 +0200 @@ -1,5 +1,6 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +49,9 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) @@ -96,6 +100,14 @@ ENTRY(__ieee754_pow) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fld %st // y : y : x + fabs // |y| : y : x + fcompl MO(p63) // y : x + fnstsw + sahf + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x --- libc/sysdeps/x86_64/fpu/e_powl.S.jj 2001-09-19 12:24:08.000000000 +0200 +++ libc/sysdeps/x86_64/fpu/e_powl.S 2004-07-14 20:02:06.000000000 +0200 @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -48,6 +48,10 @@ one: .double 1.0 ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(p63,@object) +p63: + .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43 + ASM_SIZE_DIRECTIVE(p63) #ifdef PIC #define MO(op) op##(%rip) @@ -87,6 +91,14 @@ ENTRY(__ieee754_powl) fxch // y : x + /* fistpll raises invalid exception for |y| >= 1L<<63. */ + fldl MO(p63) // 1L<<63 : y : x + fld %st(1) // y : 1L<<63 : y : x + fabs // |y| : 1L<<63 : y : x + fcomip %st(1), %st // 1L<<63 : y : x + fstp %st(0) // y : x + jnc 2f + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -148,6 +160,11 @@ ENTRY(__ieee754_powl) 7: fyl2x // log2(x) : y 8: fmul %st(1) // y*log2(x) : y + fxam + fnstsw + andb $0x45, %ah + cmpb $0x05, %ah // is y*log2(x) == ??inf ? + je 28f fst %st(1) // y*log2(x) : y*log2(x) frndint // int(y*log2(x)) : y*log2(x) fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x)) @@ -158,6 +175,11 @@ ENTRY(__ieee754_powl) fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret +28: fstp %st(1) // y*log2(x) + fldl MO(one) // 1 : y*log2(x) + fscale // 2^(y*log2(x)) : y*log2(x) + fstp %st(1) // 2^(y*log2(x)) + ret // pow(x,??0) = 1 .align ALIGNARG(4) Jakub From drepper@redhat.com Tue Jul 20 07:07:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 20 Jul 2004 07:07:00 -0000 Subject: [PATCH] Fix powl on i386/x86_64 [BZ #258] (take 2) In-Reply-To: <20040719080353.GL30497@sunsite.ms.mff.cuni.cz> References: <20040714160203.GQ5191@sunsite.ms.mff.cuni.cz> <20040715093555.GA9816@sunsite.ms.mff.cuni.cz> <40F80B44.9020305@redhat.com> <20040719080353.GL30497@sunsite.ms.mff.cuni.cz> Message-ID: <40FCC457.1010702@redhat.com> Applied. And it might very well be that fld1 nowadays is as fast as the memory load. When I wrote the code I used an i386+i387. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Tue Jul 20 07:18:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 20 Jul 2004 07:18:00 -0000 Subject: [PATCH] New charmap alias WINDOWS-874 for IBM874 [BZ #244] In-Reply-To: References: Message-ID: <40FCC6C8.7000307@redhat.com> This patch doesn't really do anything. The entry need to be added to the gconv.modules files. I've done that now. This cosmetic change is added, too. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From pere@hungry.com Tue Jul 20 07:34:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Tue, 20 Jul 2004 07:34:00 -0000 Subject: [PATCH] New charmap alias WINDOWS-874 for IBM874 [BZ #244] In-Reply-To: <40FCC6C8.7000307@redhat.com> References: <40FCC6C8.7000307@redhat.com> Message-ID: <20040720072656.GF27305@saruman.uio.no> [Ulrich Drepper] > This patch doesn't really do anything. The entry need to be added > to the gconv.modules files. I've done that now. This cosmetic > change is added, too. Aha. I was woundering where the charmap file comment was being used, but failed to find any. Thanks for correcting it. I've closed the bugzilla report now. From jakub@redhat.com Tue Jul 20 22:17:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 20 Jul 2004 22:17:00 -0000 Subject: [PATCH] Fix strtold on 32-bit arches with ldbl-96 [BZ #274] Message-ID: <20040720200152.GO30497@sunsite.ms.mff.cuni.cz> Hi! This hunk is supposed to shift retval up by used bits where used >= BITS_PER_MP_LIMB, but it clears also the lowest limb already containing result of mpn_lshift. 2004-07-21 Jakub Jelinek [BZ #274] * stdlib/strtod_l.c (INTERNAL (__STRTOF)): Fix used >= BITS_PER_MP_LIMB shifting up. * stdlib/tst-strtod.c (main): Add new tests. --- libc/stdlib/strtod_l.c.jj 2004-07-12 20:47:47.000000000 +0200 +++ libc/stdlib/strtod_l.c 2004-07-20 23:49:29.456044788 +0200 @@ -1488,7 +1488,7 @@ / BITS_PER_MP_LIMB], retval, RETURN_LIMB_SIZE, used % BITS_PER_MP_LIMB); - for (i = used / BITS_PER_MP_LIMB; i >= 0; --i) + for (i = used / BITS_PER_MP_LIMB - 1; i >= 0; --i) retval[i] = 0; } else if (used > 0) --- libc/stdlib/tst-strtod.c.jj 2003-06-27 13:08:48.000000000 +0200 +++ libc/stdlib/tst-strtod.c 2004-07-21 00:02:05.378630841 +0200 @@ -157,6 +157,21 @@ main (int argc, char ** argv) status = 1; } + static struct { const char *str; long double l; } ltests[] = + { + { "42.0000000000000000001", 42.0000000000000000001L }, + { "42.00000000000000000001", 42.00000000000000000001L }, + { "42.000000000000000000001", 42.000000000000000000001L } + }; + int n; + for (n = 0; n < sizeof (ltests) / sizeof (ltests[0]); ++n) + if (strtold (ltests[n].str, NULL) != ltests[n].l) + { + printf ("ltests[%d]: %La != %La\n", n, + strtold (ltests[n].str, NULL), ltests[n].l); + status = 1; + } + status |= long_dbl (); status |= locale_test (); Jakub From jakub@redhat.com Wed Jul 21 17:39:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 21 Jul 2004 17:39:00 -0000 Subject: [PATCH] Avoid leaks in res_init Message-ID: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> Hi! #include #include #include int main (void) { int i; mtrace (); for (i = 0; i < 50; ++i) { res_init (); gethostbyname ("www.google.com"); } } leaks memory and if IPv6 is enabled also filehandles. I have googled around but could not find a word about whether res_init can or can't be called multiple times, but certainly we need such an interface e.g. for nscd to reread resolv.conf during nscd -i hosts. 2004-07-21 Jakub Jelinek * resolv/res_libc.c (res_init): If RES_INIT is set and _res.nscount > 0, call __res_nclose and free nsaddrs. --- libc/resolv/res_libc.c.jj 2003-07-23 09:56:18.000000000 +0200 +++ libc/resolv/res_libc.c 2004-07-21 19:25:05.419402346 +0200 @@ -54,6 +54,14 @@ res_init(void) { _res.retry = 4; if (!(_res.options & RES_INIT)) _res.options = RES_DEFAULT; + else if (_res.nscount > 0) { + __res_nclose (&_res); /* Close any VC sockets. */ + + for (int ns = 0; ns < MAXNS; ns++) { + free (_res._u._ext.nsaddrs[ns]); + _res._u._ext.nsaddrs[ns] = NULL; + } + } /* * This one used to initialize implicitly to zero, so unless the app Jakub From jakub@redhat.com Wed Jul 21 18:07:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 21 Jul 2004 18:07:00 -0000 Subject: [PATCH] tst-leaks2 In-Reply-To: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> References: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> Message-ID: <20040721155123.GR30497@sunsite.ms.mff.cuni.cz> On Wed, Jul 21, 2004 at 05:23:24PM +0200, Jakub Jelinek wrote: > leaks memory and if IPv6 is enabled also filehandles. Here is a testcase for make xcheck: 2004-07-21 Jakub Jelinek * resolv/Makefile: Add rules to build and run tst-leaks2. * resolv/tst-leaks2.c: New test. --- libc/resolv/Makefile.jj 2004-01-12 10:52:38.000000000 +0100 +++ libc/resolv/Makefile 2004-07-21 20:00:47.727921163 +0200 @@ -33,8 +33,9 @@ routines := herror inet_addr inet_ntop i res_hconf res_libc res-state tests = tst-aton tst-leaks +xtests = tst-leaks2 -generate := mtrace-tst-leaks tst-leaks.mtrace +generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace include ../Makeconfig @@ -65,7 +66,8 @@ ifeq (yesyes,$(build-shared)$(have-threa tests: $(objpfx)ga_test endif -generated := mtrace-tst-leaks tst-leaks.mtrace +generated := mtrace-tst-leaks tst-leaks.mtrace \ + mtrace-tst-leaks2 tst-leaks2.mtrace include ../Rules @@ -104,3 +106,12 @@ ifneq (no,$(PERL)) tests: $(objpfx)mtrace-tst-leaks endif endif + +tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace +$(objpfx)mtrace-tst-leaks2: $(objpfx)tst-leaks2.out + $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@ +ifeq (no,$(cross-compiling)) +ifneq (no,$(PERL)) +xtests: $(objpfx)mtrace-tst-leaks2 +endif +endif --- libc/resolv/tst-leaks2.c.jj 2004-07-21 19:55:46.287620269 +0200 +++ libc/resolv/tst-leaks2.c 2004-07-21 20:03:47.549480733 +0200 @@ -0,0 +1,42 @@ +/* Tests for res_init in libresolv + Copyright (C) 2004 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. */ + +#undef gethostbyname + +#include +#include +#include + +/* Prototype for our test function. */ +extern int do_test (int argc, char *argv[]); + +/* This defines the `main' function and some more. */ +#include + +int +do_test (int argc, char *argv[]) +{ + mtrace (); + for (int i = 0; i < 20; ++i) + { + res_init (); + gethostbyname ("www.gnu.org"); + } + return 0; +} Jakub From drepper@redhat.com Wed Jul 21 18:31:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 21 Jul 2004 18:31:00 -0000 Subject: [PATCH] Avoid leaks in res_init In-Reply-To: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> References: <20040721152324.GQ30497@sunsite.ms.mff.cuni.cz> Message-ID: <40FEB5BB.107@redhat.com> Applied, along with the test. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From pere@hungry.com Fri Jul 23 14:33:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Fri, 23 Jul 2004 14:33:00 -0000 Subject: [PATCH] Change month names for kr_KO [BZ #25] In-Reply-To: (Petter Reinholdtsen's message of "Wed, 14 Jul 2004 23:03:13 +0200") References: Message-ID: <2flhdrylro1.fsf@saruman.uio.no> [Petter Reinholdtsen] > Here is a patch to change the month names for the korean locale. I've > tried to get hold of the original locale author and the last person > submitting patches for this locale, without any luck. The original author have just added a comment to Bugzilla, confirming this change. Please apply it to CVS. From jakub@redhat.com Fri Jul 23 14:57:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 23 Jul 2004 14:57:00 -0000 Subject: [PATCH] Make popen return byte-oriented stream [BZ #282] Message-ID: <20040723124104.GW30497@sunsite.ms.mff.cuni.cz> Hi! http://www.opengroup.org/onlinepubs/009695399/functions/popen.html has: Pipe streams are byte-oriented. and Issue 5 A statement is added to the DESCRIPTION indicating that pipe streams are byte-oriented. 2004-07-23 Jakub Jelinek [BZ #282] * libio/iopopen.c (_IO_new_popen): Use _IO_init instead of _IO_no_init. Remove wd from struct locked_FILE. (_IO_wproc_jumps): Remove. Reported by Andrew Josey . * stdio-common/Makefile (tests): Add tst-popen. * stdio-common/tst-popen.c: New test. --- libc/libio/iopopen.c.jj 2004-02-20 16:36:30.000000000 +0100 +++ libc/libio/iopopen.c 2004-07-23 16:52:13.745182557 +0200 @@ -106,7 +106,6 @@ struct _IO_proc_file typedef struct _IO_proc_file _IO_proc_file; static const struct _IO_jump_t _IO_proc_jumps; -static const struct _IO_jump_t _IO_wproc_jumps; static struct _IO_proc_file *proc_file_chain; @@ -213,7 +212,6 @@ _IO_new_popen (command, mode) #ifdef _IO_MTSAFE_IO _IO_lock_t lock; #endif - struct _IO_wide_data wd; } *new_f; _IO_FILE *fp; @@ -224,7 +222,7 @@ _IO_new_popen (command, mode) new_f->fpx.file.file._lock = &new_f->lock; #endif fp = &new_f->fpx.file.file; - _IO_no_init (fp, 0, 0, &new_f->wd, &_IO_wproc_jumps); + _IO_init (fp, 0); _IO_JUMPS (&new_f->fpx.file) = &_IO_proc_jumps; _IO_new_file_init (&new_f->fpx.file); #if !_IO_UNIFIED_JUMPTABLES @@ -309,29 +307,6 @@ static const struct _IO_jump_t _IO_proc_ JUMP_INIT(imbue, _IO_default_imbue) }; -static const struct _IO_jump_t _IO_wproc_jumps = { - JUMP_INIT_DUMMY, - JUMP_INIT(finish, _IO_new_file_finish), - JUMP_INIT(overflow, _IO_new_file_overflow), - JUMP_INIT(underflow, _IO_new_file_underflow), - JUMP_INIT(uflow, INTUSE(_IO_default_uflow)), - JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)), - JUMP_INIT(xsputn, _IO_new_file_xsputn), - JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)), - JUMP_INIT(seekoff, _IO_new_file_seekoff), - JUMP_INIT(seekpos, _IO_default_seekpos), - JUMP_INIT(setbuf, _IO_new_file_setbuf), - JUMP_INIT(sync, _IO_new_file_sync), - JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)), - JUMP_INIT(read, INTUSE(_IO_file_read)), - JUMP_INIT(write, _IO_new_file_write), - JUMP_INIT(seek, INTUSE(_IO_file_seek)), - JUMP_INIT(close, _IO_new_proc_close), - JUMP_INIT(stat, INTUSE(_IO_file_stat)), - JUMP_INIT(showmanyc, _IO_default_showmanyc), - JUMP_INIT(imbue, _IO_default_imbue) -}; - strong_alias (_IO_new_popen, __new_popen) versioned_symbol (libc, _IO_new_popen, _IO_popen, GLIBC_2_1); versioned_symbol (libc, __new_popen, popen, GLIBC_2_1); --- libc/stdio-common/Makefile.jj 2004-01-12 10:52:38.000000000 +0100 +++ libc/stdio-common/Makefile 2004-07-23 16:37:15.853516991 +0200 @@ -52,7 +52,8 @@ tests := tstscanf test_rdwr test-popen t scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \ scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \ tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \ - tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 + tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \ + tst-popen test-srcs = tst-unbputc tst-printf --- libc/stdio-common/tst-popen.c.jj 2004-07-23 16:22:12.521611310 +0200 +++ libc/stdio-common/tst-popen.c 2004-07-23 16:42:30.832372281 +0200 @@ -0,0 +1,72 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2004. + + 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 + +static int +do_test (void) +{ + FILE *f = popen ("echo test", "r"); + int result = 0, ret; + char *line = NULL; + size_t len = 0; + + if (f == NULL) + { + printf ("popen failed %m"); + return 1; + } + + /* POSIX says that pipe streams are byte-oriented. */ + if (fwide (f, 0) >= 0) + { + puts ("popen did not return byte-oriented stream"); + result = 1; + } + + if (getline (&line, &len, f) != 5) + { + puts ("could not read line from popen"); + result = 1; + } + else if (strcmp (line, "test\n") != 0) + { + printf ("read \"%s\"\n", line); + result = 1; + } + + if (getline (&line, &len, f) != -1) + { + puts ("second getline did not return -1"); + result = 1; + } + + ret = pclose (f); + if (ret != 0) + { + printf ("pclose returned %d\n", ret); + result = 1; + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" Jakub From jakub@redhat.com Fri Jul 23 18:25:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 23 Jul 2004 18:25:00 -0000 Subject: [PATCH] Handle gcc -std=c99 -D_XOPEN_SOURCE=600 [BZ #284] Message-ID: <20040723160943.GX30497@sunsite.ms.mff.cuni.cz> Hi! The c99 script (which is part of XPG6) uses gcc -std=c99. Unfortunately -std=c99 defines also __STRICT_ANSI__ and eventhough -D_XOPEN_SOURCE=600 per XPG6 should enable -D_POSIX_SOURCE and -D_POSIX_C_SOURCE=200112L, when __STRICT_ANSI__ it doesn't do so. I think it would be better if gcc -std=c99 did not define __STRICT_ANSI__, only gcc -std=c99 -ansi did, because otherwise there is no way to request ISO C99 language features and XPG6, but not GNU C99 language extensions. The c99 script could be changed to use gcc -std=c99 -U__STRICT_ANSI "$@", but still there are many people who will use gcc -std=c99 -D_XOPEN_SOURCE=600. Or as done in the patch below __STRICT_ANSI__ can be ignored if _XOPEN_SOURCE is defined for the purpose of defining _POSIX_SOURCE and _POSIX_C_SOURCE. The __clockid_t change is IMHO useful no matter what solution is chosen, NPTL pthread.h already uses __clockid_t in a couple of other places surrounded by __USE_XOPEN2K. 2004-07-23 Jakub Jelinek [BZ #284] * include/features.h (_POSIX_SOURCE, _POSIX_C_SOURCE): Define if _XOPEN_SOURCE >= 500 even if __STRICT_ANSI__ is defined. linuxthreads/ * sysdeps/pthread/pthread.h (pthread_getcpuclockid): Use __clockid_t instead of clockid_t. nptl/ * sysdeps/pthread/pthread.h (pthread_getcpuclockid): Use __clockid_t instead of clockid_t. --- libc/include/features.h.jj 2003-05-17 02:38:00.000000000 +0200 +++ libc/include/features.h 2004-07-23 20:12:52.086150557 +0200 @@ -162,8 +162,8 @@ /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2 (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */ -#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \ - !defined _POSIX_C_SOURCE) +#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) # define _POSIX_SOURCE 1 # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 # define _POSIX_C_SOURCE 2 --- libc/linuxthreads/sysdeps/pthread/pthread.h.jj 2003-12-29 00:50:52.000000000 +0100 +++ libc/linuxthreads/sysdeps/pthread/pthread.h 2004-07-23 18:59:27.759397642 +0200 @@ -648,7 +648,7 @@ extern void _pthread_cleanup_pop_restore #ifdef __USE_XOPEN2K /* Get ID of CPU-time clock for thread THREAD_ID. */ extern int pthread_getcpuclockid (pthread_t __thread_id, - clockid_t *__clock_id) __THROW; + __clockid_t *__clock_id) __THROW; #endif --- libc/nptl/sysdeps/pthread/pthread.h.jj 2004-03-22 14:45:56.000000000 +0100 +++ libc/nptl/sysdeps/pthread/pthread.h 2004-07-23 18:58:50.252951923 +0200 @@ -915,7 +915,7 @@ extern int pthread_setspecific (pthread_ #ifdef __USE_XOPEN2K /* Get ID of CPU-time clock for thread THREAD_ID. */ extern int pthread_getcpuclockid (pthread_t __thread_id, - clockid_t *__clock_id) __THROW; + __clockid_t *__clock_id) __THROW; #endif Jakub From drepper@redhat.com Fri Jul 23 18:40:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 23 Jul 2004 18:40:00 -0000 Subject: [PATCH] Make popen return byte-oriented stream [BZ #282] In-Reply-To: <20040723124104.GW30497@sunsite.ms.mff.cuni.cz> References: <20040723124104.GW30497@sunsite.ms.mff.cuni.cz> Message-ID: <41015B6A.2030608@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Fri Jul 23 18:53:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 23 Jul 2004 18:53:00 -0000 Subject: [PATCH] Change month names for kr_KO [BZ #25] In-Reply-To: <2flhdrylro1.fsf@saruman.uio.no> References: <2flhdrylro1.fsf@saruman.uio.no> Message-ID: <41015E84.3030304@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Fri Jul 23 19:16:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 23 Jul 2004 19:16:00 -0000 Subject: [PATCH] Handle gcc -std=c99 -D_XOPEN_SOURCE=600 [BZ #284] In-Reply-To: References: <20040723160943.GX30497@sunsite.ms.mff.cuni.cz> Message-ID: <410163FB.3010009@redhat.com> Joseph S. Myers wrote: > A conforming implementation of a c99 script (none is included in FSF GCC, > though it's in the projects list and several variants are floating around) > should certainly define __STRICT_ANSI__ so that pure ISO C programs that > don't want POSIX facilities can be built with it and programs using POSIX > facilities need to define feature test macros. Wrong. That would mean you would hijack the name "c99". c99 is the name of the C compiler in POSIX. Any other use, e.g., for strict ISO C compliant uses, is a conflict. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Fri Jul 23 20:20:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 23 Jul 2004 20:20:00 -0000 Subject: [PATCH] Handle gcc -std=c99 -D_XOPEN_SOURCE=600 [BZ #284] In-Reply-To: References: <20040723160943.GX30497@sunsite.ms.mff.cuni.cz> <410163FB.3010009@redhat.com> Message-ID: <410172E2.7010909@redhat.com> Joseph S. Myers wrote: > c99 is the name of the compiler to "accept source code conforming to the > ISO C standard". For example, And once -D_POSIX_C_SOURCE=200112L is defined all this ISO C nonsense must be completely out of the way. No __STRICT_ANSI__, since non-ISO C stuff is used. The same applies to a few other defines. Only if none is defined can this silly strict ISO C business take place. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From drepper@redhat.com Sun Jul 25 03:32:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 25 Jul 2004 03:32:00 -0000 Subject: [PATCH] Fix strtold on 32-bit arches with ldbl-96 [BZ #274] In-Reply-To: <20040720200152.GO30497@sunsite.ms.mff.cuni.cz> References: <20040720200152.GO30497@sunsite.ms.mff.cuni.cz> Message-ID: <41032996.5030402@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From pere@hungry.com Mon Jul 26 22:09:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Mon, 26 Jul 2004 22:09:00 -0000 Subject: [PATCH] Test sorting order for tr_TR In-Reply-To: (Petter Reinholdtsen's message of "Sun, 18 Jul 2004 09:47:22 +0200") References: Message-ID: <2flr7qy8lpb.fsf@saruman.uio.no> [Petter Reinholdtsen, 2004-07-18] > I got a sorting order test from the tr_TR author. Please include in > CVS. There is the changelog entry for localedata/ChangeLog: I hope > the UTF-8 encoded file survived this email. > > 2004-07-17 Petter Reinholdtsen > > * Makefile (test-input): Add tr_TR.UTF-8 sorting test. Test case > for BZ #19. > * tr_TR.in: New file Is there anything controversial in this patch? Will it help to mention in the changelog that I got the test data from Recai Oktas to get it accepted? Or are you just all busy and I just to impatient? Should such test cases go through Bugzilla, or is it OK for me to just pass them on directly? From drepper@redhat.com Mon Jul 26 22:43:00 2004 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 26 Jul 2004 22:43:00 -0000 Subject: [PATCH] Test sorting order for tr_TR In-Reply-To: <2flr7qy8lpb.fsf@saruman.uio.no> References: <2flr7qy8lpb.fsf@saruman.uio.no> Message-ID: <410588D5.7030906@redhat.com> Petter Reinholdtsen wrote: > Is there anything controversial in this patch? Yes. The problem is that it requires yet another locale to be created at test time. And there is not even an error which is tested for. To test the actual locale definition, and not the locale code in libc, we need a separate target which the interested parties can run if necessary. I don't have the time to make all these changes to the Makefile in the moment. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? From pere@hungry.com Mon Jul 26 22:47:00 2004 From: pere@hungry.com (Petter Reinholdtsen) Date: Mon, 26 Jul 2004 22:47:00 -0000 Subject: [PATCH] Test sorting order for tr_TR In-Reply-To: <410588D5.7030906@redhat.com> References: <2flr7qy8lpb.fsf@saruman.uio.no> <410588D5.7030906@redhat.com> Message-ID: <20040726224727.GG7928@saruman.uio.no> [Ulrich Drepper] > Yes. The problem is that it requires yet another locale to be created > at test time. And there is not even an error which is tested for. It does? As far as I can se the tr_TR.UTF-8 is already created at test time, and all my patch is doing is adding a new sorting test file to check that the sorting order of the locale is correct. > To test the actual locale definition, and not the locale code in > libc, we need a separate target which the interested parties can run > if necessary. I don't have the time to make all these changes to > the Makefile in the moment. Yes, this is a good idea. We would be nice to be able to check both the implementation and the content of the locales. I'll see what I can do. :) I guess the hard part will be to come up with a target name for this. :) From jakub@redhat.com Fri Jul 30 07:58:00 2004 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 30 Jul 2004 07:58:00 -0000 Subject: [PATCH] Handle gcc -std=c99 -D_XOPEN_SOURCE=600 [BZ #284] In-Reply-To: <410172E2.7010909@redhat.com> References: <20040723160943.GX30497@sunsite.ms.mff.cuni.cz> <410163FB.3010009@redhat.com> <410172E2.7010909@redhat.com> Message-ID: <20040730054203.GY30497@sunsite.ms.mff.cuni.cz> On Fri, Jul 23, 2004 at 01:19:46PM -0700, Ulrich Drepper wrote: > Joseph S. Myers wrote: > > > c99 is the name of the compiler to "accept source code conforming to the > > ISO C standard". For example, > > And once -D_POSIX_C_SOURCE=200112L is defined all this ISO C nonsense > must be completely out of the way. No __STRICT_ANSI__, since non-ISO C > stuff is used. The same applies to a few other defines. Only if none > is defined can this silly strict ISO C business take place. I guess it all depends what exact meaning __STRICT_ANSI__ is supposed to have. Either its definition chooses only ISO C90 (resp. C99) features in the headers, or it can be combined with other feature set macros with the result of a union between ISO C90 (resp. C99) features and features selected by the other feature macros. The __STRICT_ANSI__ documentation in info gcc doesn't seem to favor either of these definitions, at least in my reading. Jakub