From roland@redhat.com Wed Feb 1 03:19:00 2006 From: roland@redhat.com (Roland McGrath) Date: Wed, 01 Feb 2006 03:19:00 -0000 Subject: Enforcing gcc-4.1 for Powerpc -mlong-double-128 In-Reply-To: Steven Munroe's message of Tuesday, 31 January 2006 16:49:16 -0600 <43DFE96C.5050203@us.ibm.com> Message-ID: <20060201031927.D2511180B7B@magilla.sf.frob.com> > gcc-3.4 now ICEs for > building powerpc64 -mlong-double-128 with current glibc cvs. This had > worked in the past. What about 4.0? From jakub@redhat.com Wed Feb 1 09:27:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 09:27:00 -0000 Subject: [PATCH] Fix ldbl-128 s_llrintl.c Message-ID: <20060201092659.GX4625@sunsite.mff.cuni.cz> Hi! Obvious typo causing wrong rounding... 2006-02-01 Jakub Jelinek * sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Fix a typo. * sysdeps/s390/fpu/libm-test-ulps: Remove llrint ulps. --- libc/sysdeps/ieee754/ldbl-128/s_llrintl.c.jj 2001-07-06 00:55:55.000000000 -0400 +++ libc/sysdeps/ieee754/ldbl-128/s_llrintl.c 2006-02-01 04:13:21.000000000 -0500 @@ -1,6 +1,6 @@ /* Round argument to nearest integral value according to current rounding direction. - Copyright (C) 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997 and Jakub Jelinek , 1999. @@ -52,7 +52,7 @@ __llrintl (long double x) return 0; w = two112[sx] + x; t = w - two112[sx]; - GET_LDOUBLE_WORDS64 (i0, i1, x); + GET_LDOUBLE_WORDS64 (i0, i1, t); j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; i0 &= 0x0000ffffffffffffLL; i0 |= 0x0001000000000000LL; --- libc/sysdeps/s390/fpu/libm-test-ulps.jj 2006-01-31 15:22:04.000000000 -0500 +++ libc/sysdeps/s390/fpu/libm-test-ulps 2006-02-01 04:19:31.000000000 -0500 @@ -691,62 +691,6 @@ ifloat: 2 ildouble: 1 ldouble: 1 -# llrint -Test "llrint (-4503599627370495.5) == -4503599627370496LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-4503599627370496.75) == -4503599627370497LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-4503599627370497.5) == -4503599627370498LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-72057594037927935.5) == -72057594037927936LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-72057594037927936.75) == -72057594037927937LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-72057594037927937.5) == -72057594037927938LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-9007199254740991.5) == -9007199254740992LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-9007199254740992.75) == -9007199254740993LL": -ildouble: 1 -ldouble: 1 -Test "llrint (-9007199254740993.5) == -9007199254740994LL": -ildouble: 1 -ldouble: 1 -Test "llrint (4503599627370495.5) == 4503599627370496LL": -ildouble: -1 -ldouble: -1 -Test "llrint (4503599627370496.75) == 4503599627370497LL": -ildouble: -1 -ldouble: -1 -Test "llrint (4503599627370497.5) == 4503599627370498LL": -ildouble: -1 -ldouble: -1 -Test "llrint (72057594037927935.5) == 72057594037927936LL": -ildouble: -1 -ldouble: -1 -Test "llrint (72057594037927936.75) == 72057594037927937LL": -ildouble: -1 -ldouble: -1 -Test "llrint (72057594037927937.5) == 72057594037927938LL": -ildouble: -1 -ldouble: -1 -Test "llrint (9007199254740991.5) == 9007199254740992LL": -ildouble: -1 -ldouble: -1 -Test "llrint (9007199254740992.75) == 9007199254740993LL": -ildouble: -1 -ldouble: -1 -Test "llrint (9007199254740993.5) == 9007199254740994LL": -ildouble: -1 -ldouble: -1 - # log10 Test "log10 (0.75) == -0.124938736608299953132449886193870744": double: 1 Jakub From jakub@redhat.com Wed Feb 1 12:21:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 12:21:00 -0000 Subject: [PATCH] Fix s_finitel.c on ppc/ppc64 Message-ID: <20060201122123.GY4625@sunsite.mff.cuni.cz> Hi! While comparing ppc{,64} and s390{,64} abilist differences between older DFmode only long double capable glibc with current CVS glibc, I noticed we are now only exporting {__,}finitel@GLIBC_2.{1,0} and not also {__,}finitel@@GLIBC_2.4. Fixed thusly: 2006-02-01 Jakub Jelinek * sysdeps/ieee754/ldbl-128ibm/s_finitel.c: Use long_double_symbol even for libm. --- libc/sysdeps/ieee754/ldbl-128ibm/s_finitel.c.jj 2006-01-28 01:07:25.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-128ibm/s_finitel.c 2006-02-01 13:15:44.000000000 +0100 @@ -35,8 +35,11 @@ ___finitel (long double x) -0x7ff0000000000000LL)>>63); } hidden_ver (___finitel, __finitel) -#ifndef IS_IN_libm weak_alias (___finitel, ____finitel) -long_double_symbol (libc, ___finitel, finitel); -long_double_symbol (libc, ____finitel, __finitel); +#ifdef IS_IN_libm +long_double_symbol (libm, ____finitel, finitel); +long_double_symbol (libm, ___finitel, __finitel); +#else +long_double_symbol (libc, ____finitel, finitel); +long_double_symbol (libc, ___finitel, __finitel); #endif Jakub From jakub@redhat.com Wed Feb 1 15:25:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 15:25:00 -0000 Subject: [PATCH] Fix __BEGIN_NAMESPACE_C99/__END_NAMESPACE_C99 pairing Message-ID: <20060201152453.GZ4625@sunsite.mff.cuni.cz> Hi! In , __BEGIN_NAMESPACE_C99 is guarded with: #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 condition while the corresponding __END_NAMESPACE_C99 with: #ifdef __USE_ISOC99. So, if in C++, _GLIBCPP_USE_NAMESPACES is defined, either __USE_MISC or __USE_XOPEN_EXTENDED and not __USE_ISOC99, we have unclosed namespace. Additionally, it seems that currently scalb{,l,f} prototype is only provided #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && defined __USE_ISOC99 while in revision 1.18 and older it was provided even if not __USE_ISOC99 (after all, scalb{,l,f} is not in ISO C99). 2006-02-01 Jakub Jelinek * math/bits/mathcalls.h: Guard __END_NAMESPACE_C99 with the same #if condition as corresponding __BEGIN_NAMESPACE_C99. (scalb): Don't define only if __USE_ISOC99. --- libc/math/bits/mathcalls.h.jj 2006-01-18 09:28:38.000000000 +0100 +++ libc/math/bits/mathcalls.h 2006-02-01 16:17:46.000000000 +0100 @@ -353,10 +353,13 @@ __MATHDECL_1 (int, __signbit,, (_Mdouble /* Multiply-add function computed as a ternary operation. */ __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); +#endif /* Use ISO C99. */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 __END_NAMESPACE_C99 +#endif -# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED /* Return X times (2 to the Nth power). */ __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); -# endif -#endif /* Use ISO C99. */ +#endif Jakub From jakub@redhat.com Wed Feb 1 15:29:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 15:29:00 -0000 Subject: [PATCH] Fix __BEGIN_NAMESPACE_C99/__END_NAMESPACE_C99 pairing In-Reply-To: <20060201152453.GZ4625@sunsite.mff.cuni.cz> References: <20060201152453.GZ4625@sunsite.mff.cuni.cz> Message-ID: <20060201152926.GA4625@sunsite.mff.cuni.cz> On Wed, Feb 01, 2006 at 04:24:53PM +0100, Jakub Jelinek wrote: > 2006-02-01 Jakub Jelinek > > * math/bits/mathcalls.h: Guard __END_NAMESPACE_C99 with the > same #if condition as corresponding __BEGIN_NAMESPACE_C99. > (scalb): Don't define only if __USE_ISOC99. Forgot to add, I did some testing to see if similar problems aren't elsewhere: #!/bin/sh for i in `rpm -ql glibc-headers`; do perl /usr/src/libc/scripts/begin-end-check.pl $i; done 2>&1 | grep -v OK for i in `rpm -ql glibc-headers`; do cat > /tmp/a.c < #undef __BEGIN_DECLS #undef __END_DECLS #undef __BEGIN_NAMESPACE_STD #undef __END_NAMESPACE_STD #undef __BEGIN_NAMESPACE_C99 #undef __END_NAMESPACE_C99 #include <$i> EOF gcc -E /tmp/a.c -o /tmp/a.i > /dev/null 2>&1 || continue; for flags in "" -D_GNU_SOURCE -D_ISOC99_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_SVID_SOURCE -D_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -ansi -D_POSIX_SOURCE -D_POSIX_C_SOURCE -D_POSIX_C_SOURCE=2 -D_POSIX_C_SOURCE=199309L -D_POSIX_C_SOURCE=199506L -D_POSIX_C_SOURCE=200112L; do gcc $flags -E /tmp/a.c -o /tmp/a.i > /dev/null 2>&1; perl /usr/src/libc/scripts/begin-end-check.pl /tmp/a.i | grep -v OK | sed "s~^~$i $flags: ~" done done and math.h (plus tgmath.h that includes math.h) were the only 2 reported headers. Jakub From jakub@redhat.com Wed Feb 1 16:34:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 16:34:00 -0000 Subject: [PATCH] Fix Message-ID: <20060201163435.GB4625@sunsite.mff.cuni.cz> Hi! While _IO_vfscanf and _IO_vfprintf are 1) exported from libc 2) prototyped in libio.h, the latter two are guarded with #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T and not exported. 2006-02-01 Jakub Jelinek * libio/bits/libio-ldbl.h (_IO_vfwscanf, _IO_vfwprintf): Remove __LDBL_REDIR_DECL. --- libc/libio/bits/libio-ldbl.h.jj 2006-01-14 13:09:48.000000000 +0100 +++ libc/libio/bits/libio-ldbl.h 2006-02-01 17:30:32.000000000 +0100 @@ -23,5 +23,3 @@ __LDBL_REDIR_DECL (_IO_vfscanf) __LDBL_REDIR_DECL (_IO_vfprintf) -__LDBL_REDIR_DECL (_IO_vfwscanf) -__LDBL_REDIR_DECL (_IO_vfwprintf) Jakub From munroesj@us.ibm.com Wed Feb 1 17:33:00 2006 From: munroesj@us.ibm.com (Steven Munroe) Date: Wed, 01 Feb 2006 17:33:00 -0000 Subject: [PATCH] Fix s_finitel.c on ppc/ppc64 In-Reply-To: <20060201122123.GY4625@sunsite.mff.cuni.cz> References: <20060201122123.GY4625@sunsite.mff.cuni.cz> Message-ID: <43E0F2AE.3050702@us.ibm.com> Jakub Jelinek wrote: >Hi! > >While comparing ppc{,64} and s390{,64} abilist differences between >older DFmode only long double capable glibc with current CVS glibc, >I noticed we are now only exporting {__,}finitel@GLIBC_2.{1,0} >and not also {__,}finitel@@GLIBC_2.4. Fixed thusly: > Thanks for finding this and the libio-ldbl.h problem. I have hit this trying a full biarch toolchain build. But it looks there are simular problems with sprintf and __strtold_internal. I am hitting this in the powerpc glibc install for -msecure-plt bootstrap. /opt/biarch/gcc41-ld/bin/powerpc-secure-gcc -o /home/sjmunroe/toolchain/build/glibc32/malloc/memusagestat /home/sjmunroe/toolchain/build/glibc32/malloc/memusagestat.o -lgd -lpng -lz -lm /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: undefined reference to `finitel@GLIBC_2.4' /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: undefined reference to `sprintf@GLIBC_2.4' /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: undefined reference to `__strtold_internal@GLIBC_2.4' collect2: ld returned 1 exit status Will the fix be simular to finitel? From munroesj@us.ibm.com Wed Feb 1 17:37:00 2006 From: munroesj@us.ibm.com (Steven Munroe) Date: Wed, 01 Feb 2006 17:37:00 -0000 Subject: Enforcing gcc-4.1 for Powerpc -mlong-double-128 In-Reply-To: <20060201031927.D2511180B7B@magilla.sf.frob.com> References: <20060201031927.D2511180B7B@magilla.sf.frob.com> Message-ID: <43E0F3CF.8040608@us.ibm.com> Roland McGrath wrote: >>gcc-3.4 now ICEs for >>building powerpc64 -mlong-double-128 with current glibc cvs. This had >>worked in the past. >> > >What about 4.0? > > gcc-4.0 seems to be ok. At least does not ICE for the test case that take out gcc-3.4. Have not tried a full glibc -mlong-double-128 build lately thoe... From jakub@redhat.com Wed Feb 1 17:45:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 01 Feb 2006 17:45:00 -0000 Subject: [PATCH] Fix s_finitel.c on ppc/ppc64 In-Reply-To: <43E0F2AE.3050702@us.ibm.com> References: <20060201122123.GY4625@sunsite.mff.cuni.cz> <43E0F2AE.3050702@us.ibm.com> Message-ID: <20060201174525.GC4625@sunsite.mff.cuni.cz> On Wed, Feb 01, 2006 at 11:41:02AM -0600, Steven Munroe wrote: > >While comparing ppc{,64} and s390{,64} abilist differences between > >older DFmode only long double capable glibc with current CVS glibc, > >I noticed we are now only exporting {__,}finitel@GLIBC_2.{1,0} > >and not also {__,}finitel@@GLIBC_2.4. Fixed thusly: > > > > Thanks for finding this and the libio-ldbl.h problem. I have hit this > trying a full biarch toolchain build. But it looks there are simular > problems with sprintf and __strtold_internal. I am hitting this in the > powerpc glibc install for -msecure-plt bootstrap. > > /opt/biarch/gcc41-ld/bin/powerpc-secure-gcc -o > /home/sjmunroe/toolchain/build/glibc32/malloc/memusagestat > /home/sjmunroe/toolchain/build/glibc32/malloc/memusagestat.o -lgd -lpng > -lz -lm > /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: > undefined reference to `finitel@GLIBC_2.4' > /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: > undefined reference to `sprintf@GLIBC_2.4' > /opt/biarch/gcc41-ld/lib/gcc/powerpc-linux/4.1.0/../../../../lib/libm.so: > undefined reference to `__strtold_internal@GLIBC_2.4' > collect2: ld returned 1 exit status > > Will the fix be simular to finitel? There are no problems with sprintf nor __strtold_internal in the .dynsyms I have: find . -type f | xargs grep '^\(__nldbl\|\)\(sprintf\|__strtold_internal\)' ./i386/lib.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./i386/lib.libc-2.3.90.so.abi:sprintf@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./i686/lib.i686.nosegneg.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./i686/lib.i686.nosegneg.libc-2.3.90.so.abi:sprintf@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./i686/lib.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./i686/lib.libc-2.3.90.so.abi:sprintf@@GLIBC_2.0 FUNC GLOBAL DEFAULT ./ia64/lib.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.2 FUNC GLOBAL DEFAULT ./ia64/lib.libc-2.3.90.so.abi:sprintf@@GLIBC_2.2 FUNC GLOBAL DEFAULT ./ppc/lib.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./ppc/lib.libc-2.3.90.so.abi:__strtold_internal@GLIBC_2.0 FUNC GLOBAL DEFAULT ./ppc/lib.libc-2.3.90.so.abi:sprintf@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./ppc/lib.libc-2.3.90.so.abi:sprintf@GLIBC_2.0 FUNC GLOBAL DEFAULT ./ppc64/lib64.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./ppc64/lib64.libc-2.3.90.so.abi:__strtold_internal@GLIBC_2.3 FUNC GLOBAL DEFAULT ./ppc64/lib64.libc-2.3.90.so.abi:sprintf@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./ppc64/lib64.libc-2.3.90.so.abi:sprintf@GLIBC_2.3 FUNC GLOBAL DEFAULT ./s390/lib.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./s390/lib.libc-2.3.90.so.abi:__strtold_internal@GLIBC_2.0 FUNC GLOBAL DEFAULT ./s390/lib.libc-2.3.90.so.abi:sprintf@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./s390/lib.libc-2.3.90.so.abi:sprintf@GLIBC_2.0 FUNC GLOBAL DEFAULT ./s390x/lib64.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./s390x/lib64.libc-2.3.90.so.abi:__strtold_internal@GLIBC_2.2 FUNC GLOBAL DEFAULT ./s390x/lib64.libc-2.3.90.so.abi:sprintf@@GLIBC_2.4 FUNC GLOBAL DEFAULT ./s390x/lib64.libc-2.3.90.so.abi:sprintf@GLIBC_2.2 FUNC GLOBAL DEFAULT ./x86_64/lib64.libc-2.3.90.so.abi:__strtold_internal@@GLIBC_2.2.5 FUNC GLOBAL DEFAULT ./x86_64/lib64.libc-2.3.90.so.abi:sprintf@@GLIBC_2.2.5 FUNC GLOBAL DEFAULT Furthermore, even the missing {,__}finitel@@GLIBC_2.4 in libm.so is something that could result in such problems - {,__}finitel@@GLIBC_2.4 is still exported from libc.so and therefore it would just bind to the libc symbol rather than libm. The above errors sound like you are mixing a newly built libm.so with old libc.so or something like that. Jakub From roland@redhat.com Thu Feb 2 09:42:00 2006 From: roland@redhat.com (Roland McGrath) Date: Thu, 02 Feb 2006 09:42:00 -0000 Subject: [PATCH] SH tiny tweak In-Reply-To: Kaz Kojima's message of Tuesday, 31 January 2006 23:30:10 +0900 <20060131.233010.93478310.kkojima@rr.iij4u.or.jp> Message-ID: <20060202094204.57F60180988@magilla.sf.frob.com> I made a change so that include/setjmp.h is not spuriously brought in for C++. I'm concerned that your change might affect C++ name mangling for existing C++ code using jmp_buf, but I'm not sure whether that is an issue or not. Thanks, Roland From roland@redhat.com Thu Feb 2 10:15:00 2006 From: roland@redhat.com (Roland McGrath) Date: Thu, 02 Feb 2006 10:15:00 -0000 Subject: __atfct_seterrno() or futimesat() broken In-Reply-To: Thorsten Kukuk's message of Saturday, 28 January 2006 17:55:11 +0100 <20060128165511.GA4000@suse.de> Message-ID: <20060202101544.476E1180988@magilla.sf.frob.com> I don't see how the lstat check that did the problematic string twiddling was actually doing anything for us not better done by the fstat check for the EBADF case. I changed it to use the simple fstat check for EBADF on ENOENT as well as ENOTDIR, which gets rid of the code with the bad assumptions about the contents of BUF. I also made it do the check for missing /proc on ENOENT as well. There are in fact many other potential error codes that could be /proc is not mounted as expected, but ENOENT is in fact the most likely one (and ENOTDIR possible, but not perhaps any more likely than several others). Thanks, Roland From kkojima@rr.iij4u.or.jp Thu Feb 2 12:26:00 2006 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Thu, 02 Feb 2006 12:26:00 -0000 Subject: [PATCH] SH tiny tweak In-Reply-To: <20060202094204.57F60180988@magilla.sf.frob.com> References: <20060131.233010.93478310.kkojima@rr.iij4u.or.jp> <20060202094204.57F60180988@magilla.sf.frob.com> Message-ID: <20060202.212549.25479365.kkojima@rr.iij4u.or.jp> Roland McGrath wrote: >I made a change so that include/setjmp.h is not spuriously brought in for C++. >I'm concerned that your change might affect C++ name mangling for existing >C++ code using jmp_buf, but I'm not sure whether that is an issue or not. Thanks! It gets rid of the compile time failure for test-cancel24 on SH. Regards, kaz From jakub@redhat.com Thu Feb 2 15:23:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 02 Feb 2006 15:23:00 -0000 Subject: [PATCH] Fix nexttowardl if compiling new program against new glibc headers with -mlong-double-64 Message-ID: <20060202152341.GD4625@sunsite.mff.cuni.cz> Hi! I have (hopefully) finished the ldbl-dbl-tst.c testcase I posted a few weeks ago and tested it in various ways on ppc{32,64} and s390{,x} with already installed new glibc, in all cases using -O0 -fno-builtin to avoid compiler/inlines optimizing stuff out. 1) compiled/linked the program against older (non-ldbl) glibc, run against old glibc 2) run the same binary against new glibc 3) compile against old glibc, link with -lnldbl_nonshared -lm, run against new glibc 4) compile/run against new glibc with -mlong-double-64 5) compile/run against new glibc with -mlong-double-128 Repeat the same also for -D_FORTIFY_SOURCE=2. The only failures were in 4) on s390{,x} where it segfaulted, fixed by the patch below, and 5) on ppc{32,64} where the test on line 262 failed, due to apparently different rounding. #include #include int main (void) { register_printf_function ('B', printf_size, printf_size_info); register_printf_function ('b', printf_size, printf_size_info); printf ("%LB %LB %B %B\n", 3.25L, 7834.5L, 3.75, 7835.5); puts ("Expected"); printf ("3.250 7.835K 3.750 7.835K\n"); return 0; } on ppc{32,64} with -mlong-double-128 prints: 3.250 7.834K 3.750 7.835K Expected 3.250 7.835K 3.750 7.835K while on x86_64 or s390/s390x with -mlong-double-128 prints the expected output. 2006-02-02 Jakub Jelinek * math/math.h [__LDBL_COMPAT && __USE_ISOC99] (nexttowardl): New prototype. --- libc/math/math.h.jj 2006-01-14 17:41:02.000000000 +0100 +++ libc/math/math.h 2006-02-02 15:26:29.000000000 +0100 @@ -110,6 +110,9 @@ extern float __REDIRECT_NTH (nexttowardf __attribute__ ((__const__)); extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__)); +extern long double __REDIRECT_NTH (nexttowardl, + (long double __x, long double __y), + nextafter) __attribute__ ((__const__)); # endif # endif Jakub -------------- next part -------------- #define _GNU_SOURCE 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #define obstack_chunk_alloc malloc #define obstack_chunk_free free #ifdef __NO_LONG_DOUBLE_MATH /* Provide prototypes ourselves. */ extern long double acoshl (long double); extern long double acosl (long double); extern long double asinhl (long double); extern long double asinl (long double); extern long double atan2l (long double, long double); extern long double atanhl (long double); extern long double atanl (long double); extern long double cbrtl (long double); extern long double ceill (long double); extern long double copysignl (long double, long double); extern long double coshl (long double); extern long double cosl (long double); extern long double dreml (long double, long double); extern long double erfcl (long double); extern long double erfl (long double); extern long double exp10l (long double); extern long double exp2l (long double); extern long double expl (long double); extern long double expm1l (long double); extern long double fabsl (long double); extern long double fdiml (long double, long double); extern int __finitel (long double); extern int finitel (long double); extern long double floorl (long double); extern long double fmal (long double, long double, long double); extern long double fmaxl (long double, long double); extern long double fminl (long double, long double); extern long double fmodl (long double, long double); extern long double frexpl (long double, int *); extern long double gammal (long double); extern long double hypotl (long double, long double); extern int ilogbl (long double); extern int isinfl (long double); extern int isnanl (long double); extern long double j0l (long double); extern long double j1l (long double); extern long double jnl (int, long double); extern long double ldexpl (long double, int); extern long double lgammal (long double); extern long double lgammal_r (long double, int *); extern long long int llrintl (long double); extern long long int llroundl (long double); extern long double log10l (long double); extern long double log1pl (long double); extern long double log2l (long double); extern long double logbl (long double); extern long double logl (long double); extern long int lrintl (long double); extern long int lroundl (long double); extern long double nanl (const char *); extern long double nexttowardl (long double, long double); extern long double modfl (long double, long double *); extern long double nearbyintl (long double); extern long double nextafterl (long double, long double); extern long double pow10l (long double); extern long double powl (long double, long double); extern long double remainderl (long double, long double); extern long double remquol (long double, long double, int *); extern long double rintl (long double); extern long double roundl (long double); extern long double scalbl (long double, long double); extern long double scalblnl (long double, long int); extern long double scalbnl (long double, int); extern long double significandl (long double); extern void sincosl (long double, long double *, long double *); extern long double sinhl (long double); extern long double sinl (long double); extern long double sqrtl (long double); extern long double tanhl (long double); extern long double tanl (long double); extern long double tgammal (long double); extern long double truncl (long double); extern long double y0l (long double); extern long double y1l (long double); extern long double ynl (int, long double); #endif _Complex long double lc1; long double l1, l2; _Complex double dc1; double d1, d2; int failures; #define CHECK(x) \ do { \ if (!(x)) \ { \ fprintf (stderr, "failure on line %d\n", __LINE__); \ ++failures; \ } \ } while (0) #define CHECK2(x, y) \ do { \ l1 = x; \ /* Avoid using fabsl here, we want to test it too. */ \ CHECK ((l1 > y && (l1 - y) < 0.01L) \ || (l1 <= y && (y - l1) < 0.01L)); \ } while (0) #define CHECK3(fn, x, y) \ CHECK2 (fn##l (x##L), y##L); \ CHECK2 (fn (x), y) #define CHECK4(fn, x, y, z) \ CHECK2 (fn##l (x##L, y##L), z##L); \ CHECK2 (fn (x, y), z) #define CHECK5(fn, x, y, z, w) \ CHECK2 (fn##l (x##L, y##L, z##L), w##L); \ CHECK2 (fn (x, y, z), w) #define CHECKC3(fn, x, yr, yc) \ lc1 = fn##l (x##L); \ CHECK2 (__real__ lc1, yr##L); \ CHECK2 (__imag__ lc1, yc##L); \ dc1 = fn (x); \ CHECK2 (__real__ dc1, yr); \ CHECK2 (__imag__ dc1, yc) #define CHECKC4(fn, x, y, zr, zc) \ lc1 = fn##l (x##L, y##L); \ CHECK2 (__real__ lc1, zr##L); \ CHECK2 (__imag__ lc1, zc##L); \ dc1 = fn (x, y); \ CHECK2 (__real__ dc1, zr); \ CHECK2 (__imag__ dc1, zc) void test (va_list *ap, va_list *pap) { int i; if (freopen ("/proc/self/fd/1", "w", stderr) == NULL) CHECK (0); CHECK (setlocale (LC_ALL, "en_US.ISO-8859-1") != NULL); locale_t loc = newlocale (LC_ALL_MASK, "en_US.ISO-8859-1", NULL); CHECK (loc != NULL); locale_t loc2 = newlocale (LC_ALL_MASK, "cs_CZ.UTF-8", NULL); CHECK (loc2 != NULL); char tmpp2[] = "/tmp/tst-ldbl-dbl-XXXXXX"; int fd = mkstemp (tmpp2); if (fd < 0) CHECK (0); char tmpp[sizeof ("/proc/self/fd/%d") + 3 * sizeof (int)]; snprintf (tmpp, sizeof (tmpp), "/proc/self/fd/%d", fd); unlink (tmpp2); if (freopen (tmpp, "w", stdout) == NULL) CHECK (0); /* asprintf, dprintf, fprintf, fwprintf, obstack_printf, obstack_vprintf, printf, printf_size, snprintf, sprintf, swprintf, vasprintf, vdprintf, vfprintf, vfwprintf, vprintf, vsnprintf, vsprintf, vswprintf, vwprintf, wprintf */ /* _IO_fprintf, _IO_printf, _IO_sprintf, _IO_vfprintf, _IO_vsprintf, __asprintf, __vsnprintf, __fprintf_chk, __fwprintf_chk, __printf_chk, __snprintf_chk, __sprintf_chk, __swprintf_chk, __vfprintf_chk, __vfwprintf_chk, __vprintf_chk, __vsnprintf_chk, __vsprintf_chk, __vswprintf_chk, __vwprintf_chk, __wprintf_chk, __printf_fp */ char *p; p = NULL; asprintf (&p, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); free (p); p = NULL; vasprintf (&p, "%Lg %5.9Lf %g %5.9f\n", *ap++); CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); free (p); fflush (stdout); dprintf (1, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vdprintf (1, "%Lg %5.9Lf %g %5.9f\n", *ap++); fflush (stdout); fprintf (stdout, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vfprintf (stdout, "%Lg %5.9Lf %g %5.9f\n", *ap++); printf ("%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vprintf ("%Lg %5.9Lf %g %5.9f\n", *ap++); struct obstack o; obstack_init (&o); obstack_printf (&o, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); obstack_1grow (&o, 0); p = obstack_finish (&o); CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); obstack_1grow (&o, 'z'); obstack_finish (&o); obstack_vprintf (&o, "%Lg %5.9Lf %g %5.9f\n", *ap++); obstack_1grow (&o, 0); p = obstack_finish (&o); CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); obstack_free (&o, NULL); char buf[80]; memset (buf, 0, sizeof (buf)); sprintf (buf, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); memset (buf, 0, sizeof (buf)); vsprintf (buf, "%Lg %5.9Lf %g %5.9f\n", *ap++); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); memset (buf, 0, sizeof (buf)); snprintf (buf, 80, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); memset (buf, 0, sizeof (buf)); vsnprintf (buf, 80, "%Lg %5.9Lf %g %5.9f\n", *ap++); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); fflush (stdout); if (freopen (tmpp, "r", stdin) == NULL) CHECK (0); for (i = 0; i < 6; i++) { memset (buf, 0, sizeof (buf)); CHECK (fgets (buf, sizeof (buf), stdin) == buf); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); } if (freopen (tmpp, "w", stdout) == NULL) CHECK (0); fwprintf (stdout, L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vfwprintf (stdout, L"%Lg %5.9Lf %g %5.9f\n", *ap++); wprintf (L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vwprintf (L"%Lg %5.9Lf %g %5.9f\n", *ap++); fflush (stdout); if (freopen (tmpp, "r", stdin) == NULL) CHECK (0); for (i = 0; i < 4; i++) { memset (buf, 0, sizeof (buf)); CHECK (fgets (buf, sizeof (buf), stdin) == buf); CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0); } if (freopen (tmpp, "w", stdout) == NULL) CHECK (0); wchar_t wbuf[80]; memset (wbuf, 0, sizeof (wbuf)); swprintf (wbuf, 80, L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (wcscmp (wbuf, L"3.25 7834.500000000 3.75 7835.500000000\n") == 0); memset (wbuf, 0, sizeof (wbuf)); vswprintf (wbuf, 80, L"%Lg %5.9Lf %g %5.9f\n", *ap++); CHECK (wcscmp (wbuf, L"3.25 7834.500000000 3.75 7835.500000000\n") == 0); register_printf_function ('B', printf_size, printf_size_info); register_printf_function ('b', printf_size, printf_size_info); memset (buf, 0, sizeof (buf)); sprintf (buf, "%LB %LB %B %B\n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (buf, "3.250 7.835K 3.750 7.835K\n") == 0); memset (buf, 0, sizeof (buf)); vsprintf (buf, "%Lb %Lb %b %b\n", *ap++); CHECK (strcmp (buf, "3.250 7.651k 3.750 7.652k\n") == 0); /* fscanf, fwscanf, scanf, sscanf, swscanf, vfscanf, vfwscanf, vscanf, vsscanf, vswscanf, vwscanf, wscanf */ /* _IO_sscanf, _IO_vfscanf, __vfscanf, __vsscanf */ l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (sscanf ("8.125 16372.625 -9.5 32163.125", "%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vsscanf ("8.125 16372.625 -9.5 32163.125", "%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); for (i = 0; i < 4; i++) puts ("8.125 16372.625 -9.5 32163.125"); fflush (stdout); if (freopen (tmpp, "r", stdin) == NULL) CHECK (0); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (fscanf (stdin, "%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vfscanf (stdin, "%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (scanf ("%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vscanf ("%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); if (freopen (tmpp, "r", stdin) == NULL) CHECK (0); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (swscanf (L"8.125 16372.625 -9.5 32163.125", L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vswscanf (L"8.125 16372.625 -9.5 32163.125", L"%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (fwscanf (stdin, L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vfwscanf (stdin, L"%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (wscanf (L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); l1 = 0; l2 = 0; d1 = 0; d2 = 0; CHECK (vwscanf (L"%Lf %Lf %lf %lf\n", *pap++) == 4); CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125); /* syslog, vsyslog */ /* __syslog_chk, __vsyslog_chk */ syslog (1, "long double test %Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5); vsyslog (1, "long double test %Lg %5.9Lf %g %5.9f\n", *ap++); /* qecvt, qecvt_r, qfcvt, qfcvt_r, qgcvt */ int decpt, sign; decpt = -1300; sign = -1300; CHECK (strcmp (qecvt (3.25L, 8, &decpt, &sign), "32500000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; CHECK (strcmp (qecvt (-7834.5L, 9, &decpt, &sign), "783450000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; CHECK (strcmp (ecvt (3.75, 8, &decpt, &sign), "37500000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; CHECK (strcmp (ecvt (-7835.5, 9, &decpt, &sign), "783550000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; CHECK (strcmp (qfcvt (3.25L, 8, &decpt, &sign), "325000000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; CHECK (strcmp (qfcvt (-7834.5L, 9, &decpt, &sign), "7834500000000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; CHECK (strcmp (fcvt (3.75, 8, &decpt, &sign), "375000000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; CHECK (strcmp (fcvt (-7835.5, 9, &decpt, &sign), "7835500000000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (qecvt_r (3.25L, 8, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "32500000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (qecvt_r (-7834.5L, 9, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "783450000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (ecvt_r (3.75, 8, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "37500000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (ecvt_r (-7835.5, 9, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "783550000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (qfcvt_r (3.25L, 8, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "325000000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (qfcvt_r (-7834.5L, 9, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "7834500000000") == 0); CHECK (decpt == 4 && sign == 1); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (fcvt_r (3.75, 8, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "375000000") == 0); CHECK (decpt == 1 && sign == 0); decpt = -1300; sign = -1300; memset (buf, 0, sizeof (buf)); CHECK (fcvt_r (-7835.5, 9, &decpt, &sign, buf, sizeof (buf)) == 0); CHECK (strcmp (buf, "7835500000000") == 0); CHECK (decpt == 4 && sign == 1); memset (buf, 0, sizeof (buf)); CHECK (qgcvt (3.251L, 3, buf) == buf); CHECK (strcmp (buf, "3.25") == 0); memset (buf, 0, sizeof (buf)); CHECK (qgcvt (7834.51L, 5, buf) == buf); CHECK (strcmp (buf, "7834.5") == 0); memset (buf, 0, sizeof (buf)); CHECK (gcvt (3.751, 3, buf) == buf); CHECK (strcmp (buf, "3.75") == 0); memset (buf, 0, sizeof (buf)); CHECK (gcvt (7835.51, 5, buf) == buf); CHECK (strcmp (buf, "7835.5") == 0); /* strfmon, strfmon_l */ /* __strfmon_l */ memset (buf, 0, sizeof (buf)); strfmon (buf, sizeof (buf), "%Ln %Ln %n %n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (buf, "$3.25 $7,834.50 $3.75 $7,835.50") == 0); memset (buf, 0, sizeof (buf)); strfmon_l (buf, sizeof (buf), loc, "%Ln %Ln %n %n", 3.25L, 7834.5L, 3.75, 7835.5); CHECK (strcmp (buf, "$3.25 $7,834.50 $3.75 $7,835.50") == 0); /* strtold, strtold_l, wcstold, wcstold_l */ /* __strtold_l, __wcstold_l, __strtold_internal, __wcstold_internal */ char *q = "1324.75"; CHECK (strtold (q, &p) == 1324.75L && p == q + 7); q = "12325,75"; CHECK (strtold_l (q, &p, loc2) == 12325.75L && p == q + 8); wchar_t *r = L"1374.25", *s; CHECK (wcstold (r, &s) == 1374.25L && s == r + 7); r = L"18374,125"; CHECK (wcstold_l (r, &s, loc2) == 18374.125L && s == r + 9); /* acoshl, acosl, asinhl, asinl, atan2l, atanhl, atanl, cabsl, cacoshl, cacosl, cargl, casinhl, casinl, catanhl, catanl, cbrtl, ccoshl, ccosl, ceill, cexpl, cimagl, clog10l, clogl, conjl, copysignl, coshl, cosl, cpowl, cprojl, creall, csinhl, csinl, csqrtl, ctanhl, ctanl, dreml, erfcl, erfl, exp10l, exp2l, expl, expm1l, fabsl, fdiml, finitel, floorl, fmal, fmaxl, fminl, fmodl, frexpl, gammal, hypotl, ilogbl, isinfl, isnanl, j0l, j1l, jnl, ldexpl, lgammal, lgammal_r, llrintl, llroundl, log10l, log1pl, log2l, logbl, logl, lrintl, lroundl, nexttoward, nexttowardf, modfl, nanl, nearbyintl, nextafterl, nexttowardl, pow10l, powl, remainderl, remquol, rintl, roundl, scalbl, scalblnl, scalbnl, significandl, sincosl, sinhl, sinl, sqrtl, tanhl, tanl, tgammal, truncl, y0l, y1l, ynl */ /* __clog10l, __finitel, __isinfl, __isnanl, __signbitl */ CHECK3 (acosh, 7.0, 2.6339); CHECK3 (acos, 0.75, 0.722734); CHECK3 (asinh, 0.75, 0.69314718); CHECK3 (asin, 0.75, 0.848062078); CHECK4 (atan2, 0.75, 1.0, 0.6435011); CHECK3 (atanh, 0.75, 0.97295507); CHECK3 (atan, 0.75, 0.6435011); CHECK3 (cabs, 0.75 + I * 1.25, 1.457737973711325); CHECKC3 (cacosh, 0.75 + I * 1.25, 1.1323936316053, 1.1175201491561); CHECKC3 (cacos, -2 + I * -3, 2.141449111115996, 1.9833870299165); CHECK3 (carg, 2.0 + I * 3.0, 0.982793723247); CHECKC3 (casinh, 0.75 + I * 1.25, 1.03171853444778, 0.91173829096849); CHECKC3 (casin, -2 + I * -3, -0.570652784321, -1.9833870299165354); CHECKC3 (catanh, 0.75 + I * 1.25, 0.26149213879567, 0.99682512646392); CHECKC3 (catan, -2 + I * -3, -1.4099210495965755, -0.229072682968539); CHECK3 (cbrt, 0.75, 0.908560296); CHECKC3 (ccosh, -2 + I * -3, -3.72454550491532, 0.5118225699873846); CHECKC3 (ccos, 0.75 + I * 1.25, 1.38173873063426, -1.09193013555397); CHECK3 (ceil, 0.25, 1.0); CHECKC3 (cexp, -2.0 + I * -3.0, -0.13398091492954, -0.019098516261135); CHECK3 (cimag, 6.5 + I * 18.5, 18.5); CHECKC3 (clog10, 0.75 + I * 1.25, 0.163679467193165, 0.447486970040493); CHECKC3 (clog, -2 + I * -3, 1.28247467873077, -2.15879893034246417); CHECKC3 (conj, 3.0 + I * -4.0, 3.0, 4.0); CHECK4 (copysign, 3.25, -5.125, -3.25); CHECK3 (cosh, 0.75, 1.29468328); CHECK3 (cos, 0.75, 0.731688868); CHECKC4 (cpow, 0.75 + I * 1.25, I * 1.0, 0.3318254391776, 0.131338600281); CHECKC3 (cproj, 2.0 + I * 3.0, 0.2857142857142857, 0.42857142857142857); CHECK3 (creal, 6.5 + I * 18.5, 6.5); CHECKC3 (csinh, 0.75 + I * 1.25, 0.25929485455116, 1.228634524095); CHECKC3 (csin, 0.75 + I * 1.25, 1.28722291002649, 1.1721063598927); CHECKC3 (csqrt, -2 + I * 3, 0.8959774761298, 1.67414922803554); CHECKC3 (ctanh, 0.75 + I * 1.25, 1.37260757053, 0.38579595260975); CHECKC3 (ctan, 0.75 + I * 1.25, 0.160807785916206, 0.9753632850312356); CHECK4 (drem, 6.2, 2.31, -0.73); CHECK3 (erfc, 2.0, 0.00467773498); CHECK3 (erf, 2.0, 0.995322265); CHECK3 (exp10, 0.75, 5.6234132519); #ifndef __NO_LONG_DOUBLE_MATH /* exp2l hasn't been exported from libm before glibc 2.4. */ CHECK3 (exp2, 0.75, 1.68179283); #endif CHECK3 (exp, 0.75, 2.1170000166); CHECK3 (expm1, 0.75, 1.1170000166); CHECK3 (fabs, -17.25, 17.25); CHECK4 (fdim, 7.9, 2.3, 5.6); CHECK (finitel (2.5L) != 0); CHECK (finitel (HUGE_VALL) == 0); CHECK (finitel ((long double) NAN) == 0); CHECK (finite (2.5) != 0); CHECK (finite (HUGE_VAL) == 0); CHECK (finite ((double) NAN) == 0); CHECK (__finitel (2.5L) != 0); CHECK (__finitel (HUGE_VALL) == 0); CHECK (__finitel ((long double) NAN) == 0); CHECK (__finite (2.5) != 0); CHECK (__finite (HUGE_VAL) == 0); CHECK (__finite ((double) NAN) == 0); CHECK3 (floor, 3.25, 3.0); CHECK5 (fma, 2.4, 4.8, 7.1, 18.62); CHECK4 (fmax, 17.8, 19.1, 19.1); CHECK4 (fmin, 17.8, 19.1, 17.8); CHECK4 (fmod, 6.2, 2.31, 1.58); i = -1; CHECK2 (frexpl (12.8L, &i), 0.8L); CHECK (i == 4); i = -1; CHECK2 (frexp (12.8, &i), 0.8); CHECK (i == 4); CHECK3 (gamma, 3, 0.6931471805599); CHECK4 (hypot, 0.7, -12.4, 12.4197423); CHECK (ilogbl (-2000.0L) == 10); CHECK (ilogb (-2000.0) == 10); CHECK (isinfl (HUGE_VALL) == 1); CHECK (isinfl (-HUGE_VALL) == -1); CHECK (isinfl (3.2L) == 0); CHECK (isinfl ((long double) NAN) == 0); CHECK (isinf (HUGE_VAL) == 1); CHECK (isinf (-HUGE_VAL) == -1); CHECK (isinf (3.2) == 0); CHECK (isinf ((double) NAN) == 0); CHECK (isnanl (HUGE_VALL) == 0); CHECK (isnanl (3.2L) == 0); CHECK (isnanl ((long double) NAN) != 0); CHECK (isnan (HUGE_VAL) == 0); CHECK (isnan (3.2) == 0); CHECK (isnan ((double) NAN) != 0); CHECK3 (j0, 0.75, 0.864242275); CHECK3 (j1, 0.75, 0.349243602); CHECK4 (jn, 3.0, 2.0, 0.12894324947); CHECK4 (ldexp, 0.8, 4, 12.8); signgam = -2; CHECK2 (lgammal (0.7L), 0.260867246531666514L); CHECK (signgam == 1); signgam = -2; CHECK2 (lgamma (0.7), 0.260867246531666514); CHECK (signgam == 1); i = -2; CHECK2 (lgammal_r (0.7L, &i), 0.260867246531666514L); CHECK (i == 1); i = -2; CHECK2 (lgamma_r (0.7, &i), 0.260867246531666514); CHECK (i == 1); CHECK3 (llrint, 1071930.0008, 1071930); CHECK3 (llround, 1071930.0008, 1071930); CHECK3 (log10, 0.75, -0.124938736608); CHECK3 (log1p, -0.25, -0.28768207245178); CHECK3 (log2, 0.75, -.4150374992788); CHECK3 (logb, -2000, 10); CHECK3 (log, 0.75, -0.28768207245); CHECK3 (lrint, 1071930.0008, 1071930); CHECK3 (lround, 1071930.0008, 1071930); CHECK4 (nexttoward, 9, 9, 9); CHECK (nexttowardf (18.f, 18.L) == 18.f); l2 = 16.0L; CHECK2 (modfl (89.5L, &l2), 0.5L); CHECK (l2 == 89.0L); d1 = 16.0; CHECK2 (modf (89.5, &d1), 0.5); CHECK (d1 == 89.0); l1 = nanl ("01234"); CHECK (isnan (l1) != 0); d1 = nan ("01234"); CHECK (isnan (d1) != 0); CHECK3 (nearbyint, 1.5, 2.0); CHECK4 (nextafter, 9, 9, 9); CHECK3 (pow10, 0.75, 5.6234132519); CHECK4 (pow, 256, 8, 0x1p64); CHECK4 (remainder, 1.625, -1.0, -0.375); i = 56; CHECK2 (remquol (-1.625L, -1.0L, &i), 0.375L); CHECK (i == 2); i = 56; CHECK2 (remquo (-1.625, -1.0, &i), 0.375); CHECK (i == 2); CHECK3 (rint, 1071930.0008, 1071930); CHECK3 (round, 1071930.0008, 1071930); CHECK4 (scalb, -0.854375, 5, -27.34); CHECK4 (scalbln, 0.8, 4, 12.8); CHECK4 (scalbn, -0.854375, 5, -27.34); CHECK (signbit (12.1L) == 0); CHECK (signbit (-18.4L) != 0); CHECK (signbit (12.1) == 0); CHECK (signbit (-18.4) != 0); CHECK3 (significand, 8.0, 1.0); sincosl (0.75L, &l1, &l2); CHECK2 (l1, 0.68163876002333417); CHECK2 (l2, 0.73168886887382088); sincos (0.75, &d1, &d2); CHECK2 (d1, 0.68163876002333417); CHECK2 (d2, 0.73168886887382088); CHECK3 (sinh, 0.75, 0.8223167319358); CHECK3 (sin, 0.75, 0.681638760023334); CHECK3 (sqrt, 0.75, 0.8660254037844386); CHECK3 (tanh, -1.0, -0.761594155955764888); CHECK3 (tan, 0.75, 0.93159645994407246); CHECK3 (tgamma, 1.2, 0.91816874239976); CHECK3 (trunc, 4294967296.625, 4294967296.0); CHECK3 (y0, 10.0, 0.05567116728); CHECK3 (y1, 10.0, 0.24901542420695); CHECK4 (yn, 10, 2.0, -129184.54220803928); } void test2 (va_list *pap, ...) { va_list ap, apl[50]; int i; va_start (ap, pap); for (i = 0; i < 50; i++) va_copy (apl[i], ap); test (apl, pap); for (i = 0; i < 50; i++) va_end (apl[i]); va_end (ap); } void test3 (int dummy, ...) { va_list ap, apl[50]; int i; va_start (ap, dummy); for (i = 0; i < 50; i++) va_copy (apl[i], ap); test2 (apl, 3.25L, 7834.5L, 3.75, 7835.5); for (i = 0; i < 50; i++) va_end (apl[i]); va_end (ap); } int main (void) { test3 (0, &l1, &l2, &d1, &d2); return failures != 0; } From jakub@redhat.com Thu Feb 2 18:59:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 02 Feb 2006 18:59:00 -0000 Subject: [PATCH] Fix math.h for C++ with -mlong-double-64 Message-ID: <20060202185900.GE4625@sunsite.mff.cuni.cz> Hi! C++ has strict rules where it wants to see throw (). 2006-02-02 Jakub Jelinek * math/math.h (__nldbl_nexttowardf): Put __THROW before __attribute__ ((__const__)). (__MATHDECL_2): Use __REDIRECT_NTH instead of __REDIRECT followed by __THROW. --- libc/math/math.h 2006-02-02 05:23:04.000000000 -0500 +++ libc/math/math.h 2006-02-02 13:54:37.000000000 -0500 @@ -103,7 +103,7 @@ __BEGIN_DECLS # ifdef __USE_ISOC99 extern float __nldbl_nexttowardf (float __x, long double __y) - __attribute__ ((__const__)) __THROW; + __THROW __attribute__ ((__const__)); # ifdef __REDIRECT_NTH extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), __nldbl_nexttowardf) @@ -118,8 +118,8 @@ extern double __REDIRECT_NTH (nexttoward # undef __MATHDECL_1 # define __MATHDECL_2(type, function,suffix, args, alias) \ - extern type __REDIRECT(__MATH_PRECNAME(function,suffix), \ - args, alias) __THROW + extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \ + args, alias) # define __MATHDECL_1(type, function,suffix, args) \ __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix)) # endif Jakub From jakub@redhat.com Fri Feb 3 13:51:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 03 Feb 2006 13:51:00 -0000 Subject: [PATCH] Fix stdlib-ldbl.h Message-ID: <20060203135109.GF4625@sunsite.mff.cuni.cz> Hi! qecvt etc. are prototyped #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED ... # ifdef __USE_MISC ... qecvt (...); # endif #endif so the __LDBL_REDIR1_DECL has to match that. This broke emacs build with -mlong-double-64. 2006-02-03 Jakub Jelinek * stdlib/bits/stdlib-ldbl.h (qecvt, qfcvt, qgcvt, qecvt_r, qfcvt_r): Guard with #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED. --- libc/stdlib/bits/stdlib-ldbl.h 2006-01-14 21:14:36.000000000 +0100 +++ libc/stdlib/bits/stdlib-ldbl.h 2006-02-03 10:46:07.000000000 +0100 @@ -33,10 +33,12 @@ __LDBL_REDIR1_DECL (strtold_l, strtod_l) __LDBL_REDIR1_DECL (__strtold_internal, __strtod_internal) -#ifdef __USE_MISC +#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED +# ifdef __USE_MISC __LDBL_REDIR1_DECL (qecvt, ecvt) __LDBL_REDIR1_DECL (qfcvt, fcvt) __LDBL_REDIR1_DECL (qgcvt, gcvt) __LDBL_REDIR1_DECL (qecvt_r, ecvt_r) __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r) +# endif #endif Jakub From jakub@redhat.com Fri Feb 3 22:17:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 03 Feb 2006 22:17:00 -0000 Subject: [PATCH] Fix powerpc inline fegetround Message-ID: <20060203221722.GG4625@sunsite.mff.cuni.cz> Hi! GCC 4.1 seems to be optimizing more aggressively and on powerpc32 in test-i{float,double,ldoubl} happens to move over inlined fegetround () across fesetround call (not inlined), which results in not the saved, but the new rounding mode being restored, so many tests fail. The following patch fixes that, make check is clean again. 2006-02-03 Jakub Jelinek * sysdeps/powerpc/fpu/bits/fenvinline.h (fegetround): Make asm volatile. --- libc/sysdeps/powerpc/fpu/bits/fenvinline.h.jj 2001-07-06 06:56:02.000000000 +0200 +++ libc/sysdeps/powerpc/fpu/bits/fenvinline.h 2006-02-03 23:12:18.000000000 +0100 @@ -1,5 +1,6 @@ /* Inline floating-point environment handling functions for powerpc. - Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,8 +23,9 @@ /* Inline definition for fegetround. */ # define fegetround() \ (__extension__ ({ int __fegetround_result; \ - __asm__ ("mcrfs 7,7 ; mfcr %0" \ - : "=r"(__fegetround_result) : : "cr7"); \ + __asm__ __volatile__ \ + ("mcrfs 7,7 ; mfcr %0" \ + : "=r"(__fegetround_result) : : "cr7"); \ __fegetround_result & 3; })) /* The weird 'i#*X' constraints on the following suppress a gcc Jakub From drepper@redhat.com Sat Feb 4 07:14:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 04 Feb 2006 07:14:00 -0000 Subject: snprintf documentation fix In-Reply-To: <43D71150.7080002@m17n.org> References: <43D71150.7080002@m17n.org> Message-ID: <43E454CE.7090704@redhat.com> NIIBE Yutaka wrote: > I found a bug in the example code of snprintf in the documentation. Patch applied. -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From munroesj@us.ibm.com Mon Feb 6 23:12:00 2006 From: munroesj@us.ibm.com (Steven Munroe) Date: Mon, 06 Feb 2006 23:12:00 -0000 Subject: [Fwd: Re: Enforcing gcc-4.1 for Powerpc -mlong-double-128] Message-ID: <43E7D9DB.3080408@us.ibm.com> I have verifed that gcc-4.0 builds powerpc64 with -mlong-double-128. So if we need to enforce a minimum gcc level for long double we can use gcc-4.0. -------------- next part -------------- An embedded message was scrubbed... From: Steven Munroe Subject: Re: Enforcing gcc-4.1 for Powerpc -mlong-double-128 Date: Wed, 01 Feb 2006 11:45:51 -0600 Size: 1056 URL: From munroesj@us.ibm.com Tue Feb 7 16:28:00 2006 From: munroesj@us.ibm.com (Steven Munroe) Date: Tue, 07 Feb 2006 16:28:00 -0000 Subject: remaining ppc problems In-Reply-To: <43C0B205.9030802@redhat.com> References: <43C0B205.9030802@redhat.com> Message-ID: <43E8CCAE.10209@us.ibm.com> Ulrich Drepper wrote: >I've seen for a long time now problems in test-fenv. > >Test: after fesetenv (FE_NOMASK_ENV) processes will abort > when feraiseexcept (FE_DIVBYZERO) is called. > Fail: Process didn't receive signal and exited with status 512. > > Paul Mackerras posted a kernel patch for this problem to lkml today. From drepper@redhat.com Tue Feb 7 18:00:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 07 Feb 2006 18:00:00 -0000 Subject: remaining ppc problems In-Reply-To: <43E8CCAE.10209@us.ibm.com> References: <43C0B205.9030802@redhat.com> <43E8CCAE.10209@us.ibm.com> Message-ID: <43E8E018.1050901@redhat.com> Steven Munroe wrote: > Paul Mackerras posted a kernel patch for this problem to lkml today. I don't see it. What's the subject? And was it really sent to lkml? -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Wed Feb 8 10:30:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 08 Feb 2006 10:30:00 -0000 Subject: [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid Message-ID: <20060208102954.GH4625@sunsite.mff.cuni.cz> Hi! All other arches except i?86 have "memory" clobber in lll_futex_wait etc. (be it through INTERNAL_SYSCALL or explicitly). These macros are only used a handful time in generic code (and never in i?86 specific code) and in a big portion of those places in tight loops, without an explicit memory clobber anywhere. The syscall itself I guess servers as a CPU memory barrier, so all we need is a barrier to tell GCC not to optimize things accross it. At least 2 places are miscompiled because of this: 1) unregister_atfork (say with GCC 4.1.0pre current CVS glibc): d40c0: f0 ff 48 14 lock decl 0x14(%eax) d40c4: 8b 50 14 mov 0x14(%eax),%edx d40c7: 85 d2 test %edx,%edx d40c9: 74 22 je d40ed <__unregister_atfork+0xed> d40cb: 8d 78 14 lea 0x14(%eax),%edi d40ce: 31 f6 xor %esi,%esi d40d0: b8 f0 00 00 00 mov $0xf0,%eax d40d5: 89 f1 mov %esi,%ecx d40d7: 87 fb xchg %edi,%ebx d40d9: 65 ff 15 10 00 00 00 call *%gs:0x10 d40e0: 87 fb xchg %edi,%ebx d40e2: eb ec jmp d40d0 <__unregister_atfork+0xd0> (note the endless loop) 2) start_thread: 52b8: 8b 45 b8 mov 0xffffffb8(%ebp),%eax 52bb: f6 40 5c 40 testb $0x40,0x5c(%eax) 52bf: 75 44 jne 5305 ... 5305: 31 d2 xor %edx,%edx 5307: 89 c7 mov %eax,%edi 5309: 81 c7 e8 01 00 00 add $0x1e8,%edi 530f: 31 f6 xor %esi,%esi 5311: b8 f0 00 00 00 mov $0xf0,%eax 5316: 89 f1 mov %esi,%ecx 5318: 87 fb xchg %edi,%ebx 531a: 65 ff 15 10 00 00 00 call *%gs:0x10 5321: 87 fb xchg %edi,%ebx 5323: eb ec jmp 5311 (likewise) 2006-02-08 Jakub Jelinek * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait, lll_futex_timedwait, lll_wait_tid): Add "memory" clobber. --- libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h.jj 2006-01-06 06:01:25.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h 2006-02-08 11:12:25.000000000 +0100 @@ -75,7 +75,8 @@ : "=a" (__status) \ : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (0), \ "c" (FUTEX_WAIT), "d" (_val), \ - "i" (offsetof (tcbhead_t, sysinfo))); \ + "i" (offsetof (tcbhead_t, sysinfo)) \ + : "memory"); \ __status; \ }) @@ -90,7 +91,8 @@ : "=a" (__status) \ : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \ "c" (FUTEX_WAIT), "d" (_val), \ - "i" (offsetof (tcbhead_t, sysinfo))); \ + "i" (offsetof (tcbhead_t, sysinfo)) \ + : "memory"); \ __status; \ }) @@ -346,7 +348,8 @@ extern int lll_unlock_wake_cb (int *__fu : "=&a" (__ignore) \ : "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \ "c" (FUTEX_WAIT), "d" (_tid), \ - "i" (offsetof (tcbhead_t, sysinfo))); \ + "i" (offsetof (tcbhead_t, sysinfo)) \ + : "memory"); \ } while (0) extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) Jakub From drepper@redhat.com Wed Feb 8 15:51:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 08 Feb 2006 15:51:00 -0000 Subject: [PATCH] Fix i?86 lll_futex_{,timed_}wait and lll_wait_tid In-Reply-To: <20060208102954.GH4625@sunsite.mff.cuni.cz> References: <20060208102954.GH4625@sunsite.mff.cuni.cz> Message-ID: <43EA1404.7030904@redhat.com> Applied. -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Mon Feb 13 13:02:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 13 Feb 2006 13:02:00 -0000 Subject: [PATCH] glibc build fixes Message-ID: <20060213130201.GI4625@sunsite.mff.cuni.cz> Hi! With this I got glibc to build again on the 7 arches I did the build on. 2006-02-13 Jakub Jelinek * sysdeps/unix/sysv/linux/not-cancel.h (__openat_not_cancel, __openat64_not_cancel): Remove prototypes. (__openat_nocancel, __openat64_nocancel): New prototypes or defines. (openat_not_cancel, openat_not_cancel_3, openat64_not_cancel, openat64_not_cancel_3): Use them. nptl/ * descr.h [!__PTHREAD_MUTEX_HAVE_PREV] (DEQUEUE_MUTEX): Set robust_list.__next rather than robust_list. * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (__pthread_list_t): New typedef. (pthread_mutex_t): Replace __next and __prev fields with __list. * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h (__pthread_list_t): New typedef. (pthread_mutex_t): Replace __next and __prev fields with __list. * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (__pthread_list_t, __pthread_slist_t): New typedefs. (pthread_mutex_t): Replace __next and __prev fields with __list. * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (__pthread_list_t, __pthread_slist_t): New typedefs. (pthread_mutex_t): Replace __next and __prev fields with __list. * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h (__pthread_list_t, __pthread_slist_t): New typedefs. (pthread_mutex_t): Replace __next and __prev fields with __list. * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (__pthread_slist_t): New typedef. (pthread_mutex_t): Replace __next field with __list. --- libc/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h 30 Jan 2006 09:29:48 -0000 1.7.2.4 +++ libc/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -43,6 +43,13 @@ typedef union } pthread_attr_t; +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; + + /* Data structures for mutex handling. The structure of the attribute type is deliberately not exposed. */ typedef union @@ -57,8 +64,7 @@ typedef union binary compatibility. */ int __kind; int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; + __pthread_list_t __list; #define __PTHREAD_MUTEX_HAVE_PREV 1 } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; --- libc/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h 6 Jan 2006 21:55:55 -0000 1.13.2.3 +++ libc/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -43,6 +43,13 @@ typedef union } pthread_attr_t; +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; + + /* Data structures for mutex handling. The structure of the attribute type is not exposed on purpose. */ typedef union @@ -57,8 +64,7 @@ typedef union binary compatibility. */ int __kind; int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; + __pthread_list_t __list; #define __PTHREAD_MUTEX_HAVE_PREV 1 } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; --- libc/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h 9 Jan 2006 21:54:59 -0000 1.14.2.4 +++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -58,6 +58,20 @@ typedef union } pthread_attr_t; +#if __WORDSIZE == 64 +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; +#else +typedef struct __pthread_internal_slist +{ + struct __pthread_internal_slist *__next; +} __pthread_slist_t; +#endif + + /* Data structures for mutex handling. The structure of the attribute type is deliberately not exposed. */ typedef union @@ -75,15 +89,14 @@ typedef union int __kind; #if __WORDSIZE == 64 int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; + __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 #else unsigned int __nusers; __extension__ union { int __spins; - struct __pthread_mutex_s *__next; + __pthread_slist_t __list; }; #endif } __data; --- libc/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h 9 Jan 2006 21:54:59 -0000 1.13.2.4 +++ libc/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -57,6 +57,20 @@ typedef union } pthread_attr_t; +#if __WORDSIZE == 64 +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; +#else +typedef struct __pthread_internal_slist +{ + struct __pthread_internal_slist *__next; +} __pthread_slist_t; +#endif + + /* Data structures for mutex handling. The structure of the attribute type is not exposed on purpose. */ typedef union @@ -74,15 +88,14 @@ typedef union int __kind; #if __WORDSIZE == 64 int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; + __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 #else unsigned int __nusers; __extension__ union { int __spins; - struct __pthread_mutex_s *__next; + __pthread_slist_t __list; }; #endif } __data; --- libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h 30 Jan 2006 09:29:48 -0000 1.10.2.4 +++ libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -44,6 +44,12 @@ typedef union } pthread_attr_t; +typedef struct __pthread_internal_slist +{ + struct __pthread_internal_slist *__next; +} __pthread_slist_t; + + /* Data structures for mutex handling. The structure of the attribute type is not exposed on purpose. */ typedef union @@ -60,7 +66,7 @@ typedef union __extension__ union { int __spins; - struct __pthread_mutex_s *__next; + __pthread_slist_t __list; }; } __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; --- libc/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h 30 Jan 2006 09:29:48 -0000 1.7.2.4 +++ libc/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h 13 Feb 2006 08:18:12 -0000 @@ -58,6 +58,20 @@ typedef union } pthread_attr_t; +#if __WORDSIZE == 64 +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; +#else +typedef struct __pthread_internal_slist +{ + struct __pthread_internal_slist *__next; +} __pthread_slist_t; +#endif + + /* Data structures for mutex handling. The structure of the attribute type is deliberately not exposed. */ typedef union @@ -75,15 +89,14 @@ typedef union int __kind; #if __WORDSIZE == 64 int __spins; - struct __pthread_mutex_s *__next; - struct __pthread_mutex_s *__prev; + __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 #else unsigned int __nusers; __extension__ union { int __spins; - struct __pthread_mutex_s *__next; + __pthread_slist_t __list; }; #endif } __data; --- libc/nptl/descr.h 13 Feb 2006 07:30:04 -0000 1.23.2.10 +++ libc/nptl/descr.h 13 Feb 2006 09:52:50 -0000 @@ -166,7 +166,7 @@ struct pthread do { \ __pthread_slist_t *runp = THREAD_GETMEM (THREAD_SELF, robust_list.__next);\ if (runp == &mutex->__data.__list) \ - THREAD_SETMEM (THREAD_SELF, robust_list, runp->__next); \ + THREAD_SETMEM (THREAD_SELF, robust_list.__next, runp->__next); \ else \ { \ while (runp->__next != &mutex->__data.__list) \ --- libc/sysdeps/unix/sysv/linux/not-cancel.h 13 Feb 2006 07:30:05 -0000 1.5.2.1 +++ libc/sysdeps/unix/sysv/linux/not-cancel.h 13 Feb 2006 09:52:50 -0000 @@ -28,18 +28,26 @@ INLINE_SYSCALL (open, 2, (const char *) (name), (flags)) /* Uncancelable openat. */ -extern int __openat_not_cancel (int fd, const char *fname, int oflag, +#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt +extern int __openat_nocancel (int fd, const char *fname, int oflag, + mode_t mode) attribute_hidden; +extern int __openat64_nocancel (int fd, const char *fname, int oflag, mode_t mode) attribute_hidden; +#else +# define __openat_nocancel(fd, fname, oflag, mode) \ + openat (fd, fname, oflag, mode) +# define __openat64_nocancel(fd, fname, oflag, mode) \ + openat64 (fd, fname, oflag, mode) +#endif + #define openat_not_cancel(fd, fname, oflag, mode) \ - __openat_not_cancel (fd, fname, oflag, mode) + __openat_nocancel (fd, fname, oflag, mode) #define openat_not_cancel_3(fd, fname, oflag) \ - __openat_not_cancel (fd, fname, oflag, 0) -extern int __openat64_not_cancel (int fd, const char *fname, int oflag, - mode_t mode) attribute_hidden; + __openat_nocancel (fd, fname, oflag, 0) #define openat64_not_cancel(fd, fname, oflag, mode) \ - __openat64_not_cancel (fd, fname, oflag, mode) + __openat64_nocancel (fd, fname, oflag, mode) #define openat64_not_cancel_3(fd, fname, oflag) \ - __openat64_not_cancel (fd, fname, oflag, 0) + __openat64_nocancel (fd, fname, oflag, 0) /* Uncancelable close. */ #define close_not_cancel(fd) \ Jakub From drepper@redhat.com Wed Feb 15 17:20:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 15 Feb 2006 17:20:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <20060213130201.GI4625@sunsite.mff.cuni.cz> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> Message-ID: <43F362D1.80207@redhat.com> Applied. But with the changes I checked in before all archs but x86 and x86-64 are broken again. Somebody needs to write the generic lowlevelrobustlock.c file and adjust the lowlevellock.h files. -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From kkojima@rr.iij4u.or.jp Fri Feb 17 13:27:00 2006 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Fri, 17 Feb 2006 13:27:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <43F362D1.80207@redhat.com> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> <43F362D1.80207@redhat.com> Message-ID: <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> > Applied. But with the changes I checked in before all archs but x86 and > x86-64 are broken again. Somebody needs to write the generic > lowlevelrobustlock.c file and adjust the lowlevellock.h files. Here is a patch for SH to add *_robust_mutex_* stuff. It's tested only with "make -k check" with no new failures. Regards, kaz -- nplt/ChangeLog 2006-02-17 Kaz Kojima * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Add lll_robust_mutex_* definitions. * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S: New file. diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h --- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h 2006-01-21 07:09:32.000000000 +0900 +++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h 2006-02-17 17:07:33.000000000 +0900 @@ -62,6 +62,28 @@ extern int __lll_mutex_unlock_wake (int : "r0", "r1", "r2", "t", "memory"); \ __result; }) +#define lll_robust_mutex_trylock(futex, id) \ + ({ unsigned char __result; \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + nop\n\ + mov r15,r1\n\ + mov #-8,r15\n\ + 0: mov.l @%1,r2\n\ + cmp/eq r2,%3\n\ + bf 1f\n\ + mov.l %2,@%1\n\ + 1: mov r1,r15\n\ + mov #-1,%0\n\ + negc %0,%0"\ + : "=r" (__result) \ + : "r" (&(futex)), \ + "r" (id), \ + "r" (LLL_MUTEX_LOCK_INITIALIZER) \ + : "r0", "r1", "r2", "t", "memory"); \ + __result; }) + #define lll_mutex_cond_trylock(futex) \ ({ unsigned char __result; \ __asm __volatile ("\ @@ -102,6 +124,25 @@ extern int __lll_mutex_unlock_wake (int if (__result) \ __lll_mutex_lock_wait (__result, __futex); }) +#define lll_robust_mutex_lock(futex, id) \ + ({ int __result, val, *__futex = &(futex); \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + nop\n\ + mov r15,r1\n\ + mov #-8,r15\n\ + 0: mov.l @%2,%0\n\ + tst %0,%0\n\ + bf 1f\n\ + mov.l %1,@%2\n\ + 1: mov r1,r15"\ + : "=&r" (__result) : "r" (id), "r" (__futex) \ + : "r0", "r1", "t", "memory"); \ + if (__result) \ + __result = __lll_robust_mutex_lock_wait (__result, __futex); \ + __result; }) + /* Special version of lll_mutex_lock which causes the unlock function to always wakeup waiters. */ #define lll_mutex_cond_lock(futex) \ @@ -122,6 +163,25 @@ extern int __lll_mutex_unlock_wake (int if (__result) \ __lll_mutex_lock_wait (__result, __futex); }) +#define lll_robust_mutex_cond_lock(futex, id) \ + ({ int __result, val, *__futex = &(futex); \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + nop\n\ + mov r15,r1\n\ + mov #-8,r15\n\ + 0: mov.l @%2,%0\n\ + tst %0,%0\n\ + bf 1f\n\ + mov.l %1,@%2\n\ + 1: mov r1,r15"\ + : "=&r" (__result) : "r" (id | FUTEX_WAITERS), "r" (__futex) \ + : "r0", "r1", "t", "memory"); \ + if (__result) \ + __result = __lll_robust_mutex_lock_wait (__result, __futex); \ + __result; }) + #define lll_mutex_timedlock(futex, timeout) \ ({ int __result, val, *__futex = &(futex); \ __asm __volatile ("\ @@ -141,6 +201,26 @@ extern int __lll_mutex_unlock_wake (int __result = __lll_mutex_timedlock_wait (__result, __futex, timeout); \ __result; }) +#define lll_robust_mutex_timedlock(futex, timeout, id) \ + ({ int __result, val, *__futex = &(futex); \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + nop\n\ + mov r15,r1\n\ + mov #-8,r15\n\ + 0: mov.l @%2,%0\n\ + tst %0,%0\n\ + bf 1f\n\ + mov.l %1,@%2\n\ + 1: mov r1,r15"\ + : "=&r" (__result) : "r" (id), "r" (__futex) \ + : "r0", "r1", "t", "memory"); \ + if (__result) \ + __result = __lll_robust_mutex_timedlock_wait (__result, __futex, \ + timeout); \ + __result; }) + #define lll_mutex_unlock(futex) \ (void) ({ int __result, *__futex = &(futex); \ __asm __volatile ("\ @@ -157,6 +237,37 @@ extern int __lll_mutex_unlock_wake (int if (__result) \ __lll_mutex_unlock_wake (__futex); }) +#define lll_robust_mutex_unlock(futex) \ + (void) ({ int __result, *__futex = &(futex); \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + mov r15,r1\n\ + mov #-6,r15\n\ + 0: mov.l @%1,%0\n\ + and %2,%0\n\ + mov.l %0,@%1\n\ + 1: mov r1,r15"\ + : "=&r" (__result) : "r" (__futex), "r" (FUTEX_TID_MASK) \ + : "r0", "r1", "memory"); \ + if (__result) \ + __lll_mutex_unlock_wake (__futex); }) + +#define lll_robust_mutex_dead(futex) \ + (void) ({ int __ignore, *__futex = &(futex); \ + __asm __volatile ("\ + .align 2\n\ + mova 1f,r0\n\ + mov r15,r1\n\ + mov #-6,r15\n\ + 0: mov.l @%1,%0\n\ + or %2,%0\n\ + mov.l %0,@%1\n\ + 1: mov r1,r15"\ + : "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \ + : "r0", "r1", "memory"); \ + lll_futex_wake (__futex, 1); }) + #define lll_mutex_islocked(futex) \ (futex != 0) diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S --- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S 1970-01-01 09:00:00.000000000 +0900 +++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S 2006-02-17 17:23:47.000000000 +0900 @@ -0,0 +1,224 @@ +/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 "lowlevel-atomic.h" + + .text + +#define SYS_gettimeofday __NR_gettimeofday +#define SYS_futex 240 +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 +#define FUTEX_WAITERS 0x80000000 +#define FUTEX_OWNER_DIED 0x40000000 + + + .globl __lll_robust_mutex_lock_wait + .type __lll_robust_mutex_lock_wait,@function + .hidden __lll_robust_mutex_lock_wait + .align 5 + cfi_startproc +__lll_robust_mutex_lock_wait: + mov.l r8, @-r15 + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r8, 0) + mov r5, r8 + mov #0, r7 /* No timeout. */ + mov #FUTEX_WAIT, r5 + +4: + mov r4, r6 + mov.l .L_FUTEX_WAITERS, r0 + or r0, r6 + shlr r0 /* r0 = FUTEX_OWNER_DIED */ + tst r0, r4 + bf/s 3f + cmp/eq r4, r6 + bt 1f + + CMPXCHG (r4, @r8, r6, r2) + bf 2f + +1: + mov r8, r4 + mov #SYS_futex, r3 + extu.b r3, r3 + trapa #0x14 + SYSCALL_INST_PAD + + mov.l @r8, r2 + +2: + tst r2, r2 + bf/s 4b + mov r2, r4 + + stc gbr, r1 + mov.w .Ltidoff, r2 + add r2, r1 + mov.l @r1, r6 + mov #0, r3 + CMPXCHG (r3, @r8, r6, r4) + bf 4b + mov #0, r4 + +3: + mov.l @r15+, r8 + ret + mov r4, r0 + cfi_endproc + .align 2 +.L_FUTEX_WAITERS: + .long FUTEX_WAITERS +.Ltidoff: + .word TID - TLS_PRE_TCB_SIZE + .size __lll_robust_mutex_lock_wait,.-__lll_robust_mutex_lock_wait + + + .globl __lll_robust_mutex_timedlock_wait + .type __lll_robust_mutex_timedlock_wait,@function + .hidden __lll_robust_mutex_timedlock_wait + .align 5 + cfi_startproc +__lll_robust_mutex_timedlock_wait: + /* Check for a valid timeout value. */ + mov.l @(4,r6), r1 + mov.l .L1g, r0 + cmp/hs r0, r1 + bt 3f + + mov.l r10, @-r15 + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r10, 0) + mov.l r9, @-r15 + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r9, 0) + mov.l r8, @-r15 + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r8, 0) + mov r4, r10 + mov r6, r9 + mov r5, r8 + + /* Stack frame for the timespec and timeval structs. */ + add #-8, r15 + cfi_adjust_cfa_offset(8) + +1: + /* Get current time. */ + mov r15, r4 + mov #0, r5 + mov #SYS_gettimeofday, r3 + trapa #0x12 + SYSCALL_INST_PAD + + /* Compute relative timeout. */ + mov.l @(4,r15), r0 + mov.w .L1k, r1 + dmulu.l r0, r1 /* Micro seconds to nano seconds. */ + mov.l @r9, r2 + mov.l @(4,r9), r3 + mov.l @r15, r0 + sts macl, r1 + sub r0, r2 + clrt + subc r1, r3 + bf 4f + mov.l .L1g, r1 + add r1, r3 + add #-1, r2 +4: + cmp/pz r2 + bf 8f /* Time is already up. */ + + mov.l r2, @r15 /* Store relative timeout. */ + mov.l r3, @(4,r15) + + mov r10, r6 + mov.l .L_FUTEX_WAITERS2, r0 + or r0, r6 + shlr r0 /* r0 = FUTEX_OWNER_DIED */ + tst r0, r4 + bf/s 6f + cmp/eq r4, r6 + bt 2f + + CMPXCHG (r4, @r8, r6, r2) + bf/s 5f + mov #0, r5 + +2: + mov r8, r4 + mov #FUTEX_WAIT, r5 + mov r10, r6 + mov r15, r7 + mov #SYS_futex, r3 + extu.b r3, r3 + trapa #0x14 + SYSCALL_INST_PAD + mov r0, r5 + + mov.l @r8, r2 + +5: + tst r2, r2 + bf/s 7f + mov r2, r10 + + stc gbr, r1 + mov.w .Ltidoff2, r2 + add r2, r1 + mov.l @r1, r4 + mov #0, r3 + CMPXCHG (r3, @r8, r4, r10) + bf 7f + mov #0, r0 + +6: + add #8, r15 + mov.l @r15+, r8 + mov.l @r15+, r9 + rts + mov.l @r15+, r10 + +7: + /* Check whether the time expired. */ + mov #-ETIMEDOUT, r1 + cmp/eq r5, r1 + bf 1b + +8: + bra 6b + mov #ETIMEDOUT, r0 +3: + rts + mov #EINVAL, r0 + cfi_endproc + .align 2 +.L_FUTEX_WAITERS2: + .long FUTEX_WAITERS +.L1g: + .long 1000000000 +.Ltidoff2: + .word TID - TLS_PRE_TCB_SIZE +.L1k: + .word 1000 + .size __lll_robust_mutex_timedlock_wait,.-__lll_robust_mutex_timedlock_wait From drepper@redhat.com Fri Feb 17 15:37:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 17 Feb 2006 15:37:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> <43F362D1.80207@redhat.com> <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> Message-ID: <43F5EDB6.9040909@redhat.com> Thanks, applied. -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Fri Feb 17 16:08:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 17 Feb 2006 16:08:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> <43F362D1.80207@redhat.com> <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> Message-ID: <20060217160814.GQ4625@sunsite.mff.cuni.cz> On Fri, Feb 17, 2006 at 10:27:47PM +0900, Kaz Kojima wrote: > > Applied. But with the changes I checked in before all archs but x86 and > > x86-64 are broken again. Somebody needs to write the generic > > lowlevelrobustlock.c file and adjust the lowlevellock.h files. > > Here is a patch for SH to add *_robust_mutex_* stuff. It's tested > only with "make -k check" with no new failures. And here it is for ppc*/s390*/ia64/alpha, so far tested on ppc64 only. sparc* not done yet, as although sparcv9/sparc64 is easy, sparc32 pre-v9 will be much harder (and probably will need to never register the robust list with kernel, so on 32-bit sparc kernels the only robustness guaranteed will be if a thread is cancelled, but not if it crashes). 2006-02-17 Jakub Jelinek * include/atomic.h (atomic_and, atomic_or): Define. nptl/ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_mutex_dead, lll_robust_mutex_trylock, lll_robust_mutex_lock, lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock, lll_robust_mutex_unlock): New macros. (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes. * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: New file. --- libc/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h 2006-02-17 16:55:38.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -64,6 +64,15 @@ INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + int *__futexp = &(futexv); \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + lll_futex_wake (__futexp, 1); \ + } \ + while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \ ({ \ @@ -106,7 +115,16 @@ __lll_mutex_cond_trylock(int *futex) #define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock)) +static inline int __attribute__((always_inline)) +__lll_robust_mutex_trylock(int *futex, int id) +{ + return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0; +} +#define lll_robust_mutex_trylock(lock, id) \ + __lll_robust_mutex_trylock (&(lock), id) + extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; static inline void __attribute__((always_inline)) __lll_mutex_lock(int *futex) @@ -117,6 +135,18 @@ __lll_mutex_lock(int *futex) #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +static inline int __attribute__ ((always_inline)) +__lll_robust_mutex_lock (int *futex, int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_lock_wait (futex); + return result; +} +#define lll_robust_mutex_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), id) + + static inline void __attribute__ ((always_inline)) __lll_mutex_cond_lock (int *futex) { @@ -126,8 +156,14 @@ __lll_mutex_cond_lock (int *futex) #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) + attribute_hidden; static inline int __attribute__ ((always_inline)) __lll_mutex_timedlock (int *futex, const struct timespec *abstime) @@ -141,6 +177,19 @@ __lll_mutex_timedlock (int *futex, const __lll_mutex_timedlock (&(futex), abstime) +static inline int __attribute__ ((always_inline)) +__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime, + int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_timedlock_wait (futex, abstime); + return result; +} +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + + static inline void __attribute__ ((always_inline)) __lll_mutex_unlock (int *futex) { @@ -152,6 +201,16 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) +__lll_robust_mutex_unlock (int *futex) +{ + int val = atomic_exchange_rel (futex, 0); + if (__builtin_expect (val & FUTEX_WAITERS, 0)) + lll_futex_wake (futex, 1); +} +#define lll_robust_mutex_unlock(futex) __lll_robust_mutex_unlock(&(futex)) + + +static inline void __attribute__ ((always_inline)) __lll_mutex_unlock_force (int *futex) { (void) atomic_exchange_rel (futex, 0); --- libc/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h 2006-02-17 16:57:18.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky , 2003. @@ -85,6 +85,17 @@ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + int *__futexp = &(futexv); \ + \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + lll_futex_wake (__futexp, 1); \ + } \ + while (0) + + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futex, nr_wake, nr_move, mutex, val) \ ({ \ @@ -167,7 +178,23 @@ __lll_mutex_cond_trylock (int *futex) #define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_trylock (int *futex, int id) +{ + unsigned int old; + + __asm __volatile ("cs %0,%3,%1" + : "=d" (old), "=Q" (*futex) + : "0" (0), "d" (id), "m" (*futex) : "cc", "memory" ); + return old != 0; +} +#define lll_robust_mutex_trylock(futex, id) \ + __lll_robust_mutex_trylock (&(futex), id) + + extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; static inline void __attribute__ ((always_inline)) @@ -178,6 +205,17 @@ __lll_mutex_lock (int *futex) } #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_lock (int *futex, int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_lock_wait (futex); + return result; +} +#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) + static inline void __attribute__ ((always_inline)) __lll_mutex_cond_lock (int *futex) @@ -187,8 +225,13 @@ __lll_mutex_cond_lock (int *futex) } #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS) + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait + (int *futex, const struct timespec *) attribute_hidden; static inline int __attribute__ ((always_inline)) @@ -202,6 +245,19 @@ __lll_mutex_timedlock (int *futex, const #define lll_mutex_timedlock(futex, abstime) \ __lll_mutex_timedlock (&(futex), abstime) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime, + int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_timedlock_wait (futex, abstime); + return result; +} +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + static inline void __attribute__ ((always_inline)) @@ -220,6 +276,21 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) +__lll_robust_mutex_unlock (int *futex) +{ + int oldval; + int newval = 0; + + lll_compare_and_swap (futex, oldval, newval, "slr %2,%2"); + if (oldval & FUTEX_WAITERS) + lll_futex_wake (futex, 1); +} +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex)) + + +static inline void +__attribute__ ((always_inline)) __lll_mutex_unlock_force (int *futex) { *futex = 0; --- libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h 2006-02-17 14:36:19.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras , 2003. @@ -69,6 +69,17 @@ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + INTERNAL_SYSCALL_DECL (__err); \ + int *__futexp = &(futexv); \ + \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + INTERNAL_SYSCALL (futex, __err, 4, __futexp, FUTEX_WAKE, 1, 0); \ + } \ + while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \ ({ \ @@ -102,8 +113,8 @@ # define __lll_rel_instr "sync" #endif -/* Set *futex to 1 if it is 0, atomically. Returns the old value */ -#define __lll_trylock(futex) \ +/* Set *futex to ID if it is 0, atomically. Returns the old value */ +#define __lll_robust_trylock(futex, id) \ ({ int __val; \ __asm __volatile ("1: lwarx %0,0,%2\n" \ " cmpwi 0,%0,0\n" \ @@ -112,31 +123,26 @@ " bne- 1b\n" \ "2: " __lll_acq_instr \ : "=&r" (__val), "=m" (*futex) \ - : "r" (futex), "r" (1), "m" (*futex) \ + : "r" (futex), "r" (id), "m" (*futex) \ : "cr0", "memory"); \ __val; \ }) +#define lll_robust_mutex_trylock(lock, id) __lll_robust_trylock (&(lock), id) + +/* Set *futex to 1 if it is 0, atomically. Returns the old value */ +#define __lll_trylock(futex) __lll_robust_trylock (futex, 1) + #define lll_mutex_trylock(lock) __lll_trylock (&(lock)) /* Set *futex to 2 if it is 0, atomically. Returns the old value */ -#define __lll_cond_trylock(futex) \ - ({ int __val; \ - __asm __volatile ("1: lwarx %0,0,%2\n" \ - " cmpwi 0,%0,0\n" \ - " bne 2f\n" \ - " stwcx. %3,0,%2\n" \ - " bne- 1b\n" \ - "2: " __lll_acq_instr \ - : "=&r" (__val), "=m" (*futex) \ - : "r" (futex), "r" (2), "m" (*futex) \ - : "cr0", "memory"); \ - __val; \ - }) +#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2) + #define lll_mutex_cond_trylock(lock) __lll_cond_trylock (&(lock)) extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; #define lll_mutex_lock(lock) \ (void) ({ \ @@ -146,6 +152,16 @@ extern void __lll_lock_wait (int *futex) __lll_lock_wait (__futex); \ }) +#define lll_robust_mutex_lock(lock, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) + #define lll_mutex_cond_lock(lock) \ (void) ({ \ int *__futex = &(lock); \ @@ -154,8 +170,22 @@ extern void __lll_lock_wait (int *futex) __lll_lock_wait (__futex); \ }) +#define lll_robust_mutex_cond_lock(lock, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + int __id = id | FUTEX_WAITERS; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, __id,\ + 0), 0)) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait + (int *futex, const struct timespec *) attribute_hidden; #define lll_mutex_timedlock(lock, abstime) \ ({ \ @@ -167,6 +197,16 @@ extern int __lll_timedlock_wait __val; \ }) +#define lll_robust_mutex_timedlock(lock, abstime, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_timedlock_wait (__futex, abstime); \ + __val; \ + }) + #define lll_mutex_unlock(lock) \ ((void) ({ \ int *__futex = &(lock); \ @@ -175,6 +215,14 @@ extern int __lll_timedlock_wait lll_futex_wake (__futex, 1); \ })) +#define lll_robust_mutex_unlock(lock) \ + ((void) ({ \ + int *__futex = &(lock); \ + int __val = atomic_exchange_rel (__futex, 0); \ + if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + lll_futex_wake (__futex, 1); \ + })) + #define lll_mutex_unlock_force(lock) \ ((void) ({ \ int *__futex = &(lock); \ --- libc/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h 2006-02-17 15:31:59.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -55,6 +55,15 @@ _r10 == -1 ? -_retval : _retval; \ }) +#define lll_robust_mutex_dead(futexv) \ +do \ + { \ + int *__futexp = &(futexv); \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + DO_INLINE_SYSCALL(futex, 3, (long) __futexp, FUTEX_WAKE, 1); \ + } \ +while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \ ({ \ @@ -79,12 +88,19 @@ #define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex)) +#define __lll_robust_mutex_trylock(futex, id) \ + (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0) +#define lll_robust_mutex_trylock(futex, id) \ + __lll_robust_mutex_trylock (&(futex), id) + + #define __lll_mutex_cond_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0) #define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; #define __lll_mutex_lock(futex) \ @@ -96,6 +112,18 @@ extern void __lll_lock_wait (int *futex) #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +#define __lll_robust_mutex_lock(futex, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + })) +#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) + + #define __lll_mutex_cond_lock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -105,8 +133,24 @@ extern void __lll_lock_wait (int *futex) #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define __lll_robust_mutex_cond_lock(futex, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + int __id = (id) | FUTEX_WAITERS; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, __id, 0) != 0) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + })) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_cond_lock (&(futex), id) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) + attribute_hidden; #define __lll_mutex_timedlock(futex, abstime) \ @@ -122,6 +166,19 @@ extern int __lll_timedlock_wait (int *fu __lll_mutex_timedlock (&(futex), abstime) +#define __lll_robust_mutex_timedlock(futex, abstime, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ + __val = __lll_robust_timedlock_wait (__futex, abstime); \ + __val; \ + })) +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + + #define __lll_mutex_unlock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -134,6 +191,18 @@ extern int __lll_timedlock_wait (int *fu __lll_mutex_unlock(&(futex)) +#define __lll_robust_mutex_unlock(futex) \ + ((void) ({ \ + int *__futex = (futex); \ + int __val = atomic_exchange_rel (__futex, 0); \ + \ + if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + lll_futex_wake (__futex, 1); \ + })) +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex)) + + #define __lll_mutex_unlock_force(futex) \ ((void) ({ \ int *__futex = (futex); \ --- libc/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c.jj 2006-02-17 09:13:58.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c 2006-02-17 09:13:58.000000000 +0100 @@ -0,0 +1,95 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +__lll_robust_lock_wait (int *futex) +{ + int oldval = *futex; + int tid = THREAD_GETMEM (THREAD_SELF, tid); + + do + { + if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + return oldval; + + int newval = oldval | FUTEX_WAITERS; + if (oldval != newval + && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) + continue; + + lll_futex_wait (futex, newval); + } + while ((oldval = atomic_compare_and_exchange_val_acq (futex, tid, 0)) != 0); + return 0; +} + + +int +__lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) +{ + /* Reject invalid timeouts. */ + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + return EINVAL; + + int tid = THREAD_GETMEM (THREAD_SELF, tid); + + do + { + struct timeval tv; + struct timespec rt; + + /* Get the current time. */ + (void) __gettimeofday (&tv, NULL); + + /* Compute relative timeout. */ + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + if (rt.tv_nsec < 0) + { + rt.tv_nsec += 1000000000; + --rt.tv_sec; + } + + /* Already timed out? */ + if (rt.tv_sec < 0) + return ETIMEDOUT; + + /* Wait. */ + int oldval = *futex; + if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + return oldval; + + int newval = oldval | FUTEX_WAITERS; + if (oldval != newval + && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) + continue; + + lll_futex_timed_wait (futex, newval, &rt); + } + while (atomic_compare_and_exchange_bool_acq (futex, tid, 0)); + + return 0; +} --- libc/include/atomic.h.jj 2005-08-23 12:00:25.000000000 +0200 +++ libc/include/atomic.h 2006-02-17 09:13:58.000000000 +0100 @@ -1,5 +1,5 @@ /* Internal macros for atomic operations for GNU C Library. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -273,6 +273,41 @@ __oldval & __mask; }) #endif +/* Atomically *mem &= mask and return the old value of *mem. */ +#ifndef atomic_and +# define atomic_and(mem, mask) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __mask = (mask); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + & __mask, \ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif + +/* Atomically *mem |= mask and return the old value of *mem. */ +#ifndef atomic_or +# define atomic_or(mem, mask) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __mask = (mask); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + | __mask, \ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif #ifndef atomic_full_barrier # define atomic_full_barrier() __asm ("" ::: "memory") Jakub From jakub@redhat.com Fri Feb 17 18:23:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 17 Feb 2006 18:23:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <20060217160814.GQ4625@sunsite.mff.cuni.cz> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> <43F362D1.80207@redhat.com> <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> <20060217160814.GQ4625@sunsite.mff.cuni.cz> Message-ID: <20060217182307.GR4625@sunsite.mff.cuni.cz> On Fri, Feb 17, 2006 at 05:08:14PM +0100, Jakub Jelinek wrote: > On Fri, Feb 17, 2006 at 10:27:47PM +0900, Kaz Kojima wrote: > > > Applied. But with the changes I checked in before all archs but x86 and > > > x86-64 are broken again. Somebody needs to write the generic > > > lowlevelrobustlock.c file and adjust the lowlevellock.h files. > > > > Here is a patch for SH to add *_robust_mutex_* stuff. It's tested > > only with "make -k check" with no new failures. > > And here it is for ppc*/s390*/ia64/alpha, so far tested on ppc64 > only. sparc* not done yet, as although sparcv9/sparc64 is easy, > sparc32 pre-v9 will be much harder (and probably will need to > never register the robust list with kernel, so on 32-bit sparc > kernels the only robustness guaranteed will be if a thread is cancelled, > but not if it crashes). That one had a few minor issues, here is one tested on ia64/ppc32/ppc64/s390/s390x: 2006-02-17 Jakub Jelinek * include/atomic.h (atomic_and, atomic_or): Define. nptl/ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_mutex_dead, lll_robust_mutex_trylock, lll_robust_mutex_lock, lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock, lll_robust_mutex_unlock): New macros. (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes. * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: New file. --- libc/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h 2006-02-17 19:20:29.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -64,6 +64,15 @@ INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + int *__futexp = &(futexv); \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + lll_futex_wake (__futexp, 1); \ + } \ + while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \ ({ \ @@ -106,7 +115,16 @@ __lll_mutex_cond_trylock(int *futex) #define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock)) +static inline int __attribute__((always_inline)) +__lll_robust_mutex_trylock(int *futex, int id) +{ + return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0; +} +#define lll_robust_mutex_trylock(lock, id) \ + __lll_robust_mutex_trylock (&(lock), id) + extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; static inline void __attribute__((always_inline)) __lll_mutex_lock(int *futex) @@ -117,6 +135,18 @@ __lll_mutex_lock(int *futex) #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +static inline int __attribute__ ((always_inline)) +__lll_robust_mutex_lock (int *futex, int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_lock_wait (futex); + return result; +} +#define lll_robust_mutex_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), id) + + static inline void __attribute__ ((always_inline)) __lll_mutex_cond_lock (int *futex) { @@ -126,8 +156,14 @@ __lll_mutex_cond_lock (int *futex) #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) + attribute_hidden; static inline int __attribute__ ((always_inline)) __lll_mutex_timedlock (int *futex, const struct timespec *abstime) @@ -141,6 +177,19 @@ __lll_mutex_timedlock (int *futex, const __lll_mutex_timedlock (&(futex), abstime) +static inline int __attribute__ ((always_inline)) +__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime, + int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_timedlock_wait (futex, abstime); + return result; +} +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + + static inline void __attribute__ ((always_inline)) __lll_mutex_unlock (int *futex) { @@ -152,6 +201,17 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) +__lll_robust_mutex_unlock (int *futex, int mask) +{ + int val = atomic_exchange_rel (futex, 0); + if (__builtin_expect (val & mask, 0)) + lll_futex_wake (futex, 1); +} +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS) + + +static inline void __attribute__ ((always_inline)) __lll_mutex_unlock_force (int *futex) { (void) atomic_exchange_rel (futex, 0); --- libc/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h 2006-02-17 19:20:29.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky , 2003. @@ -85,6 +85,17 @@ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + int *__futexp = &(futexv); \ + \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + lll_futex_wake (__futexp, 1); \ + } \ + while (0) + + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futex, nr_wake, nr_move, mutex, val) \ ({ \ @@ -167,7 +178,23 @@ __lll_mutex_cond_trylock (int *futex) #define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_trylock (int *futex, int id) +{ + unsigned int old; + + __asm __volatile ("cs %0,%3,%1" + : "=d" (old), "=Q" (*futex) + : "0" (0), "d" (id), "m" (*futex) : "cc", "memory" ); + return old != 0; +} +#define lll_robust_mutex_trylock(futex, id) \ + __lll_robust_mutex_trylock (&(futex), id) + + extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; static inline void __attribute__ ((always_inline)) @@ -178,6 +205,17 @@ __lll_mutex_lock (int *futex) } #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_lock (int *futex, int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_lock_wait (futex); + return result; +} +#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) + static inline void __attribute__ ((always_inline)) __lll_mutex_cond_lock (int *futex) @@ -187,8 +225,13 @@ __lll_mutex_cond_lock (int *futex) } #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS) + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait + (int *futex, const struct timespec *) attribute_hidden; static inline int __attribute__ ((always_inline)) @@ -202,6 +245,19 @@ __lll_mutex_timedlock (int *futex, const #define lll_mutex_timedlock(futex, abstime) \ __lll_mutex_timedlock (&(futex), abstime) +static inline int +__attribute__ ((always_inline)) +__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime, + int id) +{ + int result = 0; + if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0) + result = __lll_robust_timedlock_wait (futex, abstime); + return result; +} +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + static inline void __attribute__ ((always_inline)) @@ -220,6 +276,21 @@ __lll_mutex_unlock (int *futex) static inline void __attribute__ ((always_inline)) +__lll_robust_mutex_unlock (int *futex, int mask) +{ + int oldval; + int newval = 0; + + lll_compare_and_swap (futex, oldval, newval, "slr %2,%2"); + if (oldval & mask) + lll_futex_wake (futex, 1); +} +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS) + + +static inline void +__attribute__ ((always_inline)) __lll_mutex_unlock_force (int *futex) { *futex = 0; --- libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h 2006-02-17 14:36:19.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras , 2003. @@ -69,6 +69,17 @@ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \ }) +#define lll_robust_mutex_dead(futexv) \ + do \ + { \ + INTERNAL_SYSCALL_DECL (__err); \ + int *__futexp = &(futexv); \ + \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + INTERNAL_SYSCALL (futex, __err, 4, __futexp, FUTEX_WAKE, 1, 0); \ + } \ + while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \ ({ \ @@ -102,8 +113,8 @@ # define __lll_rel_instr "sync" #endif -/* Set *futex to 1 if it is 0, atomically. Returns the old value */ -#define __lll_trylock(futex) \ +/* Set *futex to ID if it is 0, atomically. Returns the old value */ +#define __lll_robust_trylock(futex, id) \ ({ int __val; \ __asm __volatile ("1: lwarx %0,0,%2\n" \ " cmpwi 0,%0,0\n" \ @@ -112,31 +123,26 @@ " bne- 1b\n" \ "2: " __lll_acq_instr \ : "=&r" (__val), "=m" (*futex) \ - : "r" (futex), "r" (1), "m" (*futex) \ + : "r" (futex), "r" (id), "m" (*futex) \ : "cr0", "memory"); \ __val; \ }) +#define lll_robust_mutex_trylock(lock, id) __lll_robust_trylock (&(lock), id) + +/* Set *futex to 1 if it is 0, atomically. Returns the old value */ +#define __lll_trylock(futex) __lll_robust_trylock (futex, 1) + #define lll_mutex_trylock(lock) __lll_trylock (&(lock)) /* Set *futex to 2 if it is 0, atomically. Returns the old value */ -#define __lll_cond_trylock(futex) \ - ({ int __val; \ - __asm __volatile ("1: lwarx %0,0,%2\n" \ - " cmpwi 0,%0,0\n" \ - " bne 2f\n" \ - " stwcx. %3,0,%2\n" \ - " bne- 1b\n" \ - "2: " __lll_acq_instr \ - : "=&r" (__val), "=m" (*futex) \ - : "r" (futex), "r" (2), "m" (*futex) \ - : "cr0", "memory"); \ - __val; \ - }) +#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2) + #define lll_mutex_cond_trylock(lock) __lll_cond_trylock (&(lock)) extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; #define lll_mutex_lock(lock) \ (void) ({ \ @@ -146,6 +152,16 @@ extern void __lll_lock_wait (int *futex) __lll_lock_wait (__futex); \ }) +#define lll_robust_mutex_lock(lock, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) + #define lll_mutex_cond_lock(lock) \ (void) ({ \ int *__futex = &(lock); \ @@ -154,8 +170,22 @@ extern void __lll_lock_wait (int *futex) __lll_lock_wait (__futex); \ }) +#define lll_robust_mutex_cond_lock(lock, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + int __id = id | FUTEX_WAITERS; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, __id,\ + 0), 0)) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait + (int *futex, const struct timespec *) attribute_hidden; #define lll_mutex_timedlock(lock, abstime) \ ({ \ @@ -167,6 +197,16 @@ extern int __lll_timedlock_wait __val; \ }) +#define lll_robust_mutex_timedlock(lock, abstime, id) \ + ({ \ + int *__futex = &(lock); \ + int __val = 0; \ + if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \ + 0), 0)) \ + __val = __lll_robust_timedlock_wait (__futex, abstime); \ + __val; \ + }) + #define lll_mutex_unlock(lock) \ ((void) ({ \ int *__futex = &(lock); \ @@ -175,6 +215,14 @@ extern int __lll_timedlock_wait lll_futex_wake (__futex, 1); \ })) +#define lll_robust_mutex_unlock(lock) \ + ((void) ({ \ + int *__futex = &(lock); \ + int __val = atomic_exchange_rel (__futex, 0); \ + if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + lll_futex_wake (__futex, 1); \ + })) + #define lll_mutex_unlock_force(lock) \ ((void) ({ \ int *__futex = &(lock); \ --- libc/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h.jj 2005-09-09 12:58:42.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h 2006-02-17 19:20:29.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -55,6 +55,15 @@ _r10 == -1 ? -_retval : _retval; \ }) +#define lll_robust_mutex_dead(futexv) \ +do \ + { \ + int *__futexp = &(futexv); \ + atomic_or (__futexp, FUTEX_OWNER_DIED); \ + DO_INLINE_SYSCALL(futex, 3, (long) __futexp, FUTEX_WAKE, 1); \ + } \ +while (0) + /* Returns non-zero if error happened, zero if success. */ #define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \ ({ \ @@ -79,12 +88,19 @@ #define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex)) +#define __lll_robust_mutex_trylock(futex, id) \ + (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0) +#define lll_robust_mutex_trylock(futex, id) \ + __lll_robust_mutex_trylock (&(futex), id) + + #define __lll_mutex_cond_trylock(futex) \ (atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0) #define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex)) extern void __lll_lock_wait (int *futex) attribute_hidden; +extern int __lll_robust_lock_wait (int *futex) attribute_hidden; #define __lll_mutex_lock(futex) \ @@ -96,6 +112,18 @@ extern void __lll_lock_wait (int *futex) #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex)) +#define __lll_robust_mutex_lock(futex, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) +#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id) + + #define __lll_mutex_cond_lock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -105,8 +133,24 @@ extern void __lll_lock_wait (int *futex) #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex)) +#define __lll_robust_mutex_cond_lock(futex, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + int __id = (id) | FUTEX_WAITERS; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, __id, 0) != 0) \ + __val = __lll_robust_lock_wait (__futex); \ + __val; \ + }) +#define lll_robust_mutex_cond_lock(futex, id) \ + __lll_robust_mutex_cond_lock (&(futex), id) + + extern int __lll_timedlock_wait (int *futex, const struct timespec *) attribute_hidden; +extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) + attribute_hidden; #define __lll_mutex_timedlock(futex, abstime) \ @@ -122,6 +166,19 @@ extern int __lll_timedlock_wait (int *fu __lll_mutex_timedlock (&(futex), abstime) +#define __lll_robust_mutex_timedlock(futex, abstime, id) \ + ({ \ + int *__futex = (futex); \ + int __val = 0; \ + \ + if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \ + __val = __lll_robust_timedlock_wait (__futex, abstime); \ + __val; \ + }) +#define lll_robust_mutex_timedlock(futex, abstime, id) \ + __lll_robust_mutex_timedlock (&(futex), abstime, id) + + #define __lll_mutex_unlock(futex) \ ((void) ({ \ int *__futex = (futex); \ @@ -134,6 +191,18 @@ extern int __lll_timedlock_wait (int *fu __lll_mutex_unlock(&(futex)) +#define __lll_robust_mutex_unlock(futex) \ + ((void) ({ \ + int *__futex = (futex); \ + int __val = atomic_exchange_rel (__futex, 0); \ + \ + if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \ + lll_futex_wake (__futex, 1); \ + })) +#define lll_robust_mutex_unlock(futex) \ + __lll_robust_mutex_unlock(&(futex)) + + #define __lll_mutex_unlock_force(futex) \ ((void) ({ \ int *__futex = (futex); \ --- libc/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c.jj 2006-02-17 09:13:58.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c 2006-02-17 09:13:58.000000000 +0100 @@ -0,0 +1,95 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +__lll_robust_lock_wait (int *futex) +{ + int oldval = *futex; + int tid = THREAD_GETMEM (THREAD_SELF, tid); + + do + { + if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + return oldval; + + int newval = oldval | FUTEX_WAITERS; + if (oldval != newval + && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) + continue; + + lll_futex_wait (futex, newval); + } + while ((oldval = atomic_compare_and_exchange_val_acq (futex, tid, 0)) != 0); + return 0; +} + + +int +__lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) +{ + /* Reject invalid timeouts. */ + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + return EINVAL; + + int tid = THREAD_GETMEM (THREAD_SELF, tid); + + do + { + struct timeval tv; + struct timespec rt; + + /* Get the current time. */ + (void) __gettimeofday (&tv, NULL); + + /* Compute relative timeout. */ + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + if (rt.tv_nsec < 0) + { + rt.tv_nsec += 1000000000; + --rt.tv_sec; + } + + /* Already timed out? */ + if (rt.tv_sec < 0) + return ETIMEDOUT; + + /* Wait. */ + int oldval = *futex; + if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) + return oldval; + + int newval = oldval | FUTEX_WAITERS; + if (oldval != newval + && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) + continue; + + lll_futex_timed_wait (futex, newval, &rt); + } + while (atomic_compare_and_exchange_bool_acq (futex, tid, 0)); + + return 0; +} --- libc/include/atomic.h.jj 2005-08-23 12:00:25.000000000 +0200 +++ libc/include/atomic.h 2006-02-17 09:13:58.000000000 +0100 @@ -1,5 +1,5 @@ /* Internal macros for atomic operations for GNU C Library. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -273,6 +273,41 @@ __oldval & __mask; }) #endif +/* Atomically *mem &= mask and return the old value of *mem. */ +#ifndef atomic_and +# define atomic_and(mem, mask) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __mask = (mask); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + & __mask, \ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif + +/* Atomically *mem |= mask and return the old value of *mem. */ +#ifndef atomic_or +# define atomic_or(mem, mask) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __mask = (mask); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + | __mask, \ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif #ifndef atomic_full_barrier # define atomic_full_barrier() __asm ("" ::: "memory") Jakub From drepper@redhat.com Fri Feb 17 18:51:00 2006 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 17 Feb 2006 18:51:00 -0000 Subject: [PATCH] glibc build fixes In-Reply-To: <20060217182307.GR4625@sunsite.mff.cuni.cz> References: <20060213130201.GI4625@sunsite.mff.cuni.cz> <43F362D1.80207@redhat.com> <20060217.222747.34764802.kkojima@rr.iij4u.or.jp> <20060217160814.GQ4625@sunsite.mff.cuni.cz> <20060217182307.GR4625@sunsite.mff.cuni.cz> Message-ID: <43F61B06.6010908@redhat.com> Applied. -- ? Ulrich Drepper ? Red Hat, Inc. ? 444 Castro St ? Mountain View, CA ? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 251 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Wed Feb 22 09:26:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 22 Feb 2006 09:26:00 -0000 Subject: [PATCH] Fix ypclnt.c i18n Message-ID: <20060222092646.GV4625@sunsite.mff.cuni.cz> Hi! 2005-11-26 Ulrich Drepper * nis/ypclnt.c (yperr_string): Reduce size of function by using only one gettext call. (ypbinderr_string): Likewise. leads to libc.pot not containing those strings any longer. Guess we need something like this: 2006-02-22 Jakub Jelinek * nis/ypclnt.c (yperr_string, ypbinderr_string): Add N_() around string literals. --- libc/nis/ypclnt.c.jj 2005-12-13 16:42:16.000000000 +0100 +++ libc/nis/ypclnt.c 2006-02-22 10:14:24.000000000 +0100 @@ -819,58 +819,58 @@ yperr_string (const int error) switch (error) { case YPERR_SUCCESS: - str = "Success"; + str = N_("Success"); break; case YPERR_BADARGS: - str = "Request arguments bad"; + str = N_("Request arguments bad"); break; case YPERR_RPC: - str = "RPC failure on NIS operation"; + str = N_("RPC failure on NIS operation"); break; case YPERR_DOMAIN: - str = "Can't bind to server which serves this domain"; + str = N_("Can't bind to server which serves this domain"); break; case YPERR_MAP: - str = "No such map in server's domain"; + str = N_("No such map in server's domain"); break; case YPERR_KEY: - str = "No such key in map"; + str = N_("No such key in map"); break; case YPERR_YPERR: - str = "Internal NIS error"; + str = N_("Internal NIS error"); break; case YPERR_RESRC: - str = "Local resource allocation failure"; + str = N_("Local resource allocation failure"); break; case YPERR_NOMORE: - str = "No more records in map database"; + str = N_("No more records in map database"); break; case YPERR_PMAP: - str = "Can't communicate with portmapper"; + str = N_("Can't communicate with portmapper"); break; case YPERR_YPBIND: - str = "Can't communicate with ypbind"; + str = N_("Can't communicate with ypbind"); break; case YPERR_YPSERV: - str = "Can't communicate with ypserv"; + str = N_("Can't communicate with ypserv"); break; case YPERR_NODOM: - str = "Local domain name not set"; + str = N_("Local domain name not set"); break; case YPERR_BADDB: - str = "NIS map database is bad"; + str = N_("NIS map database is bad"); break; case YPERR_VERS: - str = "NIS client/server version mismatch - can't supply service"; + str = N_("NIS client/server version mismatch - can't supply service"); break; case YPERR_ACCESS: - str = "Permission denied"; + str = N_("Permission denied"); break; case YPERR_BUSY: - str = "Database is busy"; + str = N_("Database is busy"); break; default: - str = "Unknown NIS error code"; + str = N_("Unknown NIS error code"); break; } return _(str); @@ -907,19 +907,19 @@ ypbinderr_string (const int error) switch (error) { case 0: - str = "Success"; + str = N_("Success"); break; case YPBIND_ERR_ERR: - str = "Internal ypbind error"; + str = N_("Internal ypbind error"); break; case YPBIND_ERR_NOSERV: - str = "Domain not bound"; + str = N_("Domain not bound"); break; case YPBIND_ERR_RESC: - str = "System resource allocation failure"; + str = N_("System resource allocation failure"); break; default: - str = "Unknown ypbind error"; + str = N_("Unknown ypbind error"); break; } return _(str); Jakub From jakub@redhat.com Thu Feb 23 13:56:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 23 Feb 2006 13:56:00 -0000 Subject: [PATCH] __sched_yield libc_hidden_def Message-ID: <20060223135632.GA30252@sunsite.mff.cuni.cz> Hi! Ulrich added libc_hidden_proto to __sched_yield last month. While that works when __sched_yield is provided by syscalls.list (as in that case __GI___sched_yield is provided automatically), when it is implemented in C, we need to mark it. 2006-02-23 Jakub Jelinek * posix/sched_yield.c (__sched_yield): Add libc_hidden_def. * sysdeps/mach/sched_yield.c (__sched_yield): Likewise. --- libc/posix/sched_yield.c.jj 2005-12-14 11:39:15.000000000 +0100 +++ libc/posix/sched_yield.c 2006-02-23 14:48:34.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,6 +28,7 @@ __sched_yield (void) return -1; } stub_warning (sched_yield) +libc_hidden_def (__sched_yield) weak_alias (__sched_yield, sched_yield) #include --- libc/sysdeps/mach/sched_yield.c.jj 2001-07-06 06:55:56.000000000 +0200 +++ libc/sysdeps/mach/sched_yield.c 2006-02-23 14:49:07.000000000 +0100 @@ -1,5 +1,5 @@ /* sched_yield -- yield the processor. Mach version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,4 +28,5 @@ __sched_yield (void) (void) __swtch (); return 0; } +libc_hidden_def (__sched_yield) weak_alias (__sched_yield, sched_yield) Jakub From davem@davemloft.net Thu Feb 23 21:59:00 2006 From: davem@davemloft.net (David S. Miller) Date: Thu, 23 Feb 2006 21:59:00 -0000 Subject: stray reference to posix/ftruncate64.c Message-ID: <20060223.135938.44550820.davem@davemloft.net> In unix/sysv/linux/ftruncate64.c: davem@sunset:~/src/GLIBC/cvs/libc/sysdeps$ find . -type f -name "*.c" | xargs egrep posix/ftruncate64.c ./unix/sysv/linux/ftruncate64.c:# include davem@sunset:~/src/GLIBC/cvs/libc/sysdeps$ From davem@davemloft.net Fri Feb 24 23:37:00 2006 From: davem@davemloft.net (David S. Miller) Date: Fri, 24 Feb 2006 23:37:00 -0000 Subject: [PATCH]: Recognize HWCAP_SPARC_BLKINIT Message-ID: <20060224.153709.86558879.davem@davemloft.net> SUN4V Niagara processors have a load-twin/block-init-store capability which is indicated by bit 6 in the HWCAP_* mask from the kernel. Add recognition of that value to glibc, and ask it to use "v9v" in the library search path. 2006-02-24 David S. Miller * elf/elf.h: Add HWCAP_SPARC_BLKINIT. * sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.c: Add "v9v" entry to _dl_sparc32_cap_flags. * sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h: Add HWCAP_SPARC_BLKINIT to HWCAP_IMPORTANT. * sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.c: Add "v9v" entry to _dl_sparc32_cap_flags. * sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h: Add HWCAP_SPARC_BLKINIT to HWCAP_IMPORTANT. --- ./elf/elf.h.~1~ 2006-02-23 16:01:13.000000000 -0800 +++ ./elf/elf.h 2006-02-23 16:01:18.000000000 -0800 @@ -1258,6 +1258,7 @@ typedef struct #define HWCAP_SPARC_MULDIV 8 #define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ #define HWCAP_SPARC_ULTRA3 32 +#define HWCAP_SPARC_BLKINIT 64 /* Sun4v with block-init/load-twin. */ /* MIPS R3000 specific definitions. */ --- ./sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.c.~1~ 2006-02-23 16:01:14.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.c 2006-02-23 16:01:18.000000000 -0800 @@ -47,11 +47,11 @@ #if !defined PROCINFO_DECL && defined SHARED ._dl_sparc32_cap_flags #else -PROCINFO_CLASS const char _dl_sparc32_cap_flags[6][7] +PROCINFO_CLASS const char _dl_sparc32_cap_flags[7][7] #endif #ifndef PROCINFO_DECL = { - "flush", "stbar", "swap", "muldiv", "v9", "ultra3" + "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v" } #endif #if !defined SHARED || defined PROCINFO_DECL --- ./sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h.~1~ 2006-02-23 16:01:14.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h 2006-02-23 16:01:18.000000000 -0800 @@ -62,7 +62,7 @@ _dl_string_hwcap (const char *str) return -1; }; -#define HWCAP_IMPORTANT (HWCAP_SPARC_V9|HWCAP_SPARC_ULTRA3) +#define HWCAP_IMPORTANT (HWCAP_SPARC_V9|HWCAP_SPARC_ULTRA3|HWCAP_SPARC_BLKINIT) /* There are no different platforms defined. */ #define _dl_platform_string(idx) "" --- ./sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.c.~1~ 2006-02-23 16:01:14.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.c 2006-02-23 16:01:18.000000000 -0800 @@ -47,11 +47,11 @@ #if !defined PROCINFO_DECL && defined SHARED ._dl_sparc64_cap_flags #else -PROCINFO_CLASS const char _dl_sparc64_cap_flags[6][7] +PROCINFO_CLASS const char _dl_sparc64_cap_flags[7][7] #endif #ifndef PROCINFO_DECL = { - "flush", "stbar", "swap", "muldiv", "v9", "ultra3" + "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v" } #endif #if !defined SHARED || defined PROCINFO_DECL --- ./sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h.~1~ 2006-02-23 16:01:14.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h 2006-02-23 16:01:18.000000000 -0800 @@ -63,7 +63,7 @@ _dl_string_hwcap (const char *str) return -1; }; -#define HWCAP_IMPORTANT (HWCAP_SPARC_ULTRA3) +#define HWCAP_IMPORTANT (HWCAP_SPARC_ULTRA3|HWCAP_SPARC_BLKINIT) /* There are no different platforms defined. */ #define _dl_platform_string(idx) "" From davem@davemloft.net Fri Feb 24 23:46:00 2006 From: davem@davemloft.net (David S. Miller) Date: Fri, 24 Feb 2006 23:46:00 -0000 Subject: [PATCH]: Sparc SUN4V Niagara optimize memset/memcpy Message-ID: <20060224.154607.114276042.davem@davemloft.net> I've sent a patch for scripts/config.sub to config-patches the other day, so that part of adding sparcv9v and sparc64v should show up eventually. This adds the "sparcv9v-*" and "sparc64v-*" build targets, the optimized memcpy/memset for that platform, and the necessary Implies files. Please apply. nptl/ 2006-02-24 David S. Miller * sysdeps/sparc/sparc32/sparcv9v/Implies: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies: New file. / 2006-02-24 David S. Miller * sysdeps/sparc/sparc32/sparcv9v/Implies: New file. * sysdeps/sparc/sparc32/sparcv9v/memcpy.S: New file. * sysdeps/sparc/sparc32/sparcv9v/memset.S: New file. * sysdeps/sparc/sparc64/sparcv9v/memset.S: New file. * sysdeps/sparc/sparc64/sparcv9v/memcpy.S: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies: New file. * configure.in: Add sparcv9v and sparc64v. * configure: Regenerate. --- ./nptl/sysdeps/sparc/sparc32/sparcv9v/Implies.~1~ 2006-02-23 16:55:09.000000000 -0800 +++ ./nptl/sysdeps/sparc/sparc32/sparcv9v/Implies 2006-02-23 16:55:05.000000000 -0800 @@ -0,0 +1 @@ +sparc/sparc32/sparcv9 --- ./nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies.~1~ 2006-02-23 16:53:34.000000000 -0800 +++ ./nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies 2006-02-23 16:54:37.000000000 -0800 @@ -0,0 +1 @@ +unix/sysv/linux/sparc/sparc32/sparcv9 --- ./sysdeps/sparc/sparc32/sparcv9v/Implies.~1~ 2006-02-24 15:39:56.000000000 -0800 +++ ./sysdeps/sparc/sparc32/sparcv9v/Implies 2006-02-23 16:01:18.000000000 -0800 @@ -0,0 +1 @@ +sparc/sparc32/sparcv9 --- ./sysdeps/sparc/sparc32/sparcv9v/memcpy.S.~1~ 2006-02-24 15:39:59.000000000 -0800 +++ ./sysdeps/sparc/sparc32/sparcv9v/memcpy.S 2006-02-23 16:01:18.000000000 -0800 @@ -0,0 +1,2 @@ +#define XCC icc +#include --- ./sysdeps/sparc/sparc32/sparcv9v/memset.S.~1~ 2006-02-24 15:40:02.000000000 -0800 +++ ./sysdeps/sparc/sparc32/sparcv9v/memset.S 2006-02-23 16:01:18.000000000 -0800 @@ -0,0 +1,2 @@ +#define XCC icc +#include --- ./sysdeps/sparc/sparc64/sparcv9v/memset.S.~1~ 2006-02-23 19:20:48.000000000 -0800 +++ ./sysdeps/sparc/sparc64/sparcv9v/memset.S 2006-02-23 16:21:28.000000000 -0800 @@ -0,0 +1,128 @@ +/* Set a block of memory to some byte value. + For SUN4V Niagara. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller (davem@davemloft.net) + + 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 + +#define ASI_BLK_INIT_QUAD_LDD_P 0xe2 +#define ASI_P 0x80 +#define ASI_PNF 0x82 + +#ifndef XCC +#define USE_BPR +#define XCC xcc +#endif + + .register %g2,#scratch + + .text + .align 32 + +ENTRY(memset) + /* %o0=buf, %o1=pat, %o2=len */ + and %o1, 0xff, %o3 + mov %o2, %o1 + sllx %o3, 8, %g1 + or %g1, %o3, %o2 + sllx %o2, 16, %g1 + or %g1, %o2, %o2 + sllx %o2, 32, %g1 + ba,pt %XCC, 1f + or %g1, %o2, %o2 + +ENTRY(__bzero) + clr %o2 +1: brz,pn %o1, 90f + mov %o0, %o3 + + wr %g0, ASI_P, %asi + + cmp %o1, 15 + bl,pn %icc, 70f + andcc %o0, 0x7, %g1 + be,pt %XCC, 2f + mov 8, %g2 + sub %g2, %g1, %g1 + sub %o1, %g1, %o1 +1: stba %o2, [%o0 + 0x00] %asi + subcc %g1, 1, %g1 + bne,pt %XCC, 1b + add %o0, 1, %o0 +2: cmp %o1, 128 + bl,pn %icc, 60f + andcc %o0, (64 - 1), %g1 + be,pt %XCC, 40f + mov 64, %g2 + sub %g2, %g1, %g1 + sub %o1, %g1, %o1 +1: stxa %o2, [%o0 + 0x00] %asi + subcc %g1, 8, %g1 + bne,pt %XCC, 1b + add %o0, 8, %o0 + +40: + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi + andn %o1, (64 - 1), %g1 + sub %o1, %g1, %o1 +50: + stxa %o2, [%o0 + 0x00] %asi + stxa %o2, [%o0 + 0x08] %asi + stxa %o2, [%o0 + 0x10] %asi + stxa %o2, [%o0 + 0x18] %asi + stxa %o2, [%o0 + 0x20] %asi + stxa %o2, [%o0 + 0x28] %asi + stxa %o2, [%o0 + 0x30] %asi + stxa %o2, [%o0 + 0x38] %asi + subcc %g1, 64, %g1 + bne,pt %XCC, 50b + add %o0, 64, %o0 + + wr %g0, ASI_P, %asi + brz,pn %o1, 80f +60: + andncc %o1, 0x7, %g1 + be,pn %XCC, 2f + sub %o1, %g1, %o1 +1: stxa %o2, [%o0 + 0x00] %asi + subcc %g1, 8, %g1 + bne,pt %XCC, 1b + add %o0, 8, %o0 +2: brz,pt %o1, 80f + nop + +70: +1: stba %o2, [%o0 + 0x00] %asi + subcc %o1, 1, %o1 + bne,pt %icc, 1b + add %o0, 1, %o0 + + /* fallthrough */ + +80: + wr %g0, ASI_PNF, %asi + +90: + retl + mov %o3, %o0 +END(__bzero) +END(memset) + +libc_hidden_builtin_def (memset) +weak_alias (__bzero, bzero) --- ./sysdeps/sparc/sparc64/sparcv9v/memcpy.S.~1~ 2006-02-23 19:20:55.000000000 -0800 +++ ./sysdeps/sparc/sparc64/sparcv9v/memcpy.S 2006-02-24 13:48:21.000000000 -0800 @@ -0,0 +1,594 @@ +/* Copy SIZE bytes from SRC to DEST. + For SUN4V Niagara. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller (davem@davemloft.net) + + 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 + +#define ASI_BLK_INIT_QUAD_LDD_P 0xe2 +#define ASI_P 0x80 +#define ASI_PNF 0x82 + +#define LOAD(type,addr,dest) type##a [addr] ASI_P, dest +#define LOAD_TWIN(addr_reg,dest0,dest1) \ + ldda [addr_reg] ASI_BLK_INIT_QUAD_LDD_P, dest0 + +#define STORE(type,src,addr) type src, [addr] +#define STORE_INIT(src,addr) stxa src, [addr] %asi + +#ifndef XCC +#define USE_BPR +#define XCC xcc +#endif + + .register %g2,#scratch + .register %g3,#scratch + .register %g6,#scratch + + .text + .align 32 + +ENTRY(bcopy) + sub %o1, %o0, %o4 + mov %o0, %g4 + cmp %o4, %o2 + mov %o1, %o0 + bgeu,pt %XCC, 100f + mov %g4, %o1 +#ifndef USE_BPR + srl %o2, 0, %o2 +#endif + brnz,pn %o2, 220f + add %o0, %o2, %o0 + retl + nop +END(bcopy) + + .align 32 +ENTRY(memcpy) +100: /* %o0=dst, %o1=src, %o2=len */ + mov %o0, %g5 + cmp %o2, 0 + be,pn %XCC, 85f +218: or %o0, %o1, %o3 + cmp %o2, 16 + blu,a,pn %XCC, 80f + or %o3, %o2, %o3 + + /* 2 blocks (128 bytes) is the minimum we can do the block + * copy with. We need to ensure that we'll iterate at least + * once in the block copy loop. At worst we'll need to align + * the destination to a 64-byte boundary which can chew up + * to (64 - 1) bytes from the length before we perform the + * block copy loop. + */ + cmp %o2, (2 * 64) + blu,pt %XCC, 70f + andcc %o3, 0x7, %g0 + + /* %o0: dst + * %o1: src + * %o2: len (known to be >= 128) + * + * The block copy loops will use %o4/%o5,%g2/%g3 as + * temporaries while copying the data. + */ + + LOAD(prefetch, %o1, #one_read) + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi + + /* Align destination on 64-byte boundary. */ + andcc %o0, (64 - 1), %o4 + be,pt %XCC, 2f + sub %o4, 64, %o4 + sub %g0, %o4, %o4 ! bytes to align dst + sub %o2, %o4, %o2 +1: subcc %o4, 1, %o4 + LOAD(ldub, %o1, %g1) + STORE(stb, %g1, %o0) + add %o1, 1, %o1 + bne,pt %XCC, 1b + add %o0, 1, %o0 + + /* If the source is on a 16-byte boundary we can do + * the direct block copy loop. If it is 8-byte aligned + * we can do the 16-byte loads offset by -8 bytes and the + * init stores offset by one register. + * + * If the source is not even 8-byte aligned, we need to do + * shifting and masking (basically integer faligndata). + * + * The careful bit with init stores is that if we store + * to any part of the cache line we have to store the whole + * cacheline else we can end up with corrupt L2 cache line + * contents. Since the loop works on 64-bytes of 64-byte + * aligned store data at a time, this is easy to ensure. + */ +2: + andcc %o1, (16 - 1), %o4 + andn %o2, (64 - 1), %g1 ! block copy loop iterator + sub %o2, %g1, %o2 ! final sub-block copy bytes + be,pt %XCC, 50f + cmp %o4, 8 + be,a,pt %XCC, 10f + sub %o1, 0x8, %o1 + + /* Neither 8-byte nor 16-byte aligned, shift and mask. */ + mov %g1, %o4 + and %o1, 0x7, %g1 + sll %g1, 3, %g1 + mov 64, %o3 + andn %o1, 0x7, %o1 + LOAD(ldx, %o1, %g2) + sub %o3, %g1, %o3 + sllx %g2, %g1, %g2 + +#define SWIVEL_ONE_DWORD(SRC, TMP1, TMP2, PRE_VAL, PRE_SHIFT, POST_SHIFT, DST)\ + LOAD(ldx, SRC, TMP1); \ + srlx TMP1, PRE_SHIFT, TMP2; \ + or TMP2, PRE_VAL, TMP2; \ + STORE_INIT(TMP2, DST); \ + sllx TMP1, POST_SHIFT, PRE_VAL; + +1: add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x00) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x08) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x10) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x18) + add %o1, 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32 - 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x20) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x28) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x30) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x38) + subcc %o4, 64, %o4 + bne,pt %XCC, 1b + add %o0, 64, %o0 + +#undef SWIVEL_ONE_DWORD + + srl %g1, 3, %g1 + ba,pt %XCC, 60f + add %o1, %g1, %o1 + +10: /* Destination is 64-byte aligned, source was only 8-byte + * aligned but it has been subtracted by 8 and we perform + * one twin load ahead, then add 8 back into source when + * we finish the loop. + */ + LOAD_TWIN(%o1, %o4, %o5) +1: add %o1, 16, %o1 + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16 + 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32, %o1 + STORE_INIT(%o5, %o0 + 0x00) ! initializes cache line + STORE_INIT(%g2, %o0 + 0x08) + LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + STORE_INIT(%g3, %o0 + 0x10) + STORE_INIT(%o4, %o0 + 0x18) + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16, %o1 + STORE_INIT(%o5, %o0 + 0x20) + STORE_INIT(%g2, %o0 + 0x28) + LOAD_TWIN(%o1, %o4, %o5) + STORE_INIT(%g3, %o0 + 0x30) + STORE_INIT(%o4, %o0 + 0x38) + subcc %g1, 64, %g1 + bne,pt %XCC, 1b + add %o0, 64, %o0 + + ba,pt %XCC, 60f + add %o1, 0x8, %o1 + +50: /* Destination is 64-byte aligned, and source is 16-byte + * aligned. + */ +1: LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16 + 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32, %o1 + STORE_INIT(%o4, %o0 + 0x00) ! initializes cache line + STORE_INIT(%o5, %o0 + 0x08) + LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + STORE_INIT(%g2, %o0 + 0x10) + STORE_INIT(%g3, %o0 + 0x18) + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16, %o1 + STORE_INIT(%o4, %o0 + 0x20) + STORE_INIT(%o5, %o0 + 0x28) + STORE_INIT(%g2, %o0 + 0x30) + STORE_INIT(%g3, %o0 + 0x38) + subcc %g1, 64, %g1 + bne,pt %XCC, 1b + add %o0, 64, %o0 + /* fall through */ + +60: + /* %o2 contains any final bytes still needed to be copied + * over. If anything is left, we copy it one byte at a time. + */ + wr %g0, ASI_PNF, %asi + brz,pt %o2, 85f + sub %o0, %o1, %o3 + ba,a,pt %XCC, 90f + + .align 64 +70: /* 16 < len <= 64 */ + bne,pn %XCC, 75f + sub %o0, %o1, %o3 + +72: + andn %o2, 0xf, %o4 + and %o2, 0xf, %o2 +1: subcc %o4, 0x10, %o4 + LOAD(ldx, %o1, %o5) + add %o1, 0x08, %o1 + LOAD(ldx, %o1, %g1) + sub %o1, 0x08, %o1 + STORE(stx, %o5, %o1 + %o3) + add %o1, 0x8, %o1 + STORE(stx, %g1, %o1 + %o3) + bgu,pt %XCC, 1b + add %o1, 0x8, %o1 +73: andcc %o2, 0x8, %g0 + be,pt %XCC, 1f + nop + sub %o2, 0x8, %o2 + LOAD(ldx, %o1, %o5) + STORE(stx, %o5, %o1 + %o3) + add %o1, 0x8, %o1 +1: andcc %o2, 0x4, %g0 + be,pt %XCC, 1f + nop + sub %o2, 0x4, %o2 + LOAD(lduw, %o1, %o5) + STORE(stw, %o5, %o1 + %o3) + add %o1, 0x4, %o1 +1: cmp %o2, 0 + be,pt %XCC, 85f + nop + ba,pt %XCC, 90f + nop + +75: + andcc %o0, 0x7, %g1 + sub %g1, 0x8, %g1 + be,pn %icc, 2f + sub %g0, %g1, %g1 + sub %o2, %g1, %o2 + +1: subcc %g1, 1, %g1 + LOAD(ldub, %o1, %o5) + STORE(stb, %o5, %o1 + %o3) + bgu,pt %icc, 1b + add %o1, 1, %o1 + +2: add %o1, %o3, %o0 + andcc %o1, 0x7, %g1 + bne,pt %icc, 8f + sll %g1, 3, %g1 + + cmp %o2, 16 + bgeu,pt %icc, 72b + nop + ba,a,pt %XCC, 73b + +8: mov 64, %o3 + andn %o1, 0x7, %o1 + LOAD(ldx, %o1, %g2) + sub %o3, %g1, %o3 + andn %o2, 0x7, %o4 + sllx %g2, %g1, %g2 +1: add %o1, 0x8, %o1 + LOAD(ldx, %o1, %g3) + subcc %o4, 0x8, %o4 + srlx %g3, %o3, %o5 + or %o5, %g2, %o5 + STORE(stx, %o5, %o0) + add %o0, 0x8, %o0 + bgu,pt %icc, 1b + sllx %g3, %g1, %g2 + + srl %g1, 3, %g1 + andcc %o2, 0x7, %o2 + be,pn %icc, 85f + add %o1, %g1, %o1 + ba,pt %XCC, 90f + sub %o0, %o1, %o3 + + .align 64 +80: /* 0 < len <= 16 */ + andcc %o3, 0x3, %g0 + bne,pn %XCC, 90f + sub %o0, %o1, %o3 + +1: + subcc %o2, 4, %o2 + LOAD(lduw, %o1, %g1) + STORE(stw, %g1, %o1 + %o3) + bgu,pt %XCC, 1b + add %o1, 4, %o1 + +85: retl + mov %g5, %o0 + + .align 32 +90: + subcc %o2, 1, %o2 + LOAD(ldub, %o1, %g1) + STORE(stb, %g1, %o1 + %o3) + bgu,pt %XCC, 90b + add %o1, 1, %o1 + retl + mov %g5, %o0 + +END(memcpy) + +#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src - offset - 0x20], %t0; \ + ldx [%src - offset - 0x18], %t1; \ + ldx [%src - offset - 0x10], %t2; \ + ldx [%src - offset - 0x08], %t3; \ + stw %t0, [%dst - offset - 0x1c]; \ + srlx %t0, 32, %t0; \ + stw %t0, [%dst - offset - 0x20]; \ + stw %t1, [%dst - offset - 0x14]; \ + srlx %t1, 32, %t1; \ + stw %t1, [%dst - offset - 0x18]; \ + stw %t2, [%dst - offset - 0x0c]; \ + srlx %t2, 32, %t2; \ + stw %t2, [%dst - offset - 0x10]; \ + stw %t3, [%dst - offset - 0x04]; \ + srlx %t3, 32, %t3; \ + stw %t3, [%dst - offset - 0x08]; + +#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src - offset - 0x20], %t0; \ + ldx [%src - offset - 0x18], %t1; \ + ldx [%src - offset - 0x10], %t2; \ + ldx [%src - offset - 0x08], %t3; \ + stx %t0, [%dst - offset - 0x20]; \ + stx %t1, [%dst - offset - 0x18]; \ + stx %t2, [%dst - offset - 0x10]; \ + stx %t3, [%dst - offset - 0x08]; \ + ldx [%src - offset - 0x40], %t0; \ + ldx [%src - offset - 0x38], %t1; \ + ldx [%src - offset - 0x30], %t2; \ + ldx [%src - offset - 0x28], %t3; \ + stx %t0, [%dst - offset - 0x40]; \ + stx %t1, [%dst - offset - 0x38]; \ + stx %t2, [%dst - offset - 0x30]; \ + stx %t3, [%dst - offset - 0x28]; + +#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src + offset + 0x00], %t0; \ + ldx [%src + offset + 0x08], %t1; \ + stw %t0, [%dst + offset + 0x04]; \ + srlx %t0, 32, %t2; \ + stw %t2, [%dst + offset + 0x00]; \ + stw %t1, [%dst + offset + 0x0c]; \ + srlx %t1, 32, %t3; \ + stw %t3, [%dst + offset + 0x08]; + +#define RMOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \ + ldx [%src + offset + 0x00], %t0; \ + ldx [%src + offset + 0x08], %t1; \ + stx %t0, [%dst + offset + 0x00]; \ + stx %t1, [%dst + offset + 0x08]; + + .align 32 +228: andcc %o2, 1, %g0 + be,pt %icc, 2f+4 +1: ldub [%o1 - 1], %o5 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + subcc %o2, 1, %o2 + be,pn %xcc, 229f + stb %o5, [%o0] +2: ldub [%o1 - 1], %o5 + sub %o0, 2, %o0 + ldub [%o1 - 2], %g5 + sub %o1, 2, %o1 + subcc %o2, 2, %o2 + stb %o5, [%o0 + 1] + bne,pt %xcc, 2b + stb %g5, [%o0] +229: retl + mov %g4, %o0 +out: retl + mov %g5, %o0 + + .align 32 +ENTRY(memmove) + mov %o0, %g5 +#ifndef USE_BPR + srl %o2, 0, %o2 +#endif + brz,pn %o2, out + sub %o0, %o1, %o4 + cmp %o4, %o2 + bgeu,pt %XCC, 218b + mov %o0, %g4 + add %o0, %o2, %o0 +220: add %o1, %o2, %o1 + cmp %o2, 15 + bleu,pn %xcc, 228b + andcc %o0, 7, %g2 + sub %o0, %o1, %g5 + andcc %g5, 3, %o5 + bne,pn %xcc, 232f + andcc %o1, 3, %g0 + be,a,pt %xcc, 236f + andcc %o1, 4, %g0 + andcc %o1, 1, %g0 + be,pn %xcc, 4f + andcc %o1, 2, %g0 + ldub [%o1 - 1], %g2 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + sub %o2, 1, %o2 + be,pn %xcc, 5f + stb %g2, [%o0] +4: lduh [%o1 - 2], %g2 + sub %o1, 2, %o1 + sub %o0, 2, %o0 + sub %o2, 2, %o2 + sth %g2, [%o0] +5: andcc %o1, 4, %g0 +236: be,a,pn %xcc, 2f + andcc %o2, -128, %g6 + lduw [%o1 - 4], %g5 + sub %o1, 4, %o1 + sub %o0, 4, %o0 + sub %o2, 4, %o2 + stw %g5, [%o0] + andcc %o2, -128, %g6 +2: be,pn %xcc, 235f + andcc %o0, 4, %g0 + be,pn %xcc, 282f + 4 +5: RMOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5) + subcc %g6, 128, %g6 + sub %o1, 128, %o1 + bne,pt %xcc, 5b + sub %o0, 128, %o0 +235: andcc %o2, 0x70, %g6 +41: be,pn %xcc, 280f + andcc %o2, 8, %g0 + +279: rd %pc, %o5 + sll %g6, 1, %g5 + sub %o1, %g6, %o1 + sub %o5, %g5, %o5 + jmpl %o5 + %lo(280f - 279b), %g0 + sub %o0, %g6, %o0 + RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5) +280: be,pt %xcc, 281f + andcc %o2, 4, %g0 + ldx [%o1 - 8], %g2 + sub %o0, 8, %o0 + stw %g2, [%o0 + 4] + sub %o1, 8, %o1 + srlx %g2, 32, %g2 + stw %g2, [%o0] +281: be,pt %xcc, 1f + andcc %o2, 2, %g0 + lduw [%o1 - 4], %g2 + sub %o1, 4, %o1 + stw %g2, [%o0 - 4] + sub %o0, 4, %o0 +1: be,pt %xcc, 1f + andcc %o2, 1, %g0 + lduh [%o1 - 2], %g2 + sub %o1, 2, %o1 + sth %g2, [%o0 - 2] + sub %o0, 2, %o0 +1: be,pt %xcc, 211f + nop + ldub [%o1 - 1], %g2 + stb %g2, [%o0 - 1] +211: retl + mov %g4, %o0 + +282: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5) + RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5) + subcc %g6, 128, %g6 + sub %o1, 128, %o1 + bne,pt %xcc, 282b + sub %o0, 128, %o0 + andcc %o2, 0x70, %g6 + be,pn %xcc, 284f + andcc %o2, 8, %g0 + +283: rd %pc, %o5 + sub %o1, %g6, %o1 + sub %o5, %g6, %o5 + jmpl %o5 + %lo(284f - 283b), %g0 + sub %o0, %g6, %o0 + RMOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3) +284: be,pt %xcc, 285f + andcc %o2, 4, %g0 + ldx [%o1 - 8], %g2 + sub %o0, 8, %o0 + sub %o1, 8, %o1 + stx %g2, [%o0] +285: be,pt %xcc, 1f + andcc %o2, 2, %g0 + lduw [%o1 - 4], %g2 + sub %o0, 4, %o0 + sub %o1, 4, %o1 + stw %g2, [%o0] +1: be,pt %xcc, 1f + andcc %o2, 1, %g0 + lduh [%o1 - 2], %g2 + sub %o0, 2, %o0 + sub %o1, 2, %o1 + sth %g2, [%o0] +1: be,pt %xcc, 1f + nop + ldub [%o1 - 1], %g2 + stb %g2, [%o0 - 1] +1: retl + mov %g4, %o0 + +232: ldub [%o1 - 1], %g5 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + subcc %o2, 1, %o2 + bne,pt %xcc, 232b + stb %g5, [%o0] +234: retl + mov %g4, %o0 +END(memmove) + +#ifdef USE_BPR +weak_alias (memcpy, __align_cpy_1) +weak_alias (memcpy, __align_cpy_2) +weak_alias (memcpy, __align_cpy_4) +weak_alias (memcpy, __align_cpy_8) +weak_alias (memcpy, __align_cpy_16) +#endif +libc_hidden_builtin_def (memcpy) +libc_hidden_builtin_def (memmove) --- ./sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies.~1~ 2006-02-23 16:38:18.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9v/Implies 2006-02-23 16:38:04.000000000 -0800 @@ -0,0 +1 @@ +unix/sysv/linux/sparc/sparc32/sparcv9 --- ./configure.~1~ 2006-02-23 01:17:13.000000000 -0800 +++ ./configure 2006-02-23 16:06:30.000000000 -0800 @@ -1011,7 +1011,7 @@ esac else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd $ac_popdir + cd "$ac_popdir" done fi @@ -1976,10 +1976,14 @@ sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) base_machine=sparc machine=sparc/sparc32/sparcv9b ;; +sparcv9v) + base_machine=sparc machine=sparc/sparc32/sparcv9v ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) base_machine=sparc machine=sparc/sparc64/sparcv9b ;; +sparc64v) + base_machine=sparc machine=sparc/sparc64/sparcv9v ;; *) base_machine=$machine ;; esac @@ -2750,8 +2754,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2809,8 +2812,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2926,8 +2928,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2981,8 +2982,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3027,8 +3027,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3072,8 +3071,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3535,8 +3533,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3594,8 +3591,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3666,8 +3662,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3711,8 +3706,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4876,8 +4870,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5863,8 +5856,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5962,8 +5954,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6236,8 +6227,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6467,8 +6457,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6542,8 +6531,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6606,8 +6594,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6686,8 +6673,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6778,8 +6764,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6949,8 +6934,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7015,8 +6999,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7078,8 +7061,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7119,8 +7101,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7176,8 +7157,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7217,8 +7197,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7282,8 +7261,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7314,10 +7292,8 @@ See \`config.log' for more details." >&2 esac else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -8520,11 +8496,6 @@ esac *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -8563,6 +8534,12 @@ echo "$as_me: error: cannot find input f fi;; esac done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub @@ -9140,7 +9117,7 @@ echo "$as_me: error: $ac_sub_configure f { (exit 1); exit 1; }; } fi - cd $ac_popdir + cd "$ac_popdir" done fi --- ./configure.in.~1~ 2006-02-23 01:17:13.000000000 -0800 +++ ./configure.in 2006-02-23 16:03:19.000000000 -0800 @@ -462,10 +462,14 @@ sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) base_machine=sparc machine=sparc/sparc32/sparcv9b ;; +sparcv9v) + base_machine=sparc machine=sparc/sparc32/sparcv9v ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) base_machine=sparc machine=sparc/sparc64/sparcv9b ;; +sparc64v) + base_machine=sparc machine=sparc/sparc64/sparcv9v ;; *) base_machine=$machine ;; esac changequote([,])dnl From davem@davemloft.net Fri Feb 24 23:47:00 2006 From: davem@davemloft.net (David S. Miller) Date: Fri, 24 Feb 2006 23:47:00 -0000 Subject: [PATCH]: Missing Sparc Implies Message-ID: <20060224.154757.73620976.davem@davemloft.net> Some sparcv9b/Implies files were missing under NPTL breaking the build of target sparcv9b-* with NPTL enabled. Please apply, thanks. 2006-02-24 David S. Miller * sysdeps/sparc/sparc32/sparcv9b/Implies: New file. * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies: New file. --- ./nptl/sysdeps/sparc/sparc32/sparcv9b/Implies.~1~ 2006-02-23 16:55:11.000000000 -0800 +++ ./nptl/sysdeps/sparc/sparc32/sparcv9b/Implies 2006-02-23 16:55:03.000000000 -0800 @@ -0,0 +1 @@ +sparc/sparc32/sparcv9 --- ./nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies.~1~ 2006-02-23 16:53:32.000000000 -0800 +++ ./nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies 2006-02-23 16:54:35.000000000 -0800 @@ -0,0 +1 @@ +unix/sysv/linux/sparc/sparc32/sparcv9 From roland@redhat.com Sat Feb 25 00:47:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 00:47:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: David S. Miller's message of Friday, 24 February 2006 15:47:57 -0800 <20060224.154757.73620976.davem@davemloft.net> Message-ID: <20060225004708.DC740180A66@magilla.sf.frob.com> I don't think ought to be necessary. If it is, I'd like to fix the configure magic so it's not. Those Implies files from the main source should cause those add-on directories to be searched too. From roland@redhat.com Sat Feb 25 01:08:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:08:00 -0000 Subject: [PATCH]: Sparc SUN4V Niagara optimize memset/memcpy In-Reply-To: David S. Miller's message of Friday, 24 February 2006 15:46:07 -0800 <20060224.154607.114276042.davem@davemloft.net> Message-ID: <20060225010823.67469180A66@magilla.sf.frob.com> > I've sent a patch for scripts/config.sub to config-patches the other > day, so that part of adding sparcv9v and sparc64v should show up > eventually. As a rule we don't put in new configuration support until the canonical config.sub groks it. > This adds the "sparcv9v-*" and "sparc64v-*" build targets, the > optimized memcpy/memset for that platform, and the necessary Implies > files. I think this would be better done without Implies files. Just use machine=sparc/sparc32/sparcv9/sparcv9v and the right things should happen. Thanks, Roland From davem@davemloft.net Sat Feb 25 01:24:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:24:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: <20060225004708.DC740180A66@magilla.sf.frob.com> References: <20060224.154757.73620976.davem@davemloft.net> <20060225004708.DC740180A66@magilla.sf.frob.com> Message-ID: <20060224.172413.37789507.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 16:47:08 -0800 (PST) > I don't think ought to be necessary. If it is, I'd like to fix the > configure magic so it's not. Those Implies files from the main source > should cause those add-on directories to be searched too. This doesn't happen in the top-level either, that's why we need sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies and friends eventhough we have sysdeps/sparc/sparc32/sparcv9b/Implies. From davem@davemloft.net Sat Feb 25 01:29:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:29:00 -0000 Subject: [PATCH]: Sparc SUN4V Niagara optimize memset/memcpy In-Reply-To: <20060225010823.67469180A66@magilla.sf.frob.com> References: <20060224.154607.114276042.davem@davemloft.net> <20060225010823.67469180A66@magilla.sf.frob.com> Message-ID: <20060224.172917.09191154.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 17:08:23 -0800 (PST) > > I've sent a patch for scripts/config.sub to config-patches the other > > day, so that part of adding sparcv9v and sparc64v should show up > > eventually. > > As a rule we don't put in new configuration support until the canonical > config.sub groks it. config.sub really puts an unreasonable monkey wrench into the works for doing development of new build targets for any GNU package. It ususally takes about a week for a config.sub patch get handled, integrated, and propagated into the necessary trees. Nothing impedes forward progress quite like this thing. > > This adds the "sparcv9v-*" and "sparc64v-*" build targets, the > > optimized memcpy/memset for that platform, and the necessary Implies > > files. > > I think this would be better done without Implies files. Just use > machine=sparc/sparc32/sparcv9/sparcv9v and the right things should happen. Will that actually work? I thought "machine=" takes a file path name, not a list of compatible targets. For example: sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; I read that as meaning: search ${foo}/sparc/sparc32/sparcv9, else ${foo}/sparc/sparc32, else ${foo}/sparc From roland@redhat.com Sat Feb 25 01:41:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:41:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: David S. Miller's message of Friday, 24 February 2006 17:24:13 -0800 <20060224.172413.37789507.davem@davemloft.net> Message-ID: <20060225014143.62DA3180A66@magilla.sf.frob.com> > From: Roland McGrath > Date: Fri, 24 Feb 2006 16:47:08 -0800 (PST) > > > I don't think ought to be necessary. If it is, I'd like to fix the > > configure magic so it's not. Those Implies files from the main source > > should cause those add-on directories to be searched too. > > This doesn't happen in the top-level either, that's why we need > sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies and friends > eventhough we have sysdeps/sparc/sparc32/sparcv9b/Implies. I'm not following you. The main tree tree has sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies already. Another one should not be required in the add-on too. The one would not be required either if we used sparcv9/sparcv9b instead. From roland@redhat.com Sat Feb 25 01:45:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:45:00 -0000 Subject: [PATCH]: Sparc SUN4V Niagara optimize memset/memcpy In-Reply-To: David S. Miller's message of Friday, 24 February 2006 17:29:17 -0800 <20060224.172917.09191154.davem@davemloft.net> Message-ID: <20060225014529.7330B180A66@magilla.sf.frob.com> > It ususally takes about a week for a config.sub patch get handled, > integrated, and propagated into the necessary trees. Nothing impedes > forward progress quite like this thing. Sorry. I take them as soon as it's agreed to by config-patches. > I thought "machine=" takes a file path name, not a list of compatible > targets. For example: It's a directory name, not a list, yes. But all directories always imply their parents. > sparcv8plus | sparcv8plusa | sparcv9) > base_machine=sparc machine=sparc/sparc32/sparcv9 ;; > > I read that as meaning: search ${foo}/sparc/sparc32/sparcv9, else > ${foo}/sparc/sparc32, else ${foo}/sparc Try --enable-debug-configure. The sysdeps directory list is an ordered list of many directories. That gets */sparc/sparc32/sparcv9 if it exists, followed by */sparc/sparc32 if it exists, followed by */sparc if it exists. Since something can't exist without its containing directory existing too, you'll always get a trailing subset of that list. Thanks, Roland From davem@davemloft.net Sat Feb 25 01:45:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:45:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: <20060225014143.62DA3180A66@magilla.sf.frob.com> References: <20060224.172413.37789507.davem@davemloft.net> <20060225014143.62DA3180A66@magilla.sf.frob.com> Message-ID: <20060224.174518.102972954.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 17:41:43 -0800 (PST) > > From: Roland McGrath > > Date: Fri, 24 Feb 2006 16:47:08 -0800 (PST) > > > > > I don't think ought to be necessary. If it is, I'd like to fix the > > > configure magic so it's not. Those Implies files from the main source > > > should cause those add-on directories to be searched too. > > > > This doesn't happen in the top-level either, that's why we need > > sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies and friends > > eventhough we have sysdeps/sparc/sparc32/sparcv9b/Implies. > > I'm not following you. The main tree tree has > sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies already. > Another one should not be required in the add-on too. > The one would not be required either if we used sparcv9/sparcv9b instead. I guess I don't understand how the "machine=" specification in the configure scripts work... They look like file path names that the build machinery tries one by one like this: machine=a/b/c/d step 1) try $(foo)/a/b/c/d step 2) try $(foo)/a/b/c step 3) try $(foo)/a/b step 4) try $(foo)/a You seem to be suggesting that it works another way. From roland@redhat.com Sat Feb 25 01:46:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:46:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: David S. Miller's message of Friday, 24 February 2006 17:45:18 -0800 <20060224.174518.102972954.davem@davemloft.net> Message-ID: <20060225014635.A39D4180A66@magilla.sf.frob.com> > I guess I don't understand how the "machine=" specification in the > configure scripts work... They look like file path names that the > build machinery tries one by one like this: > > machine=a/b/c/d > > step 1) try $(foo)/a/b/c/d > step 2) try $(foo)/a/b/c > step 3) try $(foo)/a/b > step 4) try $(foo)/a > > You seem to be suggesting that it works another way. It sounds like you think there's an OR. It's an AND. From roland@redhat.com Sat Feb 25 01:49:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:49:00 -0000 Subject: [PATCH]: Recognize HWCAP_SPARC_BLKINIT In-Reply-To: David S. Miller's message of Friday, 24 February 2006 15:37:09 -0800 <20060224.153709.86558879.davem@davemloft.net> Message-ID: <20060225014901.07E12180A66@magilla.sf.frob.com> > SUN4V Niagara processors have a load-twin/block-init-store capability > which is indicated by bit 6 in the HWCAP_* mask from the kernel. I don't see HWCAP_SPARC_BLKINIT in current Linus kernel sources. Have the name and value been firmly agreed to? Thanks, Roland From davem@davemloft.net Sat Feb 25 01:51:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:51:00 -0000 Subject: [PATCH]: Recognize HWCAP_SPARC_BLKINIT In-Reply-To: <20060225014901.07E12180A66@magilla.sf.frob.com> References: <20060224.153709.86558879.davem@davemloft.net> <20060225014901.07E12180A66@magilla.sf.frob.com> Message-ID: <20060224.175126.118926498.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 17:49:01 -0800 (PST) > > SUN4V Niagara processors have a load-twin/block-init-store capability > > which is indicated by bit 6 in the HWCAP_* mask from the kernel. > > I don't see HWCAP_SPARC_BLKINIT in current Linus kernel sources. > Have the name and value been firmly agreed to? Yes, I maintain the sparc64 port and the values will be added by this tree: master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.17.git once Linus opens up the 2.6.17 development phase. From davem@davemloft.net Sat Feb 25 01:58:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:58:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: <20060225014635.A39D4180A66@magilla.sf.frob.com> References: <20060224.174518.102972954.davem@davemloft.net> <20060225014635.A39D4180A66@magilla.sf.frob.com> Message-ID: <20060224.175858.05656238.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 17:46:35 -0800 (PST) > It sounds like you think there's an OR. It's an AND. How does this look? 2006-02-24 David S. Miller * configure.in: Add sparcv9 to machine for sparcv9b * configure: Regenerate * sysdeps/sparc/sparc32/sparcv9b/Implies: Delete. * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies: Delete. --- ./sysdeps/sparc/sparc32/sparcv9b/Implies.~1~ 2001-04-06 15:34:09.000000000 -0700 +++ ./sysdeps/sparc/sparc32/sparcv9b/Implies 2006-02-24 17:54:10.000000000 -0800 @@ -1 +0,0 @@ -sparc/sparc32/sparcv9 --- ./sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies.~1~ 2006-02-24 17:57:29.000000000 -0800 +++ ./sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies 2006-02-24 17:57:36.000000000 -0800 @@ -1 +0,0 @@ -unix/sysv/linux/sparc/sparc32/sparcv9 --- ./configure.in.~1~ 2006-02-23 01:17:13.000000000 -0800 +++ ./configure.in 2006-02-24 17:53:02.000000000 -0800 @@ -461,7 +461,7 @@ sparcv8 | supersparc | hypersparc) sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) - base_machine=sparc machine=sparc/sparc32/sparcv9b ;; + base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) --- ./configure.~1~ 2006-02-23 01:17:13.000000000 -0800 +++ ./configure 2006-02-24 17:53:20.000000000 -0800 @@ -1975,7 +1975,7 @@ sparcv8 | supersparc | hypersparc) sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) - base_machine=sparc machine=sparc/sparc32/sparcv9b ;; + base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) From davem@davemloft.net Sat Feb 25 01:59:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 01:59:00 -0000 Subject: [PATCH]: Recognize HWCAP_SPARC_BLKINIT In-Reply-To: <20060225015905.927E5180A66@magilla.sf.frob.com> References: <20060224.153709.86558879.davem@davemloft.net> <20060225015905.927E5180A66@magilla.sf.frob.com> Message-ID: <20060224.175930.128687767.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 17:59:05 -0800 (PST) > I consolidated the sparc dl-procinfo stuff to avoid the duplication, > and the merged in your addition. Thanks Roland. From roland@redhat.com Sat Feb 25 01:59:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 01:59:00 -0000 Subject: [PATCH]: Recognize HWCAP_SPARC_BLKINIT In-Reply-To: David S. Miller's message of Friday, 24 February 2006 15:37:09 -0800 <20060224.153709.86558879.davem@davemloft.net> Message-ID: <20060225015905.927E5180A66@magilla.sf.frob.com> I consolidated the sparc dl-procinfo stuff to avoid the duplication, and the merged in your addition. Thanks, Roland From roland@redhat.com Sat Feb 25 02:00:00 2006 From: roland@redhat.com (Roland McGrath) Date: Sat, 25 Feb 2006 02:00:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: David S. Miller's message of Friday, 24 February 2006 17:58:58 -0800 <20060224.175858.05656238.davem@davemloft.net> Message-ID: <20060225020039.B931F180A66@magilla.sf.frob.com> > 2006-02-24 David S. Miller > > * configure.in: Add sparcv9 to machine for sparcv9b > * configure: Regenerate > * sysdeps/sparc/sparc32/sparcv9b/Implies: Delete. > * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies: Delete. This looks right to me. But please verify that is actually behaves correctly as I've said it will. Thanks, Roland From davem@davemloft.net Sat Feb 25 02:07:00 2006 From: davem@davemloft.net (David S. Miller) Date: Sat, 25 Feb 2006 02:07:00 -0000 Subject: [PATCH]: Missing Sparc Implies In-Reply-To: <20060225020039.B931F180A66@magilla.sf.frob.com> References: <20060224.175858.05656238.davem@davemloft.net> <20060225020039.B931F180A66@magilla.sf.frob.com> Message-ID: <20060224.180755.67155031.davem@davemloft.net> From: Roland McGrath Date: Fri, 24 Feb 2006 18:00:39 -0800 (PST) > > 2006-02-24 David S. Miller > > > > * configure.in: Add sparcv9 to machine for sparcv9b > > * configure: Regenerate > > * sysdeps/sparc/sparc32/sparcv9b/Implies: Delete. > > * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9b/Implies: Delete. > > This looks right to me. But please verify that is actually behaves > correctly as I've said it will. It does, here is what we get for sysdep dirs for sparc9b-linux with that patch applied: sysdeps/sparc/sparc32/elf sysdeps/sparc/elf nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 sysdeps/unix/sysv/linux/sparc/sparc32/fpu sysdeps/sparc/sparc32/fpu nptl/sysdeps/unix/sysv/linux/sparc/sparc32 sysdeps/unix/sysv/linux/sparc/sparc32 sysdeps/ieee754/ldbl-64-128 sysdeps/ieee754/ldbl-opt nptl/sysdeps/unix/sysv/linux/sparc sysdeps/unix/sysv/linux/sparc nptl/sysdeps/unix/sysv/linux nptl/sysdeps/pthread sysdeps/pthread sysdeps/unix/sysv/linux sysdeps/gnu sysdeps/unix/common sysdeps/unix/mman sysdeps/unix/inet nptl/sysdeps/unix/sysv sysdeps/unix/sysv sysdeps/unix/sparc nptl/sysdeps/unix sysdeps/unix sysdeps/posix nptl/sysdeps/sparc/sparc32/sparcv9 sysdeps/sparc/sparc32/sparcv9 nptl/sysdeps/sparc/sparc32 sysdeps/sparc/sparc32 sysdeps/wordsize-32 sysdeps/ieee754/ldbl-128 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/sparc/sparc32/soft-fp sysdeps/sparc/fpu nptl/sysdeps/sparc sysdeps/sparc nptl/sysdeps/generic sysdeps/ieee754 sysdeps/generic/elf sysdeps/generic The directories added compare to before my patch are: nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 nptl/sysdeps/sparc/sparc32/sparcv9 sysdeps/sparc/sparc32/sparcv9 Which is exactly what we want. From munroesj@us.ibm.com Mon Feb 27 20:52:00 2006 From: munroesj@us.ibm.com (Steven Munroe) Date: Mon, 27 Feb 2006 20:52:00 -0000 Subject: Broken build from libc cvs trunk Message-ID: <440368AD.3010308@us.ibm.com> Roland are you in the middle of rearranging the lowlevellocking support? CVS trunk is broken with: ../nptl/lowlevellock.h:46: error: redefinition of ??__generic_mutex_lock?? ../nptl/lowlevellock.h:46: error: previous definition of ??__generic_mutex_lock?? was here ../nptl/lowlevellock.h:76: error: redefinition of ??__generic_mutex_unlock?? ../nptl/lowlevellock.h:76: error: previous definition of ??__generic_mutex_unlock?? was here Is there something the platforms need to do? or should we just stay out of your way ;-) From roland@redhat.com Mon Feb 27 20:56:00 2006 From: roland@redhat.com (Roland McGrath) Date: Mon, 27 Feb 2006 20:56:00 -0000 Subject: Broken build from libc cvs trunk In-Reply-To: Steven Munroe's message of Monday, 27 February 2006 15:01:33 -0600 <440368AD.3010308@us.ibm.com> Message-ID: <20060227205651.AE4B5180B17@magilla.sf.frob.com> I am in the middle of changing the configury around. I didn't think the parts I'd already checked in broke things, but I guess I was wrong. Sorry about that. Just sit tight until later on today. Thanks, Roland From sjmunroe@us.ibm.com Mon Feb 27 21:06:00 2006 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Mon, 27 Feb 2006 21:06:00 -0000 Subject: Broken build from libc cvs trunk In-Reply-To: <20060227205651.AE4B5180B17@magilla.sf.frob.com> Message-ID: Roland McGrath wrote on 02/27/2006 02:56:51 PM: > I am in the middle of changing the configury around. I didn't think the > parts I'd already checked in broke things, but I guess I was wrong. > Sorry about that. Just sit tight until later on today. > np, thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jakub@redhat.com Mon Feb 27 23:04:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 27 Feb 2006 23:04:00 -0000 Subject: [PATCH] PTHREAD_PRIO_{INHERIT,PROTECT} mutexes (so far just stubs) Message-ID: <20060227230419.GE30252@sunsite.mff.cuni.cz> Hi! This patch adds stubs for TPI/TPP support (but doesn't enable the options in bits/posix_opt.h yet). What is missing is handling these kind of mutexes in pthread_mutex_{lock,trylock,unlock,timedlock}.c and adding some corresponding locking for pthread_mutex_setprioceiling.c. 2006-02-27 Jakub Jelinek * Makefile (libpthread-routines): Add pthread_mutexattr_[sg]etprotocol, pthread_mutexattr_[sg]etprioceiling and pthread_mutex_[sg]etprioceiling. * Versions (GLIBC_2.4): Export pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling and pthread_mutex_setprioceiling. * sysdeps/pthread/pthread.h (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT): New enum values. (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling, pthread_mutex_setprioceiling): New prototypes. * pthreadP.h (PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP, PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP): New enum values. (PTHREAD_MUTEX_PRIO_CEILING_SHIFT, PTHREAD_MUTEX_PRIO_CEILING_MASK): Define. (PTHREAD_MUTEXATTR_PROTOCOL_SHIFT, PTHREAD_MUTEXATTR_PROTOCOL_MASK, PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT, PTHREAD_MUTEXATTR_PRIO_CEILING_MASK): Define. (PTHREAD_MUTEXATTR_FLAG_BITS): Or in PTHREAD_MUTEXATTR_PROTOCOL_MASK and PTHREAD_MUTEXATTR_PRIO_CEILING_MASK. * pthread_mutex_init.c (__pthread_mutex_init): For the time being return ENOTSUP for PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT protocol mutexes. * pthread_mutex_getprioceiling.c: New file. * pthread_mutex_setprioceiling.c: New file. * pthread_mutexattr_getprioceiling.c: New file. * pthread_mutexattr_setprioceiling.c: New file. * pthread_mutexattr_getprotocol.c: New file. * pthread_mutexattr_setprotocol.c: New file. --- libc/nptl/sysdeps/pthread/pthread.h.jj 2006-02-17 09:09:45.000000000 +0100 +++ libc/nptl/sysdeps/pthread/pthread.h 2006-02-27 18:43:06.000000000 +0100 @@ -71,6 +71,17 @@ enum #endif +#ifdef __USE_UNIX98 +/* Mutex protocols. */ +enum +{ + PTHREAD_PRIO_NONE, + PTHREAD_PRIO_INHERIT, + PTHREAD_PRIO_PROTECT +}; +#endif + + /* Mutex initializers. */ #if __WORDSIZE == 64 # define PTHREAD_MUTEX_INITIALIZER \ @@ -711,6 +722,22 @@ extern int pthread_mutex_timedlock (pthr extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW; +#ifdef __USE_UNIX98 +/* Get the priority ceiling of MUTEX. */ +extern int pthread_mutex_getprioceiling (__const pthread_mutex_t * + __restrict __mutex, + int *__restrict __prioceiling) + __THROW; + +/* Set the priority ceiling of MUTEX to PRIOCEILING, return old + priority ceiling value in *OLD_CEILING. */ +extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, + int __prioceiling, + int *__restrict __old_ceiling) + __THROW; +#endif + + #ifdef __USE_GNU /* Declare the state protected by MUTEX as consistent. */ extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex) __THROW; @@ -745,6 +772,26 @@ extern int pthread_mutexattr_gettype (__ PTHREAD_MUTEX_DEFAULT). */ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) __THROW; + +/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */ +extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __protocol) __THROW; + +/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either + PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */ +extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, + int __protocol) __THROW; + +/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */ +extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t * + __restrict __attr, + int *__restrict __prioceiling) + __THROW; + +/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */ +extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, + int __prioceiling) __THROW; #endif #ifdef __USE_GNU --- libc/nptl/Makefile.jj 2006-02-17 09:09:45.000000000 +0100 +++ libc/nptl/Makefile 2006-02-27 18:43:06.000000000 +0100 @@ -118,7 +118,12 @@ libpthread-routines = init vars events v pthread_attr_getaffinity pthread_attr_setaffinity \ pthread_mutexattr_getrobust pthread_mutexattr_setrobust \ pthread_mutex_consistent \ - cleanup_routine unwind-forcedunwind + cleanup_routine unwind-forcedunwind \ + pthread_mutexattr_getprotocol \ + pthread_mutexattr_setprotocol \ + pthread_mutexattr_getprioceiling \ + pthread_mutexattr_setprioceiling \ + pthread_mutex_getprioceiling pthread_mutex_setprioceiling # pthread_setuid pthread_seteuid pthread_setreuid \ # pthread_setresuid \ # pthread_setgid pthread_setegid pthread_setregid \ --- libc/nptl/pthread_mutexattr_getprioceiling.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutexattr_getprioceiling.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,36 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_getprioceiling (attr, prioceiling) + const pthread_mutexattr_t *attr; + int *prioceiling; +{ + const struct pthread_mutexattr *iattr; + + iattr = (const struct pthread_mutexattr *) attr; + + *prioceiling = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT); + + return 0; +} --- libc/nptl/pthread_mutexattr_getprotocol.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutexattr_getprotocol.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,36 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_getprotocol (attr, protocol) + const pthread_mutexattr_t *attr; + int *protocol; +{ + const struct pthread_mutexattr *iattr; + + iattr = (const struct pthread_mutexattr *) attr; + + *protocol = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT); + + return 0; +} --- libc/nptl/pthread_mutex_getprioceiling.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutex_getprioceiling.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,32 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutex_getprioceiling (mutex, prioceiling) + const pthread_mutex_t *mutex; + int *prioceiling; +{ + *prioceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK) + >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + + return 0; +} --- libc/nptl/pthread_mutex_init.c.jj 2005-12-30 09:04:04.000000000 +0100 +++ libc/nptl/pthread_mutex_init.c 2006-02-27 18:44:39.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -46,6 +46,11 @@ __pthread_mutex_init (mutex, mutexattr) if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0 && (imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0) return ENOTSUP; + // XXX For now we don't support priority inherited or priority protected + // XXX mutexes. + if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + != (PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT)) + return ENOTSUP; /* Clear the whole variable. */ memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T); @@ -54,6 +59,27 @@ __pthread_mutex_init (mutex, mutexattr) mutex->__data.__kind = imutexattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS; if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0) mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_PRIVATE_NP; + switch ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK) + >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT) + { + case PTHREAD_PRIO_INHERIT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP; + break; + case PTHREAD_PRIO_PROTECT: + mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP; + if (PTHREAD_MUTEX_PRIO_CEILING_MASK + == PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + mutex->__data.__kind |= (imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK); + else + mutex->__data.__kind |= ((imutexattr->mutexkind + & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT) + << PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + break; + default: + break; + } /* Default values: mutex not used yet. */ // mutex->__count = 0; already done by memset --- libc/nptl/pthread_mutexattr_setprioceiling.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutexattr_setprioceiling.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,39 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_setprioceiling (attr, prioceiling) + pthread_mutexattr_t *attr; + int prioceiling; +{ + if (prioceiling < 0 + && __builtin_expect (prioceiling > 255, 0)) + return EINVAL; + + struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr; + + iattr->mutexkind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) + | (prioceiling << PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT); + + return 0; +} --- libc/nptl/pthreadP.h.jj 2006-02-17 09:09:45.000000000 +0100 +++ libc/nptl/pthreadP.h 2006-02-27 18:43:06.000000000 +0100 @@ -66,15 +66,24 @@ enum PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP - = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP + = PTHREAD_MUTEX_ROBUST_PRIVATE_NP | PTHREAD_MUTEX_ADAPTIVE_NP, + PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP = 32, + PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP = 64 }; +#define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 16 +#define PTHREAD_MUTEX_PRIO_CEILING_MASK 0x00ff0000 /* Flags in mutex attr. */ -#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 -#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 +#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28 +#define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000 +#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 16 +#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00ff0000 +#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 +#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 #define PTHREAD_MUTEXATTR_FLAG_BITS \ - (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED) + (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \ + | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) /* Bits used in robust mutex implementation. */ --- libc/nptl/Versions.jj 2005-12-30 09:04:04.000000000 +0100 +++ libc/nptl/Versions 2006-02-27 18:43:06.000000000 +0100 @@ -235,6 +235,9 @@ libpthread { GLIBC_2.4 { pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np; pthread_mutex_consistent_np; + pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol; + pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling; + pthread_mutex_getprioceiling; pthread_mutex_setprioceiling; }; GLIBC_PRIVATE { --- libc/nptl/pthread_mutex_setprioceiling.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutex_setprioceiling.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,55 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling) + pthread_mutex_t *mutex; + int prioceiling; + int *old_ceiling; +{ + /* The low bits of __kind aren't ever changed after pthread_mutex_init, + so we don't need a lock yet. */ + if ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP) == 0) + return EINVAL; + + if (prioceiling < 0 + && __builtin_expect (prioceiling > 255, 0)) + return EINVAL; + + /* XXX This needs to lock with TID, but shouldn't obey priority protect + protocol. */ + /* lll_xxx_mutex_lock (mutex->__data.__lock); */ + + if (old_ceiling != NULL) + *old_ceiling = (mutex->__data.__kind & PTHREAD_MUTEX_PRIO_CEILING_MASK) + >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT; + + int newkind = (mutex->__data.__kind & ~PTHREAD_MUTEX_PRIO_CEILING_MASK); + mutex->__data.__kind = newkind + | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT); + + /* XXX This needs to unlock the above special kind of lock. */ + /* lll_xxx_mutex_unlock (mutex->__data.__lock); */ + + return 0; +} --- libc/nptl/pthread_mutexattr_setprotocol.c.jj 2006-02-27 18:43:06.000000000 +0100 +++ libc/nptl/pthread_mutexattr_setprotocol.c 2006-02-27 18:43:06.000000000 +0100 @@ -0,0 +1,40 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2006. + + 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 + + +int +pthread_mutexattr_setprotocol (attr, protocol) + pthread_mutexattr_t *attr; + int protocol; +{ + if (protocol != PTHREAD_PRIO_NONE + && protocol != PTHREAD_PRIO_INHERIT + && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0)) + return EINVAL; + + struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr; + + iattr->mutexkind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_PROTOCOL_MASK) + | (protocol << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT); + + return 0; +} Jakub From davem@davemloft.net Tue Feb 28 09:28:00 2006 From: davem@davemloft.net (David S. Miller) Date: Tue, 28 Feb 2006 09:28:00 -0000 Subject: failed creation of rtld-libc.aT archive Message-ID: <20060228.012806.117623612.davem@davemloft.net> It's trying to add in rtld-check_fd.os from the csu/ directory, but that shared object gets built into elf/ I can't figure out why this is happening. This is with current CVS. From roland@redhat.com Tue Feb 28 09:31:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 09:31:00 -0000 Subject: failed creation of rtld-libc.aT archive In-Reply-To: David S. Miller's message of Tuesday, 28 February 2006 01:28:06 -0800 <20060228.012806.117623612.davem@davemloft.net> Message-ID: <20060228093154.1DF6F180B18@magilla.sf.frob.com> You really need to post the actual details for something like that. From roland@redhat.com Tue Feb 28 09:36:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 09:36:00 -0000 Subject: [PATCH] PTHREAD_PRIO_{INHERIT,PROTECT} mutexes (so far just stubs) In-Reply-To: Jakub Jelinek's message of Tuesday, 28 February 2006 00:04:19 +0100 <20060227230419.GE30252@sunsite.mff.cuni.cz> Message-ID: <20060228093646.A6738180B18@magilla.sf.frob.com> I put this in with a couple of cosmetic changes. Thanks, Roland From davem@davemloft.net Tue Feb 28 09:39:00 2006 From: davem@davemloft.net (David S. Miller) Date: Tue, 28 Feb 2006 09:39:00 -0000 Subject: failed creation of rtld-libc.aT archive In-Reply-To: <20060228093154.1DF6F180B18@magilla.sf.frob.com> References: <20060228.012806.117623612.davem@davemloft.net> <20060228093154.1DF6F180B18@magilla.sf.frob.com> Message-ID: <20060228.013909.12750313.davem@davemloft.net> From: Roland McGrath Date: Tue, 28 Feb 2006 01:31:54 -0800 (PST) > You really need to post the actual details for something like that. I'm testing the newer sparcv9v patches, so I'm building for a sparcv9v-linux target. The archive creation looks for: ar cqv /home/davem/src/GLIBC/cvs/build-sparcv9v-linux/elf/rtld-libc.aT ... build-sparcv9v-linux/csu/rtld-check_fds.os ... ar: /home/davem/src/GLIBC/cvs/build-sparcv9v-linux/csu/rtld-check_fds.os: No such file or directory But this object actually gets built like so into the build-sparcv9v-linux/elf/ subdirectory: gcc check_fds.c -c -std=gnu99 -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -g -Wstrict-prototypes -mlong-double-128 -mcpu=ultrasparc -Wa,-Av9a -fPIC -I../include -I/home/davem/src/GLIBC/cvs/build-sparcv9v-linux/elf -I/home/davem/src/GLIBC/cvs/build-sparcv9v-linux -I../sysdeps/sparc/sparc32/elf -I../sysdeps/sparc/elf -I../nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 -I../sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9 -I../sysdeps/unix/sysv/linux/sparc/sparc32/fpu -I../sysdeps/sparc/sparc32/fpu -I../nptl/sysdeps/unix/sysv/linux/sparc/sparc32 -I../sysdeps/unix/sysv/linux/sparc/sparc32 -I../sysdeps/ieee754/ldbl-64-128 -I../sysdeps/ieee754/ldbl-opt -I../nptl/sysdeps/unix/sysv/linux/sparc -I../sysdeps/unix/sysv/linux/sparc -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/sparc -I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../nptl/sysdeps/sparc/sparc32/sparcv9 -I../sysdeps/sparc/sparc32/sparcv9 -I../nptl/sysdeps/sparc/sparc32 -I../sysdeps/sparc/sparc32 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-128 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/sparc/sparc32/soft-fp -I../sysdeps/sparc/fpu -I../nptl/sysdeps/sparc -I../sysdeps/sparc -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/sparc-linux-gnu/4.0.3/include -isystem /usr/include/ -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DPIC -DSHARED -DHAVE_INITFINI -DNOT_IN_libc=1 -DIS_IN_rtld=1 -o /home/davem/src/GLIBC/cvs/build-sparcv9v-linux/elf/rtld-check_fds.os -MD -MP -MF /home/davem/src/GLIBC/cvs/build-sparcv9v-linux/elf/rtld-check_fds.os.dt -MT /home/davem/src/GLIBC/cvs/build-sparcv9v-linux/elf/rtld-check_fds.os The patch I'm testing is included below for reference, the configure changes are very simple and should be the only bits that could potentially cause this problem, I think :-) Let me know if you need any more information to diagnose this. Thanks. --- ./sysdeps/sparc/sparc32/sparcv9v/memset.S.~1~ 2006-02-28 00:45:52.000000000 -0800 +++ ./sysdeps/sparc/sparc32/sparcv9v/memset.S 2006-02-28 00:45:03.000000000 -0800 @@ -0,0 +1,2 @@ +#define XCC icc +#include --- ./sysdeps/sparc/sparc32/sparcv9v/memcpy.S.~1~ 2006-02-28 00:45:38.000000000 -0800 +++ ./sysdeps/sparc/sparc32/sparcv9v/memcpy.S 2006-02-28 00:45:03.000000000 -0800 @@ -0,0 +1,2 @@ +#define XCC icc +#include --- ./sysdeps/sparc/sparc64/sparcv9v/memcpy.S.~1~ 2006-02-28 00:46:09.000000000 -0800 +++ ./sysdeps/sparc/sparc64/sparcv9v/memcpy.S 2006-02-28 00:45:03.000000000 -0800 @@ -0,0 +1,594 @@ +/* Copy SIZE bytes from SRC to DEST. + For SUN4V Niagara. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller (davem@davemloft.net) + + 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 + +#define ASI_BLK_INIT_QUAD_LDD_P 0xe2 +#define ASI_P 0x80 +#define ASI_PNF 0x82 + +#define LOAD(type,addr,dest) type##a [addr] ASI_P, dest +#define LOAD_TWIN(addr_reg,dest0,dest1) \ + ldda [addr_reg] ASI_BLK_INIT_QUAD_LDD_P, dest0 + +#define STORE(type,src,addr) type src, [addr] +#define STORE_INIT(src,addr) stxa src, [addr] %asi + +#ifndef XCC +#define USE_BPR +#define XCC xcc +#endif + + .register %g2,#scratch + .register %g3,#scratch + .register %g6,#scratch + + .text + .align 32 + +ENTRY(bcopy) + sub %o1, %o0, %o4 + mov %o0, %g4 + cmp %o4, %o2 + mov %o1, %o0 + bgeu,pt %XCC, 100f + mov %g4, %o1 +#ifndef USE_BPR + srl %o2, 0, %o2 +#endif + brnz,pn %o2, 220f + add %o0, %o2, %o0 + retl + nop +END(bcopy) + + .align 32 +ENTRY(memcpy) +100: /* %o0=dst, %o1=src, %o2=len */ + mov %o0, %g5 + cmp %o2, 0 + be,pn %XCC, 85f +218: or %o0, %o1, %o3 + cmp %o2, 16 + blu,a,pn %XCC, 80f + or %o3, %o2, %o3 + + /* 2 blocks (128 bytes) is the minimum we can do the block + * copy with. We need to ensure that we'll iterate at least + * once in the block copy loop. At worst we'll need to align + * the destination to a 64-byte boundary which can chew up + * to (64 - 1) bytes from the length before we perform the + * block copy loop. + */ + cmp %o2, (2 * 64) + blu,pt %XCC, 70f + andcc %o3, 0x7, %g0 + + /* %o0: dst + * %o1: src + * %o2: len (known to be >= 128) + * + * The block copy loops will use %o4/%o5,%g2/%g3 as + * temporaries while copying the data. + */ + + LOAD(prefetch, %o1, #one_read) + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi + + /* Align destination on 64-byte boundary. */ + andcc %o0, (64 - 1), %o4 + be,pt %XCC, 2f + sub %o4, 64, %o4 + sub %g0, %o4, %o4 ! bytes to align dst + sub %o2, %o4, %o2 +1: subcc %o4, 1, %o4 + LOAD(ldub, %o1, %g1) + STORE(stb, %g1, %o0) + add %o1, 1, %o1 + bne,pt %XCC, 1b + add %o0, 1, %o0 + + /* If the source is on a 16-byte boundary we can do + * the direct block copy loop. If it is 8-byte aligned + * we can do the 16-byte loads offset by -8 bytes and the + * init stores offset by one register. + * + * If the source is not even 8-byte aligned, we need to do + * shifting and masking (basically integer faligndata). + * + * The careful bit with init stores is that if we store + * to any part of the cache line we have to store the whole + * cacheline else we can end up with corrupt L2 cache line + * contents. Since the loop works on 64-bytes of 64-byte + * aligned store data at a time, this is easy to ensure. + */ +2: + andcc %o1, (16 - 1), %o4 + andn %o2, (64 - 1), %g1 ! block copy loop iterator + sub %o2, %g1, %o2 ! final sub-block copy bytes + be,pt %XCC, 50f + cmp %o4, 8 + be,a,pt %XCC, 10f + sub %o1, 0x8, %o1 + + /* Neither 8-byte nor 16-byte aligned, shift and mask. */ + mov %g1, %o4 + and %o1, 0x7, %g1 + sll %g1, 3, %g1 + mov 64, %o3 + andn %o1, 0x7, %o1 + LOAD(ldx, %o1, %g2) + sub %o3, %g1, %o3 + sllx %g2, %g1, %g2 + +#define SWIVEL_ONE_DWORD(SRC, TMP1, TMP2, PRE_VAL, PRE_SHIFT, POST_SHIFT, DST)\ + LOAD(ldx, SRC, TMP1); \ + srlx TMP1, PRE_SHIFT, TMP2; \ + or TMP2, PRE_VAL, TMP2; \ + STORE_INIT(TMP2, DST); \ + sllx TMP1, POST_SHIFT, PRE_VAL; + +1: add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x00) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x08) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x10) + add %o1, 0x8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x18) + add %o1, 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32 - 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x20) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x28) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x30) + add %o1, 8, %o1 + SWIVEL_ONE_DWORD(%o1, %g3, %o5, %g2, %o3, %g1, %o0 + 0x38) + subcc %o4, 64, %o4 + bne,pt %XCC, 1b + add %o0, 64, %o0 + +#undef SWIVEL_ONE_DWORD + + srl %g1, 3, %g1 + ba,pt %XCC, 60f + add %o1, %g1, %o1 + +10: /* Destination is 64-byte aligned, source was only 8-byte + * aligned but it has been subtracted by 8 and we perform + * one twin load ahead, then add 8 back into source when + * we finish the loop. + */ + LOAD_TWIN(%o1, %o4, %o5) +1: add %o1, 16, %o1 + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16 + 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32, %o1 + STORE_INIT(%o5, %o0 + 0x00) ! initializes cache line + STORE_INIT(%g2, %o0 + 0x08) + LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + STORE_INIT(%g3, %o0 + 0x10) + STORE_INIT(%o4, %o0 + 0x18) + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16, %o1 + STORE_INIT(%o5, %o0 + 0x20) + STORE_INIT(%g2, %o0 + 0x28) + LOAD_TWIN(%o1, %o4, %o5) + STORE_INIT(%g3, %o0 + 0x30) + STORE_INIT(%o4, %o0 + 0x38) + subcc %g1, 64, %g1 + bne,pt %XCC, 1b + add %o0, 64, %o0 + + ba,pt %XCC, 60f + add %o1, 0x8, %o1 + +50: /* Destination is 64-byte aligned, and source is 16-byte + * aligned. + */ +1: LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16 + 32, %o1 + LOAD(prefetch, %o1, #one_read) + sub %o1, 32, %o1 + STORE_INIT(%o4, %o0 + 0x00) ! initializes cache line + STORE_INIT(%o5, %o0 + 0x08) + LOAD_TWIN(%o1, %o4, %o5) + add %o1, 16, %o1 + STORE_INIT(%g2, %o0 + 0x10) + STORE_INIT(%g3, %o0 + 0x18) + LOAD_TWIN(%o1, %g2, %g3) + add %o1, 16, %o1 + STORE_INIT(%o4, %o0 + 0x20) + STORE_INIT(%o5, %o0 + 0x28) + STORE_INIT(%g2, %o0 + 0x30) + STORE_INIT(%g3, %o0 + 0x38) + subcc %g1, 64, %g1 + bne,pt %XCC, 1b + add %o0, 64, %o0 + /* fall through */ + +60: + /* %o2 contains any final bytes still needed to be copied + * over. If anything is left, we copy it one byte at a time. + */ + wr %g0, ASI_PNF, %asi + brz,pt %o2, 85f + sub %o0, %o1, %o3 + ba,a,pt %XCC, 90f + + .align 64 +70: /* 16 < len <= 64 */ + bne,pn %XCC, 75f + sub %o0, %o1, %o3 + +72: + andn %o2, 0xf, %o4 + and %o2, 0xf, %o2 +1: subcc %o4, 0x10, %o4 + LOAD(ldx, %o1, %o5) + add %o1, 0x08, %o1 + LOAD(ldx, %o1, %g1) + sub %o1, 0x08, %o1 + STORE(stx, %o5, %o1 + %o3) + add %o1, 0x8, %o1 + STORE(stx, %g1, %o1 + %o3) + bgu,pt %XCC, 1b + add %o1, 0x8, %o1 +73: andcc %o2, 0x8, %g0 + be,pt %XCC, 1f + nop + sub %o2, 0x8, %o2 + LOAD(ldx, %o1, %o5) + STORE(stx, %o5, %o1 + %o3) + add %o1, 0x8, %o1 +1: andcc %o2, 0x4, %g0 + be,pt %XCC, 1f + nop + sub %o2, 0x4, %o2 + LOAD(lduw, %o1, %o5) + STORE(stw, %o5, %o1 + %o3) + add %o1, 0x4, %o1 +1: cmp %o2, 0 + be,pt %XCC, 85f + nop + ba,pt %XCC, 90f + nop + +75: + andcc %o0, 0x7, %g1 + sub %g1, 0x8, %g1 + be,pn %icc, 2f + sub %g0, %g1, %g1 + sub %o2, %g1, %o2 + +1: subcc %g1, 1, %g1 + LOAD(ldub, %o1, %o5) + STORE(stb, %o5, %o1 + %o3) + bgu,pt %icc, 1b + add %o1, 1, %o1 + +2: add %o1, %o3, %o0 + andcc %o1, 0x7, %g1 + bne,pt %icc, 8f + sll %g1, 3, %g1 + + cmp %o2, 16 + bgeu,pt %icc, 72b + nop + ba,a,pt %XCC, 73b + +8: mov 64, %o3 + andn %o1, 0x7, %o1 + LOAD(ldx, %o1, %g2) + sub %o3, %g1, %o3 + andn %o2, 0x7, %o4 + sllx %g2, %g1, %g2 +1: add %o1, 0x8, %o1 + LOAD(ldx, %o1, %g3) + subcc %o4, 0x8, %o4 + srlx %g3, %o3, %o5 + or %o5, %g2, %o5 + STORE(stx, %o5, %o0) + add %o0, 0x8, %o0 + bgu,pt %icc, 1b + sllx %g3, %g1, %g2 + + srl %g1, 3, %g1 + andcc %o2, 0x7, %o2 + be,pn %icc, 85f + add %o1, %g1, %o1 + ba,pt %XCC, 90f + sub %o0, %o1, %o3 + + .align 64 +80: /* 0 < len <= 16 */ + andcc %o3, 0x3, %g0 + bne,pn %XCC, 90f + sub %o0, %o1, %o3 + +1: + subcc %o2, 4, %o2 + LOAD(lduw, %o1, %g1) + STORE(stw, %g1, %o1 + %o3) + bgu,pt %XCC, 1b + add %o1, 4, %o1 + +85: retl + mov %g5, %o0 + + .align 32 +90: + subcc %o2, 1, %o2 + LOAD(ldub, %o1, %g1) + STORE(stb, %g1, %o1 + %o3) + bgu,pt %XCC, 90b + add %o1, 1, %o1 + retl + mov %g5, %o0 + +END(memcpy) + +#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src - offset - 0x20], %t0; \ + ldx [%src - offset - 0x18], %t1; \ + ldx [%src - offset - 0x10], %t2; \ + ldx [%src - offset - 0x08], %t3; \ + stw %t0, [%dst - offset - 0x1c]; \ + srlx %t0, 32, %t0; \ + stw %t0, [%dst - offset - 0x20]; \ + stw %t1, [%dst - offset - 0x14]; \ + srlx %t1, 32, %t1; \ + stw %t1, [%dst - offset - 0x18]; \ + stw %t2, [%dst - offset - 0x0c]; \ + srlx %t2, 32, %t2; \ + stw %t2, [%dst - offset - 0x10]; \ + stw %t3, [%dst - offset - 0x04]; \ + srlx %t3, 32, %t3; \ + stw %t3, [%dst - offset - 0x08]; + +#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src - offset - 0x20], %t0; \ + ldx [%src - offset - 0x18], %t1; \ + ldx [%src - offset - 0x10], %t2; \ + ldx [%src - offset - 0x08], %t3; \ + stx %t0, [%dst - offset - 0x20]; \ + stx %t1, [%dst - offset - 0x18]; \ + stx %t2, [%dst - offset - 0x10]; \ + stx %t3, [%dst - offset - 0x08]; \ + ldx [%src - offset - 0x40], %t0; \ + ldx [%src - offset - 0x38], %t1; \ + ldx [%src - offset - 0x30], %t2; \ + ldx [%src - offset - 0x28], %t3; \ + stx %t0, [%dst - offset - 0x40]; \ + stx %t1, [%dst - offset - 0x38]; \ + stx %t2, [%dst - offset - 0x30]; \ + stx %t3, [%dst - offset - 0x28]; + +#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \ + ldx [%src + offset + 0x00], %t0; \ + ldx [%src + offset + 0x08], %t1; \ + stw %t0, [%dst + offset + 0x04]; \ + srlx %t0, 32, %t2; \ + stw %t2, [%dst + offset + 0x00]; \ + stw %t1, [%dst + offset + 0x0c]; \ + srlx %t1, 32, %t3; \ + stw %t3, [%dst + offset + 0x08]; + +#define RMOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \ + ldx [%src + offset + 0x00], %t0; \ + ldx [%src + offset + 0x08], %t1; \ + stx %t0, [%dst + offset + 0x00]; \ + stx %t1, [%dst + offset + 0x08]; + + .align 32 +228: andcc %o2, 1, %g0 + be,pt %icc, 2f+4 +1: ldub [%o1 - 1], %o5 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + subcc %o2, 1, %o2 + be,pn %xcc, 229f + stb %o5, [%o0] +2: ldub [%o1 - 1], %o5 + sub %o0, 2, %o0 + ldub [%o1 - 2], %g5 + sub %o1, 2, %o1 + subcc %o2, 2, %o2 + stb %o5, [%o0 + 1] + bne,pt %xcc, 2b + stb %g5, [%o0] +229: retl + mov %g4, %o0 +out: retl + mov %g5, %o0 + + .align 32 +ENTRY(memmove) + mov %o0, %g5 +#ifndef USE_BPR + srl %o2, 0, %o2 +#endif + brz,pn %o2, out + sub %o0, %o1, %o4 + cmp %o4, %o2 + bgeu,pt %XCC, 218b + mov %o0, %g4 + add %o0, %o2, %o0 +220: add %o1, %o2, %o1 + cmp %o2, 15 + bleu,pn %xcc, 228b + andcc %o0, 7, %g2 + sub %o0, %o1, %g5 + andcc %g5, 3, %o5 + bne,pn %xcc, 232f + andcc %o1, 3, %g0 + be,a,pt %xcc, 236f + andcc %o1, 4, %g0 + andcc %o1, 1, %g0 + be,pn %xcc, 4f + andcc %o1, 2, %g0 + ldub [%o1 - 1], %g2 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + sub %o2, 1, %o2 + be,pn %xcc, 5f + stb %g2, [%o0] +4: lduh [%o1 - 2], %g2 + sub %o1, 2, %o1 + sub %o0, 2, %o0 + sub %o2, 2, %o2 + sth %g2, [%o0] +5: andcc %o1, 4, %g0 +236: be,a,pn %xcc, 2f + andcc %o2, -128, %g6 + lduw [%o1 - 4], %g5 + sub %o1, 4, %o1 + sub %o0, 4, %o0 + sub %o2, 4, %o2 + stw %g5, [%o0] + andcc %o2, -128, %g6 +2: be,pn %xcc, 235f + andcc %o0, 4, %g0 + be,pn %xcc, 282f + 4 +5: RMOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5) + RMOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5) + subcc %g6, 128, %g6 + sub %o1, 128, %o1 + bne,pt %xcc, 5b + sub %o0, 128, %o0 +235: andcc %o2, 0x70, %g6 +41: be,pn %xcc, 280f + andcc %o2, 8, %g0 + +279: rd %pc, %o5 + sll %g6, 1, %g5 + sub %o1, %g6, %o1 + sub %o5, %g5, %o5 + jmpl %o5 + %lo(280f - 279b), %g0 + sub %o0, %g6, %o0 + RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5) + RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5) +280: be,pt %xcc, 281f + andcc %o2, 4, %g0 + ldx [%o1 - 8], %g2 + sub %o0, 8, %o0 + stw %g2, [%o0 + 4] + sub %o1, 8, %o1 + srlx %g2, 32, %g2 + stw %g2, [%o0] +281: be,pt %xcc, 1f + andcc %o2, 2, %g0 + lduw [%o1 - 4], %g2 + sub %o1, 4, %o1 + stw %g2, [%o0 - 4] + sub %o0, 4, %o0 +1: be,pt %xcc, 1f + andcc %o2, 1, %g0 + lduh [%o1 - 2], %g2 + sub %o1, 2, %o1 + sth %g2, [%o0 - 2] + sub %o0, 2, %o0 +1: be,pt %xcc, 211f + nop + ldub [%o1 - 1], %g2 + stb %g2, [%o0 - 1] +211: retl + mov %g4, %o0 + +282: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5) + RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5) + subcc %g6, 128, %g6 + sub %o1, 128, %o1 + bne,pt %xcc, 282b + sub %o0, 128, %o0 + andcc %o2, 0x70, %g6 + be,pn %xcc, 284f + andcc %o2, 8, %g0 + +283: rd %pc, %o5 + sub %o1, %g6, %o1 + sub %o5, %g6, %o5 + jmpl %o5 + %lo(284f - 283b), %g0 + sub %o0, %g6, %o0 + RMOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3) + RMOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3) +284: be,pt %xcc, 285f + andcc %o2, 4, %g0 + ldx [%o1 - 8], %g2 + sub %o0, 8, %o0 + sub %o1, 8, %o1 + stx %g2, [%o0] +285: be,pt %xcc, 1f + andcc %o2, 2, %g0 + lduw [%o1 - 4], %g2 + sub %o0, 4, %o0 + sub %o1, 4, %o1 + stw %g2, [%o0] +1: be,pt %xcc, 1f + andcc %o2, 1, %g0 + lduh [%o1 - 2], %g2 + sub %o0, 2, %o0 + sub %o1, 2, %o1 + sth %g2, [%o0] +1: be,pt %xcc, 1f + nop + ldub [%o1 - 1], %g2 + stb %g2, [%o0 - 1] +1: retl + mov %g4, %o0 + +232: ldub [%o1 - 1], %g5 + sub %o1, 1, %o1 + sub %o0, 1, %o0 + subcc %o2, 1, %o2 + bne,pt %xcc, 232b + stb %g5, [%o0] +234: retl + mov %g4, %o0 +END(memmove) + +#ifdef USE_BPR +weak_alias (memcpy, __align_cpy_1) +weak_alias (memcpy, __align_cpy_2) +weak_alias (memcpy, __align_cpy_4) +weak_alias (memcpy, __align_cpy_8) +weak_alias (memcpy, __align_cpy_16) +#endif +libc_hidden_builtin_def (memcpy) +libc_hidden_builtin_def (memmove) --- ./sysdeps/sparc/sparc64/sparcv9v/memset.S.~1~ 2006-02-28 00:46:13.000000000 -0800 +++ ./sysdeps/sparc/sparc64/sparcv9v/memset.S 2006-02-28 00:45:03.000000000 -0800 @@ -0,0 +1,128 @@ +/* Set a block of memory to some byte value. + For SUN4V Niagara. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller (davem@davemloft.net) + + 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 + +#define ASI_BLK_INIT_QUAD_LDD_P 0xe2 +#define ASI_P 0x80 +#define ASI_PNF 0x82 + +#ifndef XCC +#define USE_BPR +#define XCC xcc +#endif + + .register %g2,#scratch + + .text + .align 32 + +ENTRY(memset) + /* %o0=buf, %o1=pat, %o2=len */ + and %o1, 0xff, %o3 + mov %o2, %o1 + sllx %o3, 8, %g1 + or %g1, %o3, %o2 + sllx %o2, 16, %g1 + or %g1, %o2, %o2 + sllx %o2, 32, %g1 + ba,pt %XCC, 1f + or %g1, %o2, %o2 + +ENTRY(__bzero) + clr %o2 +1: brz,pn %o1, 90f + mov %o0, %o3 + + wr %g0, ASI_P, %asi + + cmp %o1, 15 + bl,pn %icc, 70f + andcc %o0, 0x7, %g1 + be,pt %XCC, 2f + mov 8, %g2 + sub %g2, %g1, %g1 + sub %o1, %g1, %o1 +1: stba %o2, [%o0 + 0x00] %asi + subcc %g1, 1, %g1 + bne,pt %XCC, 1b + add %o0, 1, %o0 +2: cmp %o1, 128 + bl,pn %icc, 60f + andcc %o0, (64 - 1), %g1 + be,pt %XCC, 40f + mov 64, %g2 + sub %g2, %g1, %g1 + sub %o1, %g1, %o1 +1: stxa %o2, [%o0 + 0x00] %asi + subcc %g1, 8, %g1 + bne,pt %XCC, 1b + add %o0, 8, %o0 + +40: + wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi + andn %o1, (64 - 1), %g1 + sub %o1, %g1, %o1 +50: + stxa %o2, [%o0 + 0x00] %asi + stxa %o2, [%o0 + 0x08] %asi + stxa %o2, [%o0 + 0x10] %asi + stxa %o2, [%o0 + 0x18] %asi + stxa %o2, [%o0 + 0x20] %asi + stxa %o2, [%o0 + 0x28] %asi + stxa %o2, [%o0 + 0x30] %asi + stxa %o2, [%o0 + 0x38] %asi + subcc %g1, 64, %g1 + bne,pt %XCC, 50b + add %o0, 64, %o0 + + wr %g0, ASI_P, %asi + brz,pn %o1, 80f +60: + andncc %o1, 0x7, %g1 + be,pn %XCC, 2f + sub %o1, %g1, %o1 +1: stxa %o2, [%o0 + 0x00] %asi + subcc %g1, 8, %g1 + bne,pt %XCC, 1b + add %o0, 8, %o0 +2: brz,pt %o1, 80f + nop + +70: +1: stba %o2, [%o0 + 0x00] %asi + subcc %o1, 1, %o1 + bne,pt %icc, 1b + add %o0, 1, %o0 + + /* fallthrough */ + +80: + wr %g0, ASI_PNF, %asi + +90: + retl + mov %o3, %o0 +END(__bzero) +END(memset) + +libc_hidden_builtin_def (memset) +weak_alias (__bzero, bzero) --- ./configure.~1~ 2006-02-27 23:27:03.000000000 -0800 +++ ./configure 2006-02-28 00:47:03.000000000 -0800 @@ -2021,10 +2021,14 @@ sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;; +sparcv9v) + base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9v ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) base_machine=sparc machine=sparc/sparc64/sparcv9b ;; +sparc64v) + base_machine=sparc machine=sparc/sparc64/sparcv9v ;; *) base_machine=$machine ;; esac --- ./configure.in.~1~ 2006-02-27 23:27:03.000000000 -0800 +++ ./configure.in 2006-02-28 00:46:49.000000000 -0800 @@ -509,10 +509,14 @@ sparcv8plus | sparcv8plusa | sparcv9) base_machine=sparc machine=sparc/sparc32/sparcv9 ;; sparcv8plusb | sparcv9b) base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9b ;; +sparcv9v) + base_machine=sparc machine=sparc/sparc32/sparcv9/sparcv9v ;; sparc64) base_machine=sparc machine=sparc/sparc64 ;; sparc64b) base_machine=sparc machine=sparc/sparc64/sparcv9b ;; +sparc64v) + base_machine=sparc machine=sparc/sparc64/sparcv9v ;; *) base_machine=$machine ;; esac changequote([,])dnl From roland@redhat.com Tue Feb 28 09:57:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 09:57:00 -0000 Subject: failed creation of rtld-libc.aT archive In-Reply-To: David S. Miller's message of Tuesday, 28 February 2006 01:39:09 -0800 <20060228.013909.12750313.davem@davemloft.net> Message-ID: <20060228095730.67AFD180B18@magilla.sf.frob.com> Should be fixed now. Thanks, Roland From roland@redhat.com Tue Feb 28 10:25:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 10:25:00 -0000 Subject: m68k moved to glibc ports repository Message-ID: <20060228102505.399B0180B18@magilla.sf.frob.com> The m68k port has not had very active maintenance, and does not have a working NPTL or Hurd port. I've moved it over to the ports repository. The commit ACL for the its directories lists schwab. Let me know if there is anyone else who should be on the list. It's been the precedent to post to libc-ports when people (other than me ;-) commit changes to their ports. But that is up to those who want to work on m68k. Thanks, Roland From jakub@redhat.com Tue Feb 28 12:50:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 28 Feb 2006 12:50:00 -0000 Subject: [PATCH] Fix int64_t/u_int64_t on 64-bit arches with non-GCC compilers Message-ID: <20060228125020.GF30252@sunsite.mff.cuni.cz> Hi! On 64-bit arches and non-GCC compilers, uses long long resp. unsigned long long types for int64_t/u_int64_t. But, uses there long resp. unsigned long and so does for GCC (it uses DImode int, which mangles as l rather than x). With those compilers, depending if you include or first thus affects mangling, the same function can mangle differently based on the order of the above headers included. The following patch is an ABI change with those compilers, makes even non-GCC compilers do the same as GCC (and the same as already does). 2006-02-28 Jakub Jelinek * posix/sys/types.h [!__GNUC_PREREQ (2, 7)] (int64_t, u_int64_t): typedef to long int resp. unsigned long int on 64-bit arches. --- libc/posix/sys/types.h.jj 2002-10-24 01:48:51.000000000 +0200 +++ libc/posix/sys/types.h 2006-02-28 13:34:44.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1994,1995,1996,1997,1998,1999,2000,2001,2002 +/* Copyright (C) 1991,1992,1994,1995,1996,1997,1998,1999,2000,2001,2002,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -163,7 +163,9 @@ typedef unsigned int uint; typedef char int8_t; typedef short int int16_t; typedef int int32_t; -# if __GLIBC_HAVE_LONG_LONG +# if __WORDSIZE == 64 +typedef long int int64_t; +# elif __GLIBC_HAVE_LONG_LONG __extension__ typedef long long int int64_t; # endif # endif @@ -172,7 +174,9 @@ __extension__ typedef long long int int6 typedef unsigned char u_int8_t; typedef unsigned short int u_int16_t; typedef unsigned int u_int32_t; -# if __GLIBC_HAVE_LONG_LONG +# if __WORDSIZE == 64 +typedef unsigned long int u_int64_t; +# elif __GLIBC_HAVE_LONG_LONG __extension__ typedef unsigned long long int u_int64_t; # endif Jakub From jakub@redhat.com Tue Feb 28 14:42:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 28 Feb 2006 14:42:00 -0000 Subject: m68k moved to glibc ports repository In-Reply-To: <20060228102505.399B0180B18@magilla.sf.frob.com> References: <20060228102505.399B0180B18@magilla.sf.frob.com> Message-ID: <20060228144203.GG30252@sunsite.mff.cuni.cz> On Tue, Feb 28, 2006 at 02:25:05AM -0800, Roland McGrath wrote: > The m68k port has not had very active maintenance, and does not have a > working NPTL or Hurd port. I've moved it over to the ports repository. > The commit ACL for the its directories lists schwab. Let me know if there > is anyone else who should be on the list. It's been the precedent to post > to libc-ports when people (other than me ;-) commit changes to their ports. > But that is up to those who want to work on m68k. The move of m68k and hppa patch broke x86_64, ppc64, sparc32 and sh arches that used a couple of files from the now moved ports. This patch should fix that. 2006-02-28 Jakub Jelinek * sysdeps/unix/sysv/linux/powerpc/powerpc64/umount.c: Include x86_64 umount.c rather than hppa umount.c. * sysdeps/unix/sysv/linux/sparc/sparc32/chown.c: Include sh chown.c rather than m68k chown.c. * sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c: Include sh fchownat.c rather than m68k fchownat.c. * sysdeps/unix/sysv/linux/sh/chown.c: Copy over from m68k chown.c. * sysdeps/unix/sysv/linux/sh/fchownat.c: Copy over from m68k fchownat.c. * sysdeps/unix/sysv/linux/x86_64/brk.c: Copy over from hppa brk.c. * sysdeps/unix/sysv/linux/x86_64/umount.c: Copy over from hppa umount.c. --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/umount.c.jj 2004-04-09 20:21:54.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/umount.c 2006-02-28 15:34:43.000000000 +0100 @@ -1 +1 @@ -#include +#include --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/chown.c.jj 2000-01-17 06:20:58.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/chown.c 2006-02-28 15:36:39.000000000 +0100 @@ -1 +1 @@ -#include +#include --- libc/sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c.jj 2005-11-11 20:54:45.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c 2006-02-28 15:36:50.000000000 +0100 @@ -1 +1 @@ -#include +#include --- libc/sysdeps/unix/sysv/linux/sh/chown.c.jj 2000-06-12 22:35:14.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/sh/chown.c 2006-01-09 22:53:48.000000000 +0100 @@ -1 +1,69 @@ -#include +/* Copyright (C) 1998,2000,2002,2003,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 +#include + +#ifdef __NR_chown32 +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_chown32 */ + +int +__chown (const char *file, uid_t owner, gid_t group) +{ +#if __ASSUME_32BITUIDS > 0 + return INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group); +#else +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + int result; + int saved_errno = errno; + + result = INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group); + if (result == 0 || errno != ENOSYS) + return result; + + __set_errno (saved_errno); + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + + if (((owner + 1) > (gid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL (chown, 3, CHECK_STRING (file), owner, group); +#endif +} +libc_hidden_def (__chown) +weak_alias (__chown, chown) --- libc/sysdeps/unix/sysv/linux/sh/fchownat.c.jj 2005-11-11 20:50:39.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/sh/fchownat.c 2006-01-09 22:53:48.000000000 +0100 @@ -1 +1,122 @@ -#include +/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 +#include +#include + +#include +#include + +#ifdef __NR_chown32 +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_chown32 */ + +int +fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if __ASSUME_32BITUIDS > 0 + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), owner, + group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); +#else +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), + owner, group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + + if (((owner + 1) > (gid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner, + group); + else + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, + group); +#endif + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + fail: + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} --- libc/sysdeps/unix/sysv/linux/x86_64/brk.c.jj 2001-09-19 12:31:31.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/x86_64/brk.c 2006-02-28 15:33:48.000000000 +0100 @@ -1 +1,42 @@ -#include +/* brk system call for Linux/x86_64. + Copyright (C) 1995, 1996, 2000, 2001, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 + +/* This must be initialized data because commons can't have aliases. */ +void *__curbrk = 0; + +int +__brk (void *addr) +{ + void *newbrk; + + __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr); + + if (newbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + + return 0; +} +weak_alias (__brk, brk) --- libc/sysdeps/unix/sysv/linux/x86_64/umount.c.jj 2001-09-19 12:31:31.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/x86_64/umount.c 2006-02-28 15:34:18.000000000 +0100 @@ -1 +1,31 @@ -#include +/* Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Huggins-Daines , 2000. + + 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. */ + +/* Since we don't have an oldumount system call, do what the kernel + does down here. */ + +extern long int __umount2 (const char *name, int flags); + +long int +__umount (const char *name) +{ + return __umount2 (name, 0); +} + +weak_alias (__umount, umount); Jakub From jakub@redhat.com Tue Feb 28 15:21:00 2006 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 28 Feb 2006 15:21:00 -0000 Subject: [PATCH] Make sure MALLOC_ALIGNMENT is at least long double's alignment Message-ID: <20060228152100.GH30252@sunsite.mff.cuni.cz> Hi! The recent switch to 128-bit long double on ppc32 broke malloc, as on this 32-bit arch long double is 16 byte aligned, but malloc was only guaranteeing 8 byte aligment so far. On sparc32 and s390 this is not a problem, since __alignof__ (long double) is 8. But, apparently some of the quick checks for invalid pointers don't work when MALLOC_ALIGNMENT is bigger than 2 * SIZE_SZ, in that case the pointer returned to the user must be MALLOC_ALIGNMENT aligned, not the chunk pointer (which is always user pointer - 2 * SIZE_SZ). With this, ppc32 glibc passes make check. I haven't checked though if this pessimizes code on i?86/x86_64 or other important arches, will do soon. If it does, then we might consider doing: #define check_align_OK(chunkptr, userptr) \ (MALLOC_ALIGNMENT > 2 * SIZE_SZ \ ? __builtin_expect ((uintptr_t) userptr & MALLOC_ALIGN_MASK, 0) \ : __builtin_expect ((uintptr_t) chunkptr & MALLOC_ALIGN_MASK, 0)) and using check_align_OK (oldp, oldmem) etc. 2006-02-28 Jakub Jelinek * malloc/malloc.c (MALLOC_ALIGNMENT): Set to __alignof__ (long double) if long double is more aligned than 2 * SIZE_SZ. (public_rEALLOc, _int_free, _int_realloc): Check that *mem is aligned, rather than corresponding mem2chunk pointer. --- libc/malloc/malloc.c 2005-12-30 09:04:02.000000000 +0100 +++ libc/malloc/malloc.c 2006-02-28 15:30:20.000000000 +0100 @@ -188,7 +188,8 @@ Changing default word sizes: INTERNAL_SIZE_T size_t - MALLOC_ALIGNMENT 2 * sizeof(INTERNAL_SIZE_T) + MALLOC_ALIGNMENT MAX (2 * sizeof(INTERNAL_SIZE_T), + __alignof__ (long double)) Configuration and functionality options: @@ -380,7 +381,8 @@ extern "C" { #ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT (2 * SIZE_SZ) +#define MALLOC_ALIGNMENT (2 * SIZE_SZ < __alignof__ (long double) \ + ? __alignof__ (long double) : 2 * SIZE_SZ) #endif /* The corresponding bit mask value */ @@ -3468,7 +3470,7 @@ public_rEALLOc(Void_t* oldmem, size_t by Therefore we can exclude some size values which might appear here by accident or by "design" from some intruder. */ if (__builtin_expect ((uintptr_t) oldp > (uintptr_t) -oldsize, 0) - || __builtin_expect ((uintptr_t) oldp & MALLOC_ALIGN_MASK, 0)) + || __builtin_expect ((uintptr_t) oldmem & MALLOC_ALIGN_MASK, 0)) { malloc_printerr (check_action, "realloc(): invalid pointer", oldmem); return NULL; @@ -4282,7 +4284,7 @@ _int_free(mstate av, Void_t* mem) Therefore we can exclude some size values which might appear here by accident or by "design" from some intruder. */ if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) - || __builtin_expect ((uintptr_t) p & MALLOC_ALIGN_MASK, 0)) + || __builtin_expect ((uintptr_t) mem & MALLOC_ALIGN_MASK, 0)) { errstr = "free(): invalid pointer"; errout: @@ -4628,7 +4630,7 @@ _int_realloc(mstate av, Void_t* oldmem, oldsize = chunksize(oldp); /* Simple tests for old block integrity. */ - if (__builtin_expect ((uintptr_t) oldp & MALLOC_ALIGN_MASK, 0)) + if (__builtin_expect ((uintptr_t) oldmem & MALLOC_ALIGN_MASK, 0)) { errstr = "realloc(): invalid pointer"; errout: Jakub From roland@redhat.com Tue Feb 28 19:09:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 19:09:00 -0000 Subject: m68k moved to glibc ports repository In-Reply-To: Jakub Jelinek's message of Tuesday, 28 February 2006 15:42:03 +0100 <20060228144203.GG30252@sunsite.mff.cuni.cz> Message-ID: <20060228190950.AA1EC180B1C@magilla.sf.frob.com> Applied. From roland@redhat.com Tue Feb 28 19:11:00 2006 From: roland@redhat.com (Roland McGrath) Date: Tue, 28 Feb 2006 19:11:00 -0000 Subject: [PATCH] Fix int64_t/u_int64_t on 64-bit arches with non-GCC compilers In-Reply-To: Jakub Jelinek's message of Tuesday, 28 February 2006 13:50:20 +0100 <20060228125020.GF30252@sunsite.mff.cuni.cz> Message-ID: <20060228191133.DF53D180B1C@magilla.sf.frob.com> Applied.