From kkojima@rr.iij4u.or.jp Mon Sep 1 03:46:00 2003 From: kkojima@rr.iij4u.or.jp (kaz Kojima) Date: Mon, 01 Sep 2003 03:46:00 -0000 Subject: [PATCH] SH: Support PSEUDO_ERRVAL Message-ID: <200309010346.h813kdJ16463@r-rr.iij4u.or.jp> Hi, The attached is a patch to support PSEUDO_ERRVAL on SH and update Versions file for fadvise64 and fallocate64. Regards, kaz -- 2003-08-31 Kaz Kojima * sysdeps/unix/sysv/linux/sh/Versions: Add posix_fadvise64 and posix_fallocate64 at GLIBC_2.3.3. * sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO_ERRVAL): Define. (PSEUDO_END_ERRVAL, ret_ERRVAL): Likewise. diff -u3prN ORIG/libc/sysdeps/unix/sysv/linux/sh/Versions LOCAL/libc/sysdeps/unix/sysv/linux/sh/Versions --- ORIG/libc/sysdeps/unix/sysv/linux/sh/Versions Thu Oct 26 11:29:19 2000 +++ LOCAL/libc/sysdeps/unix/sysv/linux/sh/Versions Mon Sep 1 05:56:56 2003 @@ -21,4 +21,7 @@ libc { # v* versionsort64; } + GLIBC_2.3.3 { + posix_fadvise64; posix_fallocate64; + } } diff -u3prN ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h --- ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h Wed Mar 26 12:57:54 2003 +++ LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h Mon Aug 25 20:29:16 2003 @@ -77,6 +77,17 @@ #define ret_NOERRNO ret +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .text; \ + ENTRY (name); \ + DO_CALL (syscall_name, args); + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + +#define ret_ERRVAL ret + #ifndef PIC # define SYSCALL_ERROR_HANDLER \ mov.l 0f,r1; \ From drepper@redhat.com Mon Sep 1 04:06:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 01 Sep 2003 04:06:00 -0000 Subject: [PATCH] SH: Support PSEUDO_ERRVAL In-Reply-To: <200309010346.h813kdJ16463@r-rr.iij4u.or.jp> References: <200309010346.h813kdJ16463@r-rr.iij4u.or.jp> Message-ID: <3F52C592.5020200@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kaz Kojima wrote: > 2003-08-31 Kaz Kojima > > * sysdeps/unix/sysv/linux/sh/Versions: Add posix_fadvise64 and > posix_fallocate64 at GLIBC_2.3.3. > * sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO_ERRVAL): Define. > (PSEUDO_END_ERRVAL, ret_ERRVAL): Likewise. Applied. Thanks, - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/UsWS2ijCOnn/RHQRAmTLAJ93lJCRzLopQ7gu/65UIxn8KnVgXwCfWrdn 61KcpMZL1zdLZ7PxCPFnW1A= =isRw -----END PGP SIGNATURE----- From jakub@redhat.com Mon Sep 1 09:52:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 01 Sep 2003 09:52:00 -0000 Subject: [PATCH] Add pthread_cond_timedwait stub to libc.so Message-ID: <20030901075051.GR12344@sunsite.ms.mff.cuni.cz> Hi! B0rken software, which doesn't link shared libraries which use pthread_cond_timedwait against -lpthread is bitten by this. With the exception of pthread_cond_timedwait, all pthread_cond_* routines have stubs in libc.so, so they are given @@GLIBC_2.3.2 version during linking. pthread_cond_timedwait doesn't have the stub, so unless -lpthread is specified (certainly the right thing to do), it remains unversioned. Mixing pthread_cond_*@GLIBC_2.3.2 and pthread_cond_timedwait@GLIBC_2.0 on one pthread_cond_t is deadly. 2003-09-01 Jakub Jelinek nptl/ * sysdeps/pthread/pthread-functions.h (struct pthread_functions): Add ptr___pthread_cond_timedwait and ptr___pthread_cond_timedwait_2_0. * init.c (pthread_functions): Initialize them. * forward.c (pthread_cond_timedwait@GLIBC_2.0, pthread_cond_timedwait@@GLIBC_2.3.2): New forwards. * Versions (libc): Export pthread_cond_timedwait@GLIBC_2.0, pthread_cond_timedwait@@GLIBC_2.3.2. linuxthreads/ * internals.h (__pthread_cond_timedwait): New prototype. * sysdeps/pthread/pthread-functions.h (struct pthread_functions): Add ptr___pthread_cond_timedwait. * pthread.c (__pthread_functions): Initialize them. * forward.c (pthread_cond_timedwait@GLIBC_2.0, pthread_cond_timedwait@@GLIBC_2.3.2): New forwards. * Versions (libc): Export pthread_cond_timedwait@GLIBC_2.0, pthread_cond_timedwait@@GLIBC_2.3.2. --- libc/nptl/sysdeps/pthread/pthread-functions.h.jj 2003-04-12 15:06:09.000000000 -0400 +++ libc/nptl/sysdeps/pthread/pthread-functions.h 2003-09-01 05:17:47.000000000 -0400 @@ -52,12 +52,17 @@ struct pthread_functions const pthread_condattr_t *); int (*ptr___pthread_cond_signal) (pthread_cond_t *); int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *); + int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *, + const struct timespec *); int (*ptr___pthread_cond_broadcast_2_0) (pthread_cond_2_0_t *); int (*ptr___pthread_cond_destroy_2_0) (pthread_cond_2_0_t *); int (*ptr___pthread_cond_init_2_0) (pthread_cond_2_0_t *, const pthread_condattr_t *); int (*ptr___pthread_cond_signal_2_0) (pthread_cond_2_0_t *); int (*ptr___pthread_cond_wait_2_0) (pthread_cond_2_0_t *, pthread_mutex_t *); + int (*ptr___pthread_cond_timedwait_2_0) (pthread_cond_2_0_t *, + pthread_mutex_t *, + const struct timespec *); int (*ptr_pthread_equal) (pthread_t, pthread_t); void (*ptr___pthread_exit) (void *); int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *); --- libc/nptl/init.c.jj 2003-08-27 05:02:38.000000000 -0400 +++ libc/nptl/init.c 2003-09-01 05:15:30.000000000 -0400 @@ -93,12 +93,14 @@ static struct pthread_functions pthread_ .ptr___pthread_cond_init = __pthread_cond_init, .ptr___pthread_cond_signal = __pthread_cond_signal, .ptr___pthread_cond_wait = __pthread_cond_wait, + .ptr___pthread_cond_timedwait = __pthread_cond_timedwait, # if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_3_2) .ptr___pthread_cond_broadcast_2_0 = __pthread_cond_broadcast_2_0, .ptr___pthread_cond_destroy_2_0 = __pthread_cond_destroy_2_0, .ptr___pthread_cond_init_2_0 = __pthread_cond_init_2_0, .ptr___pthread_cond_signal_2_0 = __pthread_cond_signal_2_0, .ptr___pthread_cond_wait_2_0 = __pthread_cond_wait_2_0, + .ptr___pthread_cond_timedwait_2_0 = __pthread_cond_timedwait_2_0, # endif .ptr_pthread_equal = __pthread_equal, .ptr___pthread_exit = __pthread_exit, --- libc/nptl/forward.c.jj 2003-04-16 17:51:27.000000000 -0400 +++ libc/nptl/forward.c 2003-09-01 05:13:37.000000000 -0400 @@ -136,6 +136,19 @@ FORWARD (__pthread_cond_wait, (pthread_c versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait, GLIBC_2_3_2); +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) +FORWARD (__pthread_cond_timedwait_2_0, + (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime), (cond, mutex, abstime), 0) +compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait, + GLIBC_2_0); +#endif +FORWARD (__pthread_cond_timedwait, + (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime), (cond, mutex, abstime), 0) +versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait, + GLIBC_2_3_2); + FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), (thread1, thread2), 1) --- libc/nptl/Versions.jj 2003-07-21 07:44:21.000000000 -0400 +++ libc/nptl/Versions 2003-09-01 05:26:42.000000000 -0400 @@ -9,6 +9,7 @@ libc { pthread_condattr_destroy; pthread_condattr_init; pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; pthread_cond_signal; pthread_cond_wait; + pthread_cond_timedwait; pthread_equal; pthread_exit; pthread_getschedparam; pthread_setschedparam; pthread_mutex_destroy; pthread_mutex_init; @@ -23,7 +24,7 @@ libc { # Changed pthread_cond_t. pthread_cond_init; pthread_cond_destroy; pthread_cond_wait; pthread_cond_signal; - pthread_cond_broadcast; + pthread_cond_broadcast; pthread_cond_timedwait; } GLIBC_PRIVATE { # Internal libc interface to libpthread --- libc/linuxthreads/Versions.jj 2003-06-17 18:28:03.000000000 -0400 +++ libc/linuxthreads/Versions 2003-09-01 05:28:26.000000000 -0400 @@ -7,6 +7,7 @@ libc { pthread_attr_setschedparam; pthread_attr_setschedpolicy; pthread_attr_setscope; pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; pthread_cond_signal; pthread_cond_wait; + pthread_cond_timedwait; pthread_condattr_destroy; pthread_condattr_init; pthread_equal; pthread_exit; pthread_getschedparam; pthread_mutex_destroy; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_unlock; @@ -20,7 +21,7 @@ libc { # Changed pthread_cond_t. pthread_cond_init; pthread_cond_destroy; pthread_cond_wait; pthread_cond_signal; - pthread_cond_broadcast; + pthread_cond_broadcast; pthread_cond_timedwait; } GLIBC_PRIVATE { # Internal libc interface to libpthread --- libc/linuxthreads/sysdeps/pthread/pthread-functions.h.jj 2003-04-20 03:37:06.000000000 -0400 +++ libc/linuxthreads/sysdeps/pthread/pthread-functions.h 2003-09-01 05:35:34.000000000 -0400 @@ -54,6 +54,8 @@ struct pthread_functions const pthread_condattr_t *); int (*ptr___pthread_cond_signal) (pthread_cond_t *); int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *); + int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *, + const struct timespec *); int (*ptr_pthread_equal) (pthread_t, pthread_t); void (*ptr___pthread_exit) (void *); int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *); --- libc/linuxthreads/forward.c.jj 2003-01-02 19:30:04.000000000 -0500 +++ libc/linuxthreads/forward.c 2003-09-01 05:29:57.000000000 -0400 @@ -128,6 +128,15 @@ compat_symbol (libc, __pthread_cond_wait #endif versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait, GLIBC_2_3_2); +FORWARD (__pthread_cond_timedwait, + (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime), (cond, mutex, abstime), 0) +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2) +strong_alias (__pthread_cond_timedwait, __pthread_cond_timedwait_2_0) +compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait, GLIBC_2_0); +#endif +versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait, GLIBC_2_3_2); + FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), (thread1, thread2), 1) --- libc/linuxthreads/internals.h.jj 2003-06-17 18:22:21.000000000 -0400 +++ libc/linuxthreads/internals.h 2003-09-01 05:30:59.000000000 -0400 @@ -354,6 +354,9 @@ extern int __pthread_cond_init (pthread_ const pthread_condattr_t *cond_attr); extern int __pthread_cond_destroy (pthread_cond_t *cond); extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); +extern int __pthread_cond_timedwait (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime); extern int __pthread_cond_signal (pthread_cond_t *cond); extern int __pthread_cond_broadcast (pthread_cond_t *cond); extern int __pthread_condattr_init (pthread_condattr_t *attr); --- libc/linuxthreads/pthread.c.jj 2003-08-14 05:05:27.000000000 -0400 +++ libc/linuxthreads/pthread.c 2003-09-01 05:36:55.000000000 -0400 @@ -260,6 +260,7 @@ struct pthread_functions __pthread_funct .ptr___pthread_cond_init = __pthread_cond_init, .ptr___pthread_cond_signal = __pthread_cond_signal, .ptr___pthread_cond_wait = __pthread_cond_wait, + .ptr___pthread_cond_timedwait = __pthread_cond_timedwait, .ptr_pthread_equal = __pthread_equal, .ptr___pthread_exit = __pthread_exit, .ptr_pthread_getschedparam = __pthread_getschedparam, Jakub From jakub@redhat.com Mon Sep 1 10:38:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 01 Sep 2003 10:38:00 -0000 Subject: [PATCH] Fix ppc32 posix_fadvise{,64} Message-ID: <20030901083738.GS12344@sunsite.ms.mff.cuni.cz> Hi! http://linux.bkbits.net:8080/linux-2.5/patch@1.1276.1.10?nav=index.html|ChangeSet@-2w|cset@1.1276.1.10 says the arguments have been reordered on ppc32. Also, fadvise64 syscall, as it uses long long for second argument and long long arguments are on ppc32 passed in even register pairs, needs a padding. 2003-09-01 Jakub Jelinek * sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise.c: New. * sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c: New. --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c.jj 2003-09-01 06:10:06.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c 2003-09-01 06:14:44.000000000 -0400 @@ -0,0 +1,77 @@ +/* Copyright (C) 2003 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 + +int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise); +int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise); + +/* Advice the system about the expected behaviour of the application with + respect to the file associated with FD. */ + +int +__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise) +{ +#ifdef __NR_fadvise64_64 + INTERNAL_SYSCALL_DECL (err); + int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advise, + __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset), + __LONG_LONG_PAIR ((long)(len >> 32), (long)len)); + if (!INTERNAL_SYSCALL_ERROR_P (ret, err)) + return 0; +# ifndef __ASSUME_FADVISE64_64_SYSCALL + if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS) +# endif + return INTERNAL_SYSCALL_ERRNO (ret, err); +#endif +#ifndef __ASSUME_FADVISE64_64_SYSCALL +# ifdef __NR_fadvise64 + if (len != (off_t) len) + return EOVERFLOW; + + INTERNAL_SYSCALL_DECL (err2); + int ret2 = INTERNAL_SYSCALL (fadvise64, err2, 6, fd, 0, + __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset), + (off_t) len, advise); + if (!INTERNAL_SYSCALL_ERROR_P (ret2, err2)) + return 0; + return INTERNAL_SYSCALL_ERRNO (ret2, err2); +# else + return ENOSYS; +# endif +#endif +} + +#include + +#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3) + +int +__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise) +{ + return __posix_fadvise64_l64 (fd, offset, len, advise); +} + +versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3); +compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2); +#else +strong_alias (__posix_fadvise64_l64, posix_fadvise64); +#endif --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise.c.jj 2003-09-01 06:25:58.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise.c 2003-09-01 06:26:55.000000000 -0400 @@ -0,0 +1,40 @@ +/* Copyright (C) 2003 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 + +/* Advice the system about the expected behaviour of the application with + respect to the file associated with FD. */ + +int +posix_fadvise (int fd, off_t offset, off_t len, int advise) +{ +#ifdef __NR_fadvise64 + INTERNAL_SYSCALL_DECL (err); + int ret = INTERNAL_SYSCALL (fadvise64, err, 6, fd, 0, + __LONG_LONG_PAIR (offset >> 31, offset), len, + advise); + if (INTERNAL_SYSCALL_ERROR_P (ret, err)) + return INTERNAL_SYSCALL_ERRNO (ret, err); + return 0; +#else + return ENOSYS; +#endif +} Jakub From schwab@suse.de Mon Sep 1 15:05:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Mon, 01 Sep 2003 15:05:00 -0000 Subject: Fix posix_fadvise on powerpc32 In-Reply-To: (Andreas Jaeger's message of "Mon, 25 Aug 2003 20:51:07 +0200") References: <3F4A5817.1060902@redhat.com> <3F4A59B0.2020300@redhat.com> Message-ID: Andreas Jaeger writes: > Index: sysdeps/unix/sysv/linux/posix_fadvise64.c > --- sysdeps/unix/sysv/linux/posix_fadvise64.c 17 Aug 2003 00:36:42 -0000 1.1 > +++ sysdeps/unix/sysv/linux/posix_fadvise64.c 25 Aug 2003 18:50:57 -0000 > @@ -33,8 +33,8 @@ __posix_fadvise64_l64 (int fd, off64_t o > #ifdef __NR_fadvise64_64 > INTERNAL_SYSCALL_DECL (err); > int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, > - __LONG_LONG_PAIR (offset >> 32, offset), > - __LONG_LONG_PAIR (len >> 32, len), > + __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset), > + __LONG_LONG_PAIR ((long)(len >> 32), (long)len), Formatting: space after cast. > @@ -50,7 +50,7 @@ __posix_fadvise64_l64 (int fd, off64_t o > > INTERNAL_SYSCALL_DECL (err2); > int ret2 = INTERNAL_SYSCALL (fadvise64, err2, 5, fd, > - __LONG_LONG_PAIR (offset >> 32, offset), > + __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset), Same. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N?rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aj@suse.de Tue Sep 2 07:18:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Tue, 02 Sep 2003 07:18:00 -0000 Subject: Fix posix_fadvise on powerpc32 In-Reply-To: (Andreas Schwab's message of "Mon, 01 Sep 2003 17:05:36 +0200") References: <3F4A5817.1060902@redhat.com> <3F4A59B0.2020300@redhat.com> Message-ID: Andreas Schwab writes: > Formatting: space after cast. Ok, fixed in CVS now, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From drepper@redhat.com Tue Sep 2 09:34:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 02 Sep 2003 09:34:00 -0000 Subject: finishing cancellation handling Message-ID: <3F54640D.5080509@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ever since the cancellation handling in nptl started using exceptions there are a large number of potential problems in the libc code. For an exception to be passed up all functions on the call path to the place where the exception originated must have call frame information. Not a problem for platforms which have the support enabled by default, but x86 for instance doesn't fall into this category. Another problem is that all interfaces which might cause an exception to be raised must not be marked with __THROW in the header. Analyzing this by hand is a tedious job and when I tried I missed many things. I've now written a little very specialized tool which helps with this: http://people.redhat.com/drepper/find-cps.c You need a reasonable libelf for it (i.e., the one from elfutils). The tool has two basic modes: one to show which interfaces, when called, can (potentially) raise an exception. The other mode shows which files, containing functions which might raise exception or call functions which might raise exceptions, are not compiled with -fexceptions. The automatic analysis is not 100% so there is the possibility to have waiver list. One I've already checked into the CVS archive (CANCEL-FILE-WAIVE). Use the tool with it like this find-cps -e -f libc_pic.a -w ~/gnu/libc/CANCEL-FILE-WAIVE open close This is for the second mode. For the first mode run find-cps -f libc_pic.a -d libc.so open close There will be a waiver list as well. I haven't populated it yet. There is a lot of work left so you are encouraged to do your part. Please send small patches as soon as you have them so that we can minimize duplication of work. There are several different solutions: ~ functions cannot use cancelable functions and have to be rewritten; this is also sometimes necessary if the cleanup action would be too messy ~ if cancellation is OK the code must be compiled with -fexceptions and the prototype in the exported header must not have __THROW ~ if the function modifies some global data it might be necessary to write cleanup handlers ~ the tools report false positives; the waiver lists must be adjusted. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/VGQN2ijCOnn/RHQRAgE3AKCh0d6xF2df9V288inv/kpVLUpfTQCdHcai S3NWHYs1j8jln5Y9qA+3vRo= =InJw -----END PGP SIGNATURE----- From aj@suse.de Wed Sep 3 10:13:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Wed, 03 Sep 2003 10:13:00 -0000 Subject: glibc build fails on x86_64 Message-ID: I just got on x86_64: loadmsgcat.c: In function `_nl_load_domain': loadmsgcat.c:917: error: `__NR_open_not_cancel_2' undeclared (first use in this function) loadmsgcat.c:917: error: (Each undeclared identifier is reported only once loadmsgcat.c:917: error: for each function it appears in.) loadmsgcat.c:965: error: `__NR_read_not_cancel' undeclared (first use in this function) Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Wed Sep 3 10:22:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 03 Sep 2003 10:22:00 -0000 Subject: glibc build fails on x86_64 In-Reply-To: References: Message-ID: <20030903082142.GU12344@sunsite.ms.mff.cuni.cz> On Wed, Sep 03, 2003 at 12:13:47PM +0200, Andreas Jaeger wrote: > > I just got on x86_64: > loadmsgcat.c: In function `_nl_load_domain': > loadmsgcat.c:917: error: `__NR_open_not_cancel_2' undeclared (first use in this function) > loadmsgcat.c:917: error: (Each undeclared identifier is reported only once > loadmsgcat.c:917: error: for each function it appears in.) > loadmsgcat.c:965: error: `__NR_read_not_cancel' undeclared (first use in this function) linuxthreads or NPTL? Both built just fine for me last night on x86_64. Jakub From aj@suse.de Wed Sep 3 11:07:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Wed, 03 Sep 2003 11:07:00 -0000 Subject: glibc build fails on x86_64 In-Reply-To: <20030903082142.GU12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Wed, 3 Sep 2003 10:21:42 +0200") References: <20030903082142.GU12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Wed, Sep 03, 2003 at 12:13:47PM +0200, Andreas Jaeger wrote: >> >> I just got on x86_64: >> loadmsgcat.c: In function `_nl_load_domain': >> loadmsgcat.c:917: error: `__NR_open_not_cancel_2' undeclared (first use in this function) >> loadmsgcat.c:917: error: (Each undeclared identifier is reported only once >> loadmsgcat.c:917: error: for each function it appears in.) >> loadmsgcat.c:965: error: `__NR_read_not_cancel' undeclared (first use in this function) > > linuxthreads or NPTL? > Both built just fine for me last night on x86_64. linuxthreads - with current CVS after Uli's changes were in, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Wed Sep 3 11:28:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 03 Sep 2003 11:28:00 -0000 Subject: [PATCH] Re: glibc build fails on x86_64 In-Reply-To: References: <20030903082142.GU12344@sunsite.ms.mff.cuni.cz> Message-ID: <20030903092652.GV12344@sunsite.ms.mff.cuni.cz> On Wed, Sep 03, 2003 at 01:07:13PM +0200, Andreas Jaeger wrote: > >> I just got on x86_64: > >> loadmsgcat.c: In function `_nl_load_domain': > >> loadmsgcat.c:917: error: `__NR_open_not_cancel_2' undeclared (first use in this function) > >> loadmsgcat.c:917: error: (Each undeclared identifier is reported only once > >> loadmsgcat.c:917: error: for each function it appears in.) > >> loadmsgcat.c:965: error: `__NR_read_not_cancel' undeclared (first use in this function) > > > > linuxthreads or NPTL? > > Both built just fine for me last night on x86_64. > > linuxthreads - with current CVS after Uli's changes were in, Oh, apparently this was one of the 2 2003-09-02 changes I didn't have in my tree during that build. Try following untested patch. The problem is that non-NPTL linux not-cancel.h uses INLINE_SYSCALL macros, so when open is redefined to open_not_cancel_2 and open_not_cancel_2 is defined as INLINE_SYSCALL (open, ...) it will expand as __NR_open_not_cancel_2. 2003-09-03 Jakub Jelinek * intl/loadmsgcat.c (open, close, read, mmap, munmap): Define as function-like macros. --- libc/intl/loadmsgcat.c.jj 2003-09-03 07:10:34.000000000 -0400 +++ libc/intl/loadmsgcat.c 2003-09-03 07:22:48.000000000 -0400 @@ -454,11 +454,12 @@ char *alloca (); /* Rename the non ISO C functions. This is required by the standard because some ISO C functions will require linking with this object file and the name space must not be polluted. */ -# define open open_not_cancel_2 -# define close close_not_cancel_no_status -# define read read_not_cancel -# define mmap __mmap -# define munmap __munmap +# define open(name, flags) open_not_cancel_2 (name, flags) +# define close(fd) close_not_cancel_no_status (fd) +# define read(fd, buf, n) read_not_cancel (fd, buf, n) +# define mmap(addr, len, prot, flags, fd, offset) \ + __mmap (addr, len, prot, flags, fd, offset) +# define munmap(addr, len) __munmap (addr, len) #endif /* For those losing systems which don't have `alloca' we have to add Jakub From aj@suse.de Wed Sep 3 11:34:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Wed, 03 Sep 2003 11:34:00 -0000 Subject: [PATCH] Re: glibc build fails on x86_64 In-Reply-To: <20030903092652.GV12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Wed, 3 Sep 2003 11:26:52 +0200") References: <20030903082142.GU12344@sunsite.ms.mff.cuni.cz> <20030903092652.GV12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Oh, apparently this was one of the 2 2003-09-02 changes I didn't have in my > tree during that build. No problem. > Try following untested patch. The problem is that non-NPTL linux > not-cancel.h uses INLINE_SYSCALL macros, so when open is redefined to > open_not_cancel_2 and open_not_cancel_2 is defined as INLINE_SYSCALL (open, > ...) it will expand as __NR_open_not_cancel_2. That looks much better than my previous tries, now the file compiles for me. Ok, let's continue... Thanks a lot, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From ralf@linux-mips.org Wed Sep 3 12:57:00 2003 From: ralf@linux-mips.org (Ralf Baechle) Date: Wed, 03 Sep 2003 12:57:00 -0000 Subject: More sigevent ... In-Reply-To: <20030831164812.GB766@bogon.ms20.nix> References: <20030831145854.GB23189@linux-mips.org> <20030831161217.GA10286@linux-mips.org> <20030831164812.GB766@bogon.ms20.nix> Message-ID: <20030903125734.GA9260@linux-mips.org> Looking into the problem a bit deeper here's my analysis of the whole missmatch of struct sigevent and the associated constants, including the entire history. - Linux 2.1.72 introduces sigevent. The definition used is the one taken from IRIX and different from what is used in other Linux ports. But that doesn't matter because there are no in-kernel users. I don't know why the structure was defined at all in kernel headers at all by that time. Maybe for the sake of libc 5? - Some of the >= libc 2.1 version circulating use the kernel definitions - Andreas Jaeger contributes sysdeps/unix/sysv/linux/mips/bits/siginfo.h for the FSF version of glibc 2.1. Markedrd as "XXX This one might need to change!!!" this header file uses the same structure as other Linux architectures but uses the same SIGEV_* constants as the kernel. - Linux 2.5.63 introduces the POSIX.1b timer API which uses the kernel's definition of sigevent. The userspace part of the POSIX.1b timer patch uses glibc's definition. But the code assumes both definitions are identical ... Time to resolve the mess. I see the following options: - Yet another syscall wrapper that does argument conversion. Imho the most icky solution. - Change the kernel to use the same definition as glibc. Not really an option, SIGEV_CALLBACK has to go. - Two part solution: - Change the kernel definition to what other architectures use (Done, may have to be undone depending on the outcome of this discussion). - Remove SIGEV_CALLBACK from glibc which would result in SIGEV_THREAD getting renumbered to the same value as in the kernel. (This is in my withdrawn libc patch from the weekend.) Grepping around in plenty of Linux code I've not found any users of SIGEV_THREAD so this would be my prefered solution. SIGEV_CALLBACK would have to be removed in any case; it's a dead definition with no functionality. Is it supposed to do what SIGEV_THREAD_ID does? I've been digging around in parts of the Redhat 9 source code and haven't found any users of SIGEV_THREAD, so it seems this is a very rarely used feature and we can change without any major compatibility issues. Comments? Ralf From aj@suse.de Thu Sep 4 10:07:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Thu, 04 Sep 2003 10:07:00 -0000 Subject: fix memrchr for GCC 3.4 Message-ID: GCC 3.4 miscompiles memrchr (the testsuite fails). The GCC developers closed my bugs as invalid: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9196 with the following comment: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The C semantics for pointer arithmetic mean that GCC is allowed to assume that this line return __res + 1; never causes a null pointer to be returned. The "mis-optimized" code has been optimized based on that assumption. In short, the bug is in glibc. The simplest fix is to write "incl %0" as the last instruction of the assembly block rather than trying to do this calculation in C. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here's a patch for this, ok to commit? Andreas 2003-09-04 Andreas Jaeger * sysdeps/i386/bits/string.h (__memrchr): Do addition in assembler to make it conforming C. * sysdeps/i386/i486/bits/string.h (__memrchr): Likewise. ============================================================ Index: sysdeps/i386/bits/string.h --- sysdeps/i386/bits/string.h 6 Jul 2001 04:55:53 -0000 1.21 +++ sysdeps/i386/bits/string.h 4 Sep 2003 10:05:12 -0000 @@ -1,5 +1,5 @@ /* Optimized, inlined string functions. i386 version. - Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1997,1998,1999,2000,2003 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 @@ -321,11 +321,12 @@ __memrchr (__const void *__s, int __c, s "repne; scasb\n\t" "je 1f\n\t" "orl $-1,%0\n" - "1:\tcld" + "1:\tcld\n\t" + "incl %0" : "=D" (__res), "=&c" (__d0) : "a" (__c), "0" (__s + __n - 1), "1" (__n) : "cc"); - return __res + 1; + return __res; } # ifdef __USE_GNU # define memrchr(s, c, n) __memrchr (s, c, n) ============================================================ Index: sysdeps/i386/i486/bits/string.h --- sysdeps/i386/i486/bits/string.h 14 Jan 2003 07:44:02 -0000 1.55 +++ sysdeps/i386/i486/bits/string.h 4 Sep 2003 10:05:12 -0000 @@ -484,7 +484,8 @@ __memrchr (__const void *__s, int __c, s ("std\n\t" "repne; scasb\n\t" "cmovne %2,%0\n\t" - "cld" + "cld\n\t" + "incl %0" : "=D" (__res), "=&c" (__d0), "=&r" (__d1) : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1), "m" ( *(struct { __extension__ char __x[__n]; } *)__s) @@ -495,13 +496,14 @@ __memrchr (__const void *__s, int __c, s "repne; scasb\n\t" "je 1f\n\t" "orl $-1,%0\n" - "1:\tcld" + "1:\tcld\n\t" + "incl %0" : "=D" (__res), "=&c" (__d0) : "a" (__c), "0" (__s + __n - 1), "1" (__n), "m" ( *(struct { __extension__ char __x[__n]; } *)__s) : "cc"); # endif - return __res + 1; + return __res; } # ifdef __USE_GNU # define memrchr(s, c, n) __memrchr ((s), (c), (n)) -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jakub@redhat.com Thu Sep 4 10:17:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 04 Sep 2003 10:17:00 -0000 Subject: fix memrchr for GCC 3.4 In-Reply-To: References: Message-ID: <20030904081544.GX12344@sunsite.ms.mff.cuni.cz> On Thu, Sep 04, 2003 at 12:07:55PM +0200, Andreas Jaeger wrote: > > GCC 3.4 miscompiles memrchr (the testsuite fails). The GCC developers > closed my bugs as invalid: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9196 > > with the following comment: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > The C semantics for pointer arithmetic mean that GCC is allowed to assume that > this line > > return __res + 1; > > never causes a null pointer to be returned. The "mis-optimized" code has been > optimized based on that assumption. In short, the bug is in glibc. > > The simplest fix is to write "incl %0" as the last instruction of the assembly > block rather than trying to do this calculation in C. Can't you just make __res unsigned long int instead of void * and add cast (ie. return (void *) (__res + 1); )? Of course, best would be to add __builtin_memrchr to gcc and after making sure gcc finally does better job than all bits/string*.h macros use just gcc builtins. Jakub From drepper@redhat.com Thu Sep 4 12:39:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 04 Sep 2003 12:39:00 -0000 Subject: fix memrchr for GCC 3.4 In-Reply-To: References: Message-ID: <3F57325C.8050703@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jaeger wrote: > Here's a patch for this, ok to commit? Yes- - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/VzJc2ijCOnn/RHQRApWGAJ94qJI/ZQe3kGxZuCOX3N6ZDMUIMQCfYTDL QNehzaYrBQnUOPdK1flqSWM= =a1SO -----END PGP SIGNATURE----- From aj@suse.de Fri Sep 5 05:13:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 Sep 2003 05:13:00 -0000 Subject: Fix i386/fcntl.c Message-ID: building glibc fails with: ../sysdeps/unix/sysv/linux/i386/fcntl.c:36: error: conflicting types for '__fcntl_nocancel' ../include/fcntl.h:12: error: previous declaration of '__fcntl_nocancel' make[2]: *** [/builds/glibc/gcc-3.4/io/fcntl.o] Error 1 Ok to commit? Andreas 2003-09-05 Andreas Jaeger * sysdeps/unix/sysv/linux/i386/fcntl.c (__fcntl_nocancel): Change prototype to use variable argument lists and get the possible one argument via va_arg. ============================================================ Index: sysdeps/unix/sysv/linux/i386/fcntl.c --- sysdeps/unix/sysv/linux/i386/fcntl.c 4 Sep 2003 13:38:44 -0000 1.17 +++ sysdeps/unix/sysv/linux/i386/fcntl.c 5 Sep 2003 05:12:12 -0000 @@ -32,8 +32,15 @@ int __have_no_fcntl64; int -__fcntl_nocancel (int fd, int cmd, void *arg) +__fcntl_nocancel (int fd, int cmd, ...) { + va_list ap; + void *arg; + + va_start (ap, cmd); + arg = va_arg (ap, void *); + va_end (ap); + #if __ASSUME_FCNTL64 == 0 # ifdef __NR_fcntl64 if (! __have_no_fcntl64) -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From drepper@redhat.com Fri Sep 5 05:33:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 Sep 2003 05:33:00 -0000 Subject: Fix i386/fcntl.c In-Reply-To: References: Message-ID: <3F58202D.10808@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Andreas Jaeger wrote: > Ok to commit? Yes. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/WCAt2ijCOnn/RHQRAlBuAJ9Fd10Oaag+qedcaJB7FeoMeJyVagCgwCe4 qsOytn08vYH5/rFIrYdbJMg= =R9R5 -----END PGP SIGNATURE----- From kukuk@suse.de Fri Sep 5 06:02:00 2003 From: kukuk@suse.de (Thorsten Kukuk) Date: Fri, 05 Sep 2003 06:02:00 -0000 Subject: cannot allocate memory in static TLS block Message-ID: <20030905060224.GA22568@suse.de> Hi, compiling the appended test case on i686, gives me the following error messages in some configurations: # ./dlopen-tls dlopen() failed: './tls.so: cannot allocate memory in static TLS block' It does not work with glibc compiled for i686 with TLS and without NPTL (the fallback, if somebody uses an older kernel or LD_ASSUME_KERNEL=2.4.1). Is this a binutils/gcc problem or a bug in glibc? It seems to work on other architectures with the same tool chain (gcc 3.3.1, binutils-2.14.90.0.5). Thanks, Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE Linux AG Deutschherrnstr. 15-19 D-90429 Nuernberg -------------------------------------------------------------------- Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B -------------- next part -------------- all: gcc -g dlopen-tls.c -o dlopen-tls -Wall -ldl gcc -g -c tls.c -o tls.o -fPIC -ftls-model=local-exec gcc -g -o tls.so -shared tls.o clean: rm -rf *.o *~ *.so -------------- next part -------------- #include #include #include #include int main() { void *handle; int (*func)(void); int i; for (i = 0; i < 500; i++) { handle = dlopen("./tls.so", RTLD_NOW); if (!handle) { fprintf(stderr, "dlopen() failed: '%s'\n", dlerror()); exit(1); } func = dlsym(handle, "getTLSVar"); if (!func) { fprintf(stderr, "Failed to find symbol 'getTLSVar'\n"); exit(1); } func(); if (dlclose(handle) != 0) { fprintf(stderr, "dlopen() failed: '%s'\n", dlerror()); exit(1); } printf("success %d\n", i); } return 0; } -------------- next part -------------- static __thread int foo; int getTLSVar(void) { return foo; } From jakub@redhat.com Fri Sep 5 08:16:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 05 Sep 2003 08:16:00 -0000 Subject: cannot allocate memory in static TLS block In-Reply-To: <20030905060224.GA22568@suse.de> References: <20030905060224.GA22568@suse.de> Message-ID: <20030905061451.GZ12344@sunsite.ms.mff.cuni.cz> On Fri, Sep 05, 2003 at 08:02:24AM +0200, Thorsten Kukuk wrote: > > Hi, > > compiling the appended test case on i686, gives me the following > error messages in some configurations: > > # ./dlopen-tls > dlopen() failed: './tls.so: cannot allocate memory in static TLS block' > > It does not work with glibc compiled for i686 with TLS and > without NPTL (the fallback, if somebody uses an older kernel or > LD_ASSUME_KERNEL=2.4.1). > > Is this a binutils/gcc problem or a bug in glibc? It seems to work > on other architectures with the same tool chain (gcc 3.3.1, > binutils-2.14.90.0.5). It works for me with all 3 libc/libpthread combos we have on i686 (linuxthreads non-FLOATING_STACKS TLS, non-__thread, linuxthreads FLOATING_STACKS TLS, non-__thread, NPTL (obviously TLS __thread), aka LD_ASSUME_KERNEL={2.2.5,2.4.1,2.4.20}), about a day old CVS checkout. Jakub From aj@suse.de Fri Sep 5 10:04:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 Sep 2003 10:04:00 -0000 Subject: fix memrchr for GCC 3.4 In-Reply-To: <20030904081544.GX12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Thu, 4 Sep 2003 10:15:44 +0200") References: <20030904081544.GX12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Thu, Sep 04, 2003 at 12:07:55PM +0200, Andreas Jaeger wrote: >> >> GCC 3.4 miscompiles memrchr (the testsuite fails). The GCC developers >> closed my bugs as invalid: >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9196 >> >> with the following comment: >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> The C semantics for pointer arithmetic mean that GCC is allowed to assume that >> this line >> >> return __res + 1; >> >> never causes a null pointer to be returned. The "mis-optimized" code has been >> optimized based on that assumption. In short, the bug is in glibc. >> >> The simplest fix is to write "incl %0" as the last instruction of the assembly >> block rather than trying to do this calculation in C. > > Can't you just make __res unsigned long int instead of void * and > add cast (ie. return (void *) (__res + 1); )? It doesn't look cleaner than my code. > Of course, best would be to add __builtin_memrchr to gcc and after making > sure gcc finally does better job than all bits/string*.h macros use just gcc > builtins. Yes, that would be really the best thing to do. Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From aj@suse.de Fri Sep 5 10:06:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 Sep 2003 10:06:00 -0000 Subject: Fix i386/fcntl.c In-Reply-To: <3F58202D.10808@redhat.com> (Ulrich Drepper's message of "Thu, 04 Sep 2003 22:33:33 -0700") References: <3F58202D.10808@redhat.com> Message-ID: Ulrich Drepper writes: > Andreas Jaeger wrote: > >> Ok to commit? > > Yes. Ok, now both x86-64 and i386 work (with linuxthreads and tls) again (with two further obvious and committed fcntl change) for me, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From jakub@redhat.com Sun Sep 7 11:58:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 07 Sep 2003 11:58:00 -0000 Subject: [PATCH] Fix fcntl on s390x and other arches In-Reply-To: References: <3F58202D.10808@redhat.com> Message-ID: <20030907095715.GE12344@sunsite.ms.mff.cuni.cz> Hi! On Fri, Sep 05, 2003 at 12:06:03PM +0200, Andreas Jaeger wrote: > Ulrich Drepper writes: > > > Andreas Jaeger wrote: > > > >> Ok to commit? > > > > Yes. > > Ok, now both x86-64 and i386 work (with linuxthreads and tls) again > (with two further obvious and committed fcntl change) for me, That way we'd have to update all arches not having their own fcntl.c (e.g. s390x fails to build in current CVS). This is IMHO better: 2003-09-07 Jakub Jelinek * sysdeps/unix/sysv/linux/syscalls.list (fcntl): Remove. * sysdeps/unix/sysv/linux/x86_64/fcntl.c: Remove. --- libc/sysdeps/unix/sysv/linux/syscalls.list.jj 2003-08-26 17:07:48.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/syscalls.list 2003-09-07 06:59:15.000000000 -0400 @@ -73,7 +73,6 @@ uselib EXTRA uselib i:s uselib wait4 - wait4 i:iWiP __wait4 wait4 chown - chown i:sii __libc_chown __chown chown -fcntl - fcntl Ci:iiF __libc_fcntl __fcntl fcntl setxattr - setxattr i:sspii setxattr lsetxattr - lsetxattr i:sspii lsetxattr --- libc/sysdeps/unix/sysv/linux/x86_64/fcntl.c.jj 2003-09-05 04:44:35.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/x86_64/fcntl.c 2003-09-07 06:59:01.000000000 -0400 @@ -1 +0,0 @@ -#include Jakub From aj@suse.de Sun Sep 7 12:07:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Sun, 07 Sep 2003 12:07:00 -0000 Subject: [PATCH] Fix fcntl on s390x and other arches In-Reply-To: <20030907095715.GE12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sun, 7 Sep 2003 11:57:15 +0200") References: <3F58202D.10808@redhat.com> <20030907095715.GE12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Hi! > > On Fri, Sep 05, 2003 at 12:06:03PM +0200, Andreas Jaeger wrote: >> Ulrich Drepper writes: >> >> > Andreas Jaeger wrote: >> > >> >> Ok to commit? >> > >> > Yes. >> >> Ok, now both x86-64 and i386 work (with linuxthreads and tls) again >> (with two further obvious and committed fcntl change) for me, > > That way we'd have to update all arches not having their own fcntl.c > (e.g. s390x fails to build in current CVS). > This is IMHO better: Yes, it is indeed. Thanks! Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From sjmunroe@us.ibm.com Mon Sep 8 16:30:00 2003 From: sjmunroe@us.ibm.com (Steven Munroe) Date: Mon, 08 Sep 2003 16:30:00 -0000 Subject: finishing cancellation handling Message-ID: <3F5CAEB1.9080902@us.ibm.com> Tried running the find-cps tool against a PPC64 glibc built on RHEL 3-Beta2. and can only get: ../find-cps -f libc_pic.a -d libc.so open close find-cps: ../../libelf/elf32_getshdr.c:93: elf64_getshdr: Assertion `ehdr->e_ident[5] != 2 || (! 0 && (ehdr->e_shoff & (__alignof__ (Elf64_Shdr) - 1)) != 0)' failed. Aborted I assume that libelf.so is biarch? The only libelf.so in this install is 32-bit but the libc_pic.a and libc.so are 64-bit... From drepper@redhat.com Mon Sep 8 19:20:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 08 Sep 2003 19:20:00 -0000 Subject: finishing cancellation handling In-Reply-To: <3F5CAEB1.9080902@us.ibm.com> References: <3F5CAEB1.9080902@us.ibm.com> Message-ID: <3F5CD673.7030104@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steven Munroe wrote: > ../find-cps -f libc_pic.a -d libc.so open close > find-cps: ../../libelf/elf32_getshdr.c:93: elf64_getshdr: Assertion > `ehdr->e_ident[5] != 2 || (! 0 && (ehdr->e_shoff & (__alignof__ > (Elf64_Shdr) - 1)) != 0)' failed. > Aborted > > I assume that libelf.so is biarch? The only libelf.so in this install is > 32-bit but the libc_pic.a and libc.so are 64-bit... libelf from elfutils supports all architectures, nothin as crude as biarch. The error means that the ELF data structures as mmaped are unnaturally aligned in memory. This probably happens because the alignment in the archive is unnatural. If you recompile find-cps and change all ELF_C_READ_MMAP to ELF_C_READ it should work. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/XNZz2ijCOnn/RHQRAse2AJsHOf2q0F1EKxQWuzyWDpIZWDErnQCggDIY KKtrBTpCEyoqpUr+S7Sltdo= =8M3q -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Mon Sep 8 20:48:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Mon, 08 Sep 2003 20:48:00 -0000 Subject: finishing cancellation handling Message-ID: Ulrich Drepper writes > If you recompile find-cps and change all ELF_C_READ_MMAP to ELF_C_READ > it should work. Thanks. That helped, but now I am seeing the message: "../find-cps duplicate definition od putw in putw.os previous definition in getw.os" objdump -xd shows this is not true! From jakub@redhat.com Mon Sep 8 21:44:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 08 Sep 2003 21:44:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h Message-ID: <20030908194238.GI12344@sunsite.ms.mff.cuni.cz> Hi! The following patch restores bits/types.h to hwo they looked like on 2002-01-01. In 2002-07-09 commit s390 -m31 __nlink_t/__ssize_t/__intptr_t were (probably) unintentionally changed from int to long and in 2002-10-23 commit lots of types changed from long to long long on 64-bit arches (similarly with ul -> ull and l* -> ll*). My scripts were only checking {alpha,i386,ia64,mips32,powerpc32,powerpc64,s390,s390x,sparc,sparc64,x86_64 -m32,x86_64 -m64}-linux, are there any other 64-bit ports supported in glibc? powerpc64-linux port did not exist at that time, so if we wanted to avoid changes to it now, we could copy the current CVS generic/bits/types.h to sysdeps/unix/sysv/linux/powerpc/bits/types.h, but I think it will be better to match other 64-bit arches. 2003-09-08 Jakub Jelinek * sysdeps/generic/bits/types.h (__quad_t): Make long int if 64-bit. (__u_quad_t): Make unsigned long int if 64-bit. (__SQUAD_TYPE): Make long int if 64-bit. (__UQUAD_TYPE): Make unsigned long int if 64-bit. * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Remove. linuxthreads/ * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Remove. --- libc/sysdeps/generic/bits/types.h.jj 2003-08-06 14:36:15.000000000 -0400 +++ libc/sysdeps/generic/bits/types.h 2003-09-08 17:14:40.000000000 -0400 @@ -51,14 +51,13 @@ __extension__ typedef signed long long i __extension__ typedef unsigned long long int __uint64_t; #endif -/* quad_t is also 64 bits, but is traditionally defined as `long long' - even when `long' is also 64 bits. */ -#ifdef __GLIBC_HAVE_LONG_LONG -__extension__ typedef long long int __quad_t; -__extension__ typedef unsigned long long int __u_quad_t; -#elif __WORDSIZE == 64 +/* quad_t is also 64 bits. */ +#if __WORDSIZE == 64 typedef long int __quad_t; typedef unsigned long int __u_quad_t; +#elif defined __GLIBC_HAVE_LONG_LONG +__extension__ typedef long long int __quad_t; +__extension__ typedef unsigned long long int __u_quad_t; #else typedef struct { @@ -106,9 +105,9 @@ typedef struct #define __U32_TYPE unsigned int #define __SLONGWORD_TYPE long int #define __ULONGWORD_TYPE unsigned long int +#if __WORDSIZE == 32 #define __SQUAD_TYPE long long int #define __UQUAD_TYPE unsigned long long int -#if __WORDSIZE == 32 # define __SWORD_TYPE int # define __UWORD_TYPE unsigned int # define __SLONG32_TYPE long int @@ -116,6 +115,8 @@ typedef struct # define __S64_TYPE __quad_t # define __U64_TYPE __u_quad_t #elif __WORDSIZE == 64 +#define __SQUAD_TYPE long int +#define __UQUAD_TYPE unsigned long int # define __SWORD_TYPE long int # define __UWORD_TYPE unsigned long int # define __SLONG32_TYPE int --- libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h.jj 2003-07-31 15:32:29.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 2003-09-08 17:26:51.000000000 -0400 @@ -1,66 +0,0 @@ -/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _BITS_TYPES_H -# error "Never include directly; use instead." -#endif - -#ifndef _BITS_TYPESIZES_H -#define _BITS_TYPESIZES_H 1 - -/* See for the meaning of these macros. This file exists so - that need not vary across different GNU platforms. */ - -#define __DEV_T_TYPE __UQUAD_TYPE -#define __UID_T_TYPE __U32_TYPE -#define __GID_T_TYPE __U32_TYPE -#define __INO_T_TYPE __ULONGWORD_TYPE -#define __INO64_T_TYPE __UQUAD_TYPE -#define __MODE_T_TYPE __U32_TYPE -#define __NLINK_T_TYPE __UWORD_TYPE -#define __OFF_T_TYPE __SLONGWORD_TYPE -#define __OFF64_T_TYPE __SQUAD_TYPE -#define __PID_T_TYPE __S32_TYPE -#define __RLIM_T_TYPE __ULONGWORD_TYPE -#define __RLIM64_T_TYPE __UQUAD_TYPE -#define __BLKCNT_T_TYPE __SLONGWORD_TYPE -#define __BLKCNT64_T_TYPE __SQUAD_TYPE -#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE -#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE -#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE -#define __FSFILCNT64_T_TYPE __UQUAD_TYPE -#define __ID_T_TYPE __U32_TYPE -#define __CLOCK_T_TYPE __SLONGWORD_TYPE -#define __TIME_T_TYPE __SLONGWORD_TYPE -#define __USECONDS_T_TYPE __U32_TYPE -#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE -#define __DADDR_T_TYPE __S32_TYPE -#define __SWBLK_T_TYPE __SLONGWORD_TYPE -#define __KEY_T_TYPE __S32_TYPE -#define __CLOCKID_T_TYPE __S32_TYPE -#define __TIMER_T_TYPE void * -#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE -#define __FSID_T_TYPE struct { int __val[2]; } -#define __SSIZE_T_TYPE __SLONGWORD_TYPE - -/* Number of descriptors that can fit in an `fd_set'. */ -#define __FD_SETSIZE 1024 - - -#endif /* bits/typesizes.h */ --- libc/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h.jj 2003-08-01 00:36:20.000000000 -0400 +++ libc/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 2003-09-08 17:27:13.000000000 -0400 @@ -1,66 +0,0 @@ -/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _BITS_TYPES_H -# error "Never include directly; use instead." -#endif - -#ifndef _BITS_TYPESIZES_H -#define _BITS_TYPESIZES_H 1 - -/* See for the meaning of these macros. This file exists so - that need not vary across different GNU platforms. */ - -#define __DEV_T_TYPE __UQUAD_TYPE -#define __UID_T_TYPE __U32_TYPE -#define __GID_T_TYPE __U32_TYPE -#define __INO_T_TYPE __ULONGWORD_TYPE -#define __INO64_T_TYPE __UQUAD_TYPE -#define __MODE_T_TYPE __U32_TYPE -#define __NLINK_T_TYPE __UWORD_TYPE -#define __OFF_T_TYPE __SLONGWORD_TYPE -#define __OFF64_T_TYPE __SQUAD_TYPE -#define __PID_T_TYPE __S32_TYPE -#define __RLIM_T_TYPE __ULONGWORD_TYPE -#define __RLIM64_T_TYPE __UQUAD_TYPE -#define __BLKCNT_T_TYPE __SLONGWORD_TYPE -#define __BLKCNT64_T_TYPE __SQUAD_TYPE -#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE -#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE -#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE -#define __FSFILCNT64_T_TYPE __UQUAD_TYPE -#define __ID_T_TYPE __U32_TYPE -#define __CLOCK_T_TYPE __SLONGWORD_TYPE -#define __TIME_T_TYPE __SLONGWORD_TYPE -#define __USECONDS_T_TYPE __U32_TYPE -#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE -#define __DADDR_T_TYPE __S32_TYPE -#define __SWBLK_T_TYPE __SLONGWORD_TYPE -#define __KEY_T_TYPE __S32_TYPE -#define __CLOCKID_T_TYPE __S32_TYPE -#define __TIMER_T_TYPE __S32_TYPE -#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE -#define __FSID_T_TYPE struct { int __val[2]; } -#define __SSIZE_T_TYPE __SLONGWORD_TYPE - -/* Number of descriptors that can fit in an `fd_set'. */ -#define __FD_SETSIZE 1024 - - -#endif /* bits/typesizes.h */ Jakub From drepper@redhat.com Tue Sep 9 00:08:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Sep 2003 00:08:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h In-Reply-To: <20030908194238.GI12344@sunsite.ms.mff.cuni.cz> References: <20030908194238.GI12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F5D19D0.7010303@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Checked in. A regression check for the name mangling is added, too. We just need base data for the various archs now. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/XRnQ2ijCOnn/RHQRAq4IAJ4giGveJKSR93XuzKZvb/nqLZhcdwCghG7X /ekdcFABe4QCBeTp/ZSWpDM= =mU+j -----END PGP SIGNATURE----- From kukuk@suse.de Tue Sep 9 04:30:00 2003 From: kukuk@suse.de (Thorsten Kukuk) Date: Tue, 09 Sep 2003 04:30:00 -0000 Subject: speed.c changes breaks on sparc32 Message-ID: <20030909043037.GA32114@suse.de> Hi, The current glibc CVS does not build on sparc32 any longer: ../sysdeps/unix/sysv/linux/speed.c: In function `cfsetospeed': ../sysdeps/unix/sysv/linux/speed.c:70: error: structure has no member named `c_ospeed' ../sysdeps/unix/sysv/linux/speed.c: In function `cfsetispeed': ../sysdeps/unix/sysv/linux/speed.c:95: error: structure has no member named `c_ispeed' make[2]: *** [/usr/src/packages/BUILD/glibc-2.3/cc/termios/speed.o] Error 1 Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE Linux AG Deutschherrnstr. 15-19 D-90429 Nuernberg -------------------------------------------------------------------- Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B From roland@redhat.com Tue Sep 9 06:44:00 2003 From: roland@redhat.com (Roland McGrath) Date: Tue, 09 Sep 2003 06:44:00 -0000 Subject: speed.c changes breaks on sparc32 In-Reply-To: Thorsten Kukuk's message of Tuesday, 9 September 2003 06:30:37 +0200 <20030909043037.GA32114@suse.de> Message-ID: <200309090644.h896iss04857@magilla.sf.frob.com> > The current glibc CVS does not build on sparc32 any longer: > > ../sysdeps/unix/sysv/linux/speed.c: In function `cfsetospeed': > ../sysdeps/unix/sysv/linux/speed.c:70: error: structure has no member named `c_ospeed' > ../sysdeps/unix/sysv/linux/speed.c: In function `cfsetispeed': > ../sysdeps/unix/sysv/linux/speed.c:95: error: structure has no member named `c_ispeed' > make[2]: *** [/usr/src/packages/BUILD/glibc-2.3/cc/termios/speed.o] Error 1 Should be fixed now. From jakub@redhat.com Tue Sep 9 10:51:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 09 Sep 2003 10:51:00 -0000 Subject: [PATCH] Fix x86-64 sigcontextinfo.h Message-ID: <20030909084949.GK12344@sunsite.ms.mff.cuni.cz> Hi! This patch matches what the kernel does, passed make check (linuxthreads, NPTL and NPTL with linuxthreads ld.so) and libSegFault.so works. linuxthreads __pthread_sighandler doesn't have to copy 936 bytes around, just passes the pointer which was given to it. 2003-09-09 Jakub Jelinek * sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h (SIGCONTEXT): Add siginfo_t * argument before, change into struct ucontext *. (SIGCONTEXT_EXTRA_ARGS): Define to _si,. (GET_PC, GET_FRAME, GET_STACK): Adjust for ctx being a pointer instead of structure. * sysdeps/unix/sysv/linux/x86_64/register-dump.h (REGISTER_DUMP): Likewise. --- libc/sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h.jj 2003-09-09 05:17:06.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h 2003-09-09 05:48:38.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,11 +16,11 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define SIGCONTEXT struct ucontext -#define SIGCONTEXT_EXTRA_ARGS -#define GET_PC(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RIP]) -#define GET_FRAME(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RBP]) -#define GET_STACK(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RSP]) +#define SIGCONTEXT siginfo_t *_si, struct ucontext * +#define SIGCONTEXT_EXTRA_ARGS _si, +#define GET_PC(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RIP]) +#define GET_FRAME(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RBP]) +#define GET_STACK(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RSP]) #define CALL_SIGHANDLER(handler, signo, ctx) \ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx)) --- libc/sysdeps/unix/sysv/linux/x86_64/register-dump.h.jj 2003-09-09 05:17:06.000000000 -0400 +++ libc/sysdeps/unix/sysv/linux/x86_64/register-dump.h 2003-09-09 05:53:43.000000000 -0400 @@ -343,4 +343,4 @@ register_dump (int fd, struct ucontext * } -#define REGISTER_DUMP register_dump (fd, &ctx) +#define REGISTER_DUMP register_dump (fd, ctx) Jakub From aj@suse.de Tue Sep 9 12:17:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Tue, 09 Sep 2003 12:17:00 -0000 Subject: [PATCH] Fix x86-64 sigcontextinfo.h In-Reply-To: <20030909084949.GK12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Tue, 9 Sep 2003 10:49:49 +0200") References: <20030909084949.GK12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Hi! > > This patch matches what the kernel does, passed make check (linuxthreads, > NPTL and NPTL with linuxthreads ld.so) and libSegFault.so works. > linuxthreads __pthread_sighandler doesn't have to copy 936 bytes around, > just passes the pointer which was given to it. And does not copy more data than was passed to it - the kernel might pass less than those bytes around. > 2003-09-09 Jakub Jelinek > > * sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h (SIGCONTEXT): Add > siginfo_t * argument before, change into struct ucontext *. > (SIGCONTEXT_EXTRA_ARGS): Define to _si,. > (GET_PC, GET_FRAME, GET_STACK): Adjust for ctx being a pointer > instead of structure. > * sysdeps/unix/sysv/linux/x86_64/register-dump.h (REGISTER_DUMP): > Likewise. > > --- libc/sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h.jj 2003-09-09 05:17:06.000000000 -0400 > +++ libc/sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h 2003-09-09 05:48:38.000000000 -0400 > @@ -1,4 +1,4 @@ > -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. > +/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > @@ -16,11 +16,11 @@ > Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > 02111-1307 USA. */ > > -#define SIGCONTEXT struct ucontext > -#define SIGCONTEXT_EXTRA_ARGS > -#define GET_PC(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RIP]) > -#define GET_FRAME(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RBP]) > -#define GET_STACK(ctx) ((void *) (ctx).uc_mcontext.gregs[REG_RSP]) > +#define SIGCONTEXT siginfo_t *_si, struct ucontext * > +#define SIGCONTEXT_EXTRA_ARGS _si, > +#define GET_PC(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RIP]) > +#define GET_FRAME(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RBP]) > +#define GET_STACK(ctx) ((void *) (ctx)->uc_mcontext.gregs[REG_RSP]) > > #define CALL_SIGHANDLER(handler, signo, ctx) \ > (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx)) > --- libc/sysdeps/unix/sysv/linux/x86_64/register-dump.h.jj 2003-09-09 05:17:06.000000000 -0400 > +++ libc/sysdeps/unix/sysv/linux/x86_64/register-dump.h 2003-09-09 05:53:43.000000000 -0400 > @@ -343,4 +343,4 @@ register_dump (int fd, struct ucontext * > } > > > -#define REGISTER_DUMP register_dump (fd, &ctx) > +#define REGISTER_DUMP register_dump (fd, ctx) Thanks! This looks correct to me! Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From jes@trained-monkey.org Tue Sep 9 14:23:00 2003 From: jes@trained-monkey.org (Jes Sorensen) Date: Tue, 09 Sep 2003 14:23:00 -0000 Subject: [patch] glibc/ia64 memccpy segfault Message-ID: <16221.57974.700230.281358@trained-monkey.org> Hi, Please find attached a patch which I have been sitting on for way too long. It should apply cleanly to both glibc-2.2 and glibc-2.3. It basically solve a bug in the ia64 memccpy implementation where the readahead will cause a segfault if you try to memccpy from across a page boundary, with the second page not being mapped and the end-of-stream character is found in the original page. This is a segfault bugfix and I recommend distributions to include it in their next updates. Cheers, Jes 2003-04-11 Jes Sorensen * sysdeps/ia64/memccpy.S: When recovering for src_aligned and the character is found during recovery, use correct register when determining the position of the found character. 2003-04-01 Jes Sorensen * sysdeps/ia64/memccpy.S: Use speculatively loads for readahead to avoid segfaults when reading from unmapped pages. For aligned reload and continue, for misaligned, roll back and use byte copy. Save ar.ec on entry and restore on exit. Index: sysdeps/ia64/memccpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/ia64/memccpy.S,v retrieving revision 1.5 diff -u -r1.5 memccpy.S --- sysdeps/ia64/memccpy.S 6 Jul 2001 04:55:54 -0000 1.5 +++ sysdeps/ia64/memccpy.S 9 Sep 2003 14:15:32 -0000 @@ -1,6 +1,6 @@ /* Optimized version of the memccpy() function. This file is part of the GNU C Library. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. Contributed by Dan Pop . The GNU C Library is free software; you can redistribute it and/or @@ -46,6 +46,7 @@ #define tmp r23 #define char r24 #define charx8 r25 +#define saved_ec r26 #define sh2 r28 #define sh1 r29 #define loopcnt r30 @@ -56,25 +57,27 @@ alloc r2 = ar.pfs, 4, 40 - 4, 0, 40 #include "softpipe.h" - .rotr r[MEMLAT + 3], tmp1[4], tmp2[4], val[4], tmp3[2], pos0[2] + .rotr r[MEMLAT + 7], tmp1[4], tmp2[4], val[4], tmp3[2], pos0[2] .rotp p[MEMLAT + 6 + 1] mov ret0 = r0 // return NULL if no match .save pr, saved_pr mov saved_pr = pr // save the predicate registers + mov dest = in0 // dest .save ar.lc, saved_lc mov saved_lc = ar.lc // save the loop counter + mov saved_ec = ar.ec // save the loop counter .body - mov dest = in0 // dest mov src = in1 // src extr.u char = in2, 0, 8 // char mov len = in3 // len sub tmp = r0, in0 // tmp = -dest cmp.ne p7, p0 = r0, r0 // clear p7 ;; - and loopcnt = 7, tmp // loopcnt = -dest % 8 + and loopcnt = 7, tmp // loopcnt = -dest % 8 cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES -(p6) br.cond.spnt .cpyfew // copy byte by byte + mov ar.ec = 0 // ec not guaranteed zero on entry +(p6) br.cond.spnt .cpyfew // copy byte by byte ;; cmp.eq p6, p0 = loopcnt, r0 mux1 charx8 = char, @brcst @@ -109,26 +112,31 @@ cmp.ne p6, p0 = r0, r0 ;; // clear p6 .align 32 .l2: -(p[0]) ld8 r[0] = [asrc], 8 // r[0] = w1 +(p[0]) ld8.s r[0] = [asrc], 8 // r[0] = w1 (p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1 (p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2 (p[MEMLAT+4]) xor tmp3[0] = val[1], charx8 (p[MEMLAT+5]) czx1.r pos0[0] = tmp3[1] +(p[MEMLAT+6]) chk.s r[6 + MEMLAT], .recovery1 // our data isn't + // valid - rollback! (p[MEMLAT+6]) cmp.ne p6, p0 = 8, pos0[1] (p6) br.cond.spnt .gotit (p[MEMLAT+6]) st8 [dest] = val[3], 8 // store val to dest (p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2 br.ctop.sptk .l2 br.cond.sptk .cpyfew + .src_aligned: cmp.ne p6, p0 = r0, r0 // clear p6 mov ar.ec = MEMLAT + 2 + 1 ;; // set EC .l3: -(p[0]) ld8 r[0] = [src], 8 +(p[0]) ld8.s r[0] = [src], 8 (p[MEMLAT]) xor tmp3[0] = r[MEMLAT], charx8 (p[MEMLAT+1]) czx1.r pos0[0] = tmp3[1] (p[MEMLAT+2]) cmp.ne p7, p0 = 8, pos0[1] +(p[MEMLAT+2]) chk.s r[MEMLAT+2], .recovery2 (p7) br.cond.spnt .gotit +.back2: (p[MEMLAT+2]) st8 [dest] = r[MEMLAT+2], 8 br.ctop.dptk .l3 .cpyfew: @@ -148,6 +156,7 @@ .restore_and_exit: mov pr = saved_pr, -1 // restore the predicate registers mov ar.lc = saved_lc // restore the loop counter + mov ar.ec = saved_ec ;; // restore the epilog counter br.ret.sptk.many b0 .gotit: .pred.rel "mutex" p6, p7 @@ -163,4 +172,33 @@ mov pr = saved_pr, -1 mov ar.lc = saved_lc br.ret.sptk.many b0 + +.recovery1: + adds src = -(MEMLAT + 6 + 1) * 8, asrc + mov loopcnt = ar.lc + mov tmp = ar.ec ;; + sub sh1 = (MEMLAT + 6 + 1), tmp + shr.u sh2 = sh2, 3 + ;; + shl loopcnt = loopcnt, 3 + sub src = src, sh2 + shl sh1 = sh1, 3 + shl tmp = tmp, 3 + ;; + add len = len, loopcnt + add src = sh1, src ;; + add len = tmp, len +.back1: + br.cond.sptk .cpyfew + +.recovery2: + add tmp = -(MEMLAT + 3) * 8, src +(p7) br.cond.spnt .gotit + ;; + ld8 r[MEMLAT+2] = [tmp] ;; + xor pos0[1] = r[MEMLAT+2], charx8 ;; + czx1.r pos0[1] = pos0[1] ;; + cmp.ne p7, p6 = 8, pos0[1] +(p7) br.cond.spnt .gotit + br.cond.sptk .back2 END(memccpy) From roland@redhat.com Tue Sep 9 19:08:00 2003 From: roland@redhat.com (Roland McGrath) Date: Tue, 09 Sep 2003 19:08:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h In-Reply-To: Jakub Jelinek's message of Monday, 8 September 2003 21:42:38 +0200 <20030908194238.GI12344@sunsite.ms.mff.cuni.cz> Message-ID: <200309091908.h89J8R829130@magilla.sf.frob.com> > and in 2002-10-23 commit lots of types changed from long to long long > on 64-bit arches (similarly with ul -> ull and l* -> ll*). That was intentional on my part, removing gratuitous source differences between 32- and 64-bit platforms. But I was only thinking about C, where the width of the type is the only thing that matters, not C++ where names matter. > My scripts were only checking > {alpha,i386,ia64,mips32,powerpc32,powerpc64,s390,s390x,sparc,sparc64,x86_64 -m32,x86_64 -m64}-linux, > are there any other 64-bit ports supported in glibc? Don't think so. > powerpc64-linux port did not exist at that time, so if we wanted to avoid > changes to it now, we could copy the current CVS generic/bits/types.h > to sysdeps/unix/sysv/linux/powerpc/bits/types.h, but I think it will > be better to match other 64-bit arches. I tend to agree, but the PPC32 and PPC64 port maintainers should say something. Modulo port maintainers' concerns I think your changes are fine. From drepper@redhat.com Tue Sep 9 20:17:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Sep 2003 20:17:00 -0000 Subject: [patch] glibc/ia64 memccpy segfault In-Reply-To: <16221.57974.700230.281358@trained-monkey.org> References: <16221.57974.700230.281358@trained-monkey.org> Message-ID: <3F5E3550.2070300@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jes Sorensen wrote: > It basically solve a bug in the ia64 memccpy implementation where the > readahead will cause a segfault if you try to memccpy from across a page > boundary, I checked the patch in after writing a test case. Thanks, - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/XjVQ2ijCOnn/RHQRAjqVAJ4zzdZlFzTJwamhbLjtDji+5MlvhgCgqydv yGvTbmgQnzSm4vw5HGfSTTM= =1+AP -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Tue Sep 9 21:28:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Tue, 09 Sep 2003 21:28:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h Message-ID: Roland McGrath writes: > > powerpc64-linux port did not exist at that time, so if we wanted to avoid > > changes to it now, we could copy the current CVS generic/bits/types.h > > to sysdeps/unix/sysv/linux/powerpc/bits/types.h, but I think it will > > be better to match other 64-bit arches. > I tend to agree, but the PPC32 and PPC64 port maintainers should say > something. PPC64 builds and runs make check without error with this change. Since for PPC64 long and long long are the same size this is what I would expect. If there are problems it will be higher in the foodchain (C++). From drepper@redhat.com Tue Sep 9 21:34:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Sep 2003 21:34:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h In-Reply-To: References: Message-ID: <3F5E475B.1040203@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > PPC64 builds and runs make check without error with this change. Since for > > PPC64 long and long long are the same size this is what I would expect. If > > there are problems it will be higher in the foodchain (C++). But this is exactly what we are talking about. Keeping the size alone isn't enough. The mangled name in C++ mustn't change either. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/Xkdb2ijCOnn/RHQRAsGeAJ0fp63sUOhQdCstdbaTWksNeVC/MACcCyIR HMD4kTPRpW+aZmW43SkNwu4= =b3by -----END PGP SIGNATURE----- From jes@trained-monkey.org Tue Sep 9 22:38:00 2003 From: jes@trained-monkey.org (Jes Sorensen) Date: Tue, 09 Sep 2003 22:38:00 -0000 Subject: [patch] glibc/ia64 memccpy segfault In-Reply-To: <3F5E3550.2070300@redhat.com> References: <16221.57974.700230.281358@trained-monkey.org> <3F5E3550.2070300@redhat.com> Message-ID: >>>>> "Ulrich" == Ulrich Drepper writes: Ulrich> Jes Sorensen wrote: >> It basically solve a bug in the ia64 memccpy implementation where >> the readahead will cause a segfault if you try to memccpy from >> across a page boundary, Ulrich> I checked the patch in after writing a test case. Thanks, Hi Uli, Thanks for checking it in. How do you feel of pushing this one for 2.2 as well? It contains the same bug. Cheers, Jes From drepper@redhat.com Tue Sep 9 22:56:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Sep 2003 22:56:00 -0000 Subject: [patch] glibc/ia64 memccpy segfault In-Reply-To: References: <16221.57974.700230.281358@trained-monkey.org> <3F5E3550.2070300@redhat.com> Message-ID: <3F5E5A87.5050402@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jes Sorensen wrote: > Thanks for checking it in. How do you feel of pushing this one for 2.2 > as well? It contains the same bug. That branch is in deep freeze and won't be changed again ever. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/XlqH2ijCOnn/RHQRAipkAKDA0zE5+oHcn4RWkuSGDd4T35h3cACcCzOy LpRUsau8l+8RwQMmwrnXnOk= =fMkp -----END PGP SIGNATURE----- From drepper@redhat.com Tue Sep 9 23:59:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Sep 2003 23:59:00 -0000 Subject: [PATCH] Fix x86-64 sigcontextinfo.h In-Reply-To: <20030909084949.GK12344@sunsite.ms.mff.cuni.cz> References: <20030909084949.GK12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F5E6918.8000303@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jakub Jelinek wrote: > 2003-09-09 Jakub Jelinek > > * sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h (SIGCONTEXT): Add > siginfo_t * argument before, change into struct ucontext *. > (SIGCONTEXT_EXTRA_ARGS): Define to _si,. > (GET_PC, GET_FRAME, GET_STACK): Adjust for ctx being a pointer > instead of structure. > * sysdeps/unix/sysv/linux/x86_64/register-dump.h (REGISTER_DUMP): > Likewise. Seems to work nicely, I've applied it. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/XmkY2ijCOnn/RHQRArxSAKCtcNawXaH0cQ0p60SJEoYvrfmjAgCfSEnS Au3AlD6UUGntu9/O99kcrIk= =FBb2 -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Wed Sep 10 19:55:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Wed, 10 Sep 2003 19:55:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h Message-ID: Ulrich Drepper writes: > But this is exactly what we are talking about. Keeping the size alone > isn't enough. The mangled name in C++ mustn't change either. This change does create a problem for powerpc and the new c++-types-check. The data file names are only qualified with $base-machine (as in c++-types-powerpc-linux-gnu.data) but 64-bit types will require different data files between powerpc32 and powerpc64. Perhaps libc/Makefile can check scripts/c++-types-$(base-machine)-$(config-os).data and if not found try scripts/c++-types-$(config-machine)-$(config-os).data? There also seems to be a problem with pthread_t between linuxthreads and nptl. pthread_t:m is OK for Linuxthreads but nplt needs pthread_t:P16__opaque_pthread. From jakub@redhat.com Wed Sep 10 20:00:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 10 Sep 2003 20:00:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h In-Reply-To: References: Message-ID: <20030910175920.GT12344@sunsite.ms.mff.cuni.cz> On Wed, Sep 10, 2003 at 02:55:24PM -0500, Steve Munroe wrote: > There also seems to be a problem with pthread_t between linuxthreads and > nptl. pthread_t:m is OK for Linuxthreads but nplt needs > pthread_t:P16__opaque_pthread. Current NPTL has: typedef unsigned long int pthread_t; Jakub From drepper@redhat.com Wed Sep 10 20:05:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 10 Sep 2003 20:05:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h In-Reply-To: References: Message-ID: <3F5F83DE.6030308@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > Perhaps libc/Makefile can > check scripts/c++-types-$(base-machine)-$(config-os).data and if not found > try scripts/c++-types-$(config-machine)-$(config-os).data? OK, I'll try something like this. > > There also seems to be a problem with pthread_t between linuxthreads and > nptl. pthread_t:m is OK for Linuxthreads but nplt needs > pthread_t:P16__opaque_pthread. This is changed in the current NPTL sources. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/X4Pe2ijCOnn/RHQRAlfrAKCZsHhF8qIQQdyzvXmHoC/UowRd2gCgqriU ZKnzxGpWJ76yCAXY9LMQlfE= =M9ma -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Wed Sep 10 20:13:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Wed, 10 Sep 2003 20:13:00 -0000 Subject: [PATCH] Fix binary compatibility of bits/types.h Message-ID: Ulrich Drepper writes: > This is changed in the current NPTL sources. nptl-0.58 comming soon? From jakub@redhat.com Thu Sep 11 21:31:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 11 Sep 2003 21:31:00 -0000 Subject: [PATCH] Kill one unnecessary .plt slot on Hammer Message-ID: <20030911192956.GF12344@sunsite.ms.mff.cuni.cz> Hi! 2003-09-11 Jakub Jelinek * libio/fileops.c (_IO_new_file_overflow): Add INTUSE to _IO_free_backup_area call. --- libc/libio/fileops.c.jj 2003-09-08 02:31:46.000000000 -0400 +++ libc/libio/fileops.c 2003-09-11 17:13:48.000000000 -0400 @@ -844,7 +844,7 @@ _IO_new_file_overflow (f, ch) if (__builtin_expect (_IO_in_backup (f), 0)) { size_t nbackup = f->_IO_read_end - f->_IO_read_ptr; - _IO_free_backup_area (f); + INTUSE(_IO_free_backup_area) (f); f->_IO_read_base -= MIN (nbackup, f->_IO_read_base - f->_IO_buf_base); f->_IO_read_ptr = f->_IO_read_base; Jakub From drepper@redhat.com Thu Sep 11 23:34:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 11 Sep 2003 23:34:00 -0000 Subject: [PATCH] Kill one unnecessary .plt slot on Hammer In-Reply-To: <20030911192956.GF12344@sunsite.ms.mff.cuni.cz> References: <20030911192956.GF12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F610666.9040303@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jakub Jelinek wrote: > 2003-09-11 Jakub Jelinek > > * libio/fileops.c (_IO_new_file_overflow): Add INTUSE to > _IO_free_backup_area call. Applied. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/YQZm2ijCOnn/RHQRAu6RAJ4jDZpXX3+QfZ2xyy26eFZ4PEM1ggCgugj/ O6g1DvgVxlm//1d+DTJEmbs= =rACS -----END PGP SIGNATURE----- From jakub@redhat.com Fri Sep 12 14:40:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 12 Sep 2003 14:40:00 -0000 Subject: [PATCH] Change s390 ssize_t back to long int Message-ID: <20030912123905.GG12344@sunsite.ms.mff.cuni.cz> Hi! As per discussion with Martin: 2003-09-12 Jakub Jelinek * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: New. (__SSIZE_T_TYPE): Define to __SWORD_TYPE for gcc 2.95.x and __SLONGWORD_TYPE otherwise. linuxthreads/ * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: New. (__SSIZE_T_TYPE): Define to __SWORD_TYPE for gcc 2.95.x and __SLONGWORD_TYPE otherwise. --- libc/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 1 Jan 1970 00:00:00 -0000 +++ libc/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 12 Sep 2003 11:25:46 -0000 1.3 @@ -0,0 +1,72 @@ +/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ + +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __ULONGWORD_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __UWORD_TYPE +#define __OFF_T_TYPE __SLONGWORD_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __ULONGWORD_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SLONGWORD_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SLONGWORD_TYPE +#define __TIME_T_TYPE __SLONGWORD_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __SWBLK_T_TYPE __SLONGWORD_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE __S32_TYPE +#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#if defined __GNUC__ && __GNUC__ <= 2 +/* Compatibility with g++ 2.95.x. */ +#define __SSIZE_T_TYPE __SWORD_TYPE +#else +/* size_t is unsigned long int on s390 -m31. */ +#define __SSIZE_T_TYPE __SLONGWORD_TYPE +#endif + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */ --- libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 1 Jan 1970 00:00:00 -0000 +++ libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h 12 Sep 2003 11:25:46 -0000 1.3 @@ -0,0 +1,72 @@ +/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ + +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __ULONGWORD_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __UWORD_TYPE +#define __OFF_T_TYPE __SLONGWORD_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __ULONGWORD_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SLONGWORD_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SLONGWORD_TYPE +#define __TIME_T_TYPE __SLONGWORD_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __SWBLK_T_TYPE __SLONGWORD_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE void * +#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#if defined __GNUC__ && __GNUC__ <= 2 +/* Compatibility with g++ 2.95.x. */ +#define __SSIZE_T_TYPE __SWORD_TYPE +#else +/* size_t is unsigned long int on s390 -m31. */ +#define __SSIZE_T_TYPE __SLONGWORD_TYPE +#endif + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */ Jakub From sjmunroe@us.ibm.com Fri Sep 12 21:25:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 12 Sep 2003 21:25:00 -0000 Subject: Tuning malloc.c Message-ID: For 64-bit systems it would be nice to adjust some of the malloc tunning parameters. For example: MMAP_AS_MORECORE_SIZE DEFAULT_TRIM_THRESHOLD DEFAULT_MMAP_THRESHOLD HEAP_MIN_SIZE HEAP_MAX_SIZE For a 64-bit machine these values should be larger to avoid excessive mmap/unmap activity for large transient mallocs. Unfortunately there seems to be no clear, arch specific, mechanism for overriding the defaults in malloc.c. Should there be a mallocconf.h? From roland@redhat.com Fri Sep 12 21:50:00 2003 From: roland@redhat.com (Roland McGrath) Date: Fri, 12 Sep 2003 21:50:00 -0000 Subject: Tuning malloc.c In-Reply-To: Steve Munroe's message of Friday, 12 September 2003 16:25:35 -0500 Message-ID: <200309122150.h8CLoWT28349@magilla.sf.frob.com> > Unfortunately there seems to be no clear, arch specific, mechanism for > overriding the defaults in malloc.c. Should there be a mallocconf.h? We can add a malloc-tuning.h header in sysdeps, sure. From drepper@redhat.com Sun Sep 14 08:04:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 14 Sep 2003 08:04:00 -0000 Subject: [PATCH] Change s390 ssize_t back to long int In-Reply-To: <20030912123905.GG12344@sunsite.ms.mff.cuni.cz> References: <20030912123905.GG12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F6420C9.1070702@redhat.com> Jakub Jelinek wrote: > 2003-09-12 Jakub Jelinek > > * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: New. > (__SSIZE_T_TYPE): Define to __SWORD_TYPE for gcc 2.95.x and > __SLONGWORD_TYPE otherwise. > linuxthreads/ > * sysdeps/unix/sysv/linux/s390/bits/typesizes.h: New. > (__SSIZE_T_TYPE): Define to __SWORD_TYPE for gcc 2.95.x and > __SLONGWORD_TYPE otherwise. I've applied the patch now. It should be clear that this is a break of the ABI from early glibc versions. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From Philip.Blundell@pobox.com Sun Sep 14 17:15:00 2003 From: Philip.Blundell@pobox.com (Philip Blundell) Date: Sun, 14 Sep 2003 17:15:00 -0000 Subject: better memset for arm Message-ID: <1063559701.16948.1.camel@kc.cam.armlinux.org> The existing implementation of memset() on arm is fairly poor. Here's a better version. p. -------------- next part -------------- 2003-09-14 Philip Blundell * sysdeps/arm/memset.S: Rewrite. Index: sysdeps/arm/memset.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/arm/memset.S,v retrieving revision 1.4 diff -u -r1.4 memset.S --- sysdeps/arm/memset.S 29 Apr 2003 22:47:20 -0000 1.4 +++ sysdeps/arm/memset.S 14 Sep 2003 17:12:45 -0000 @@ -22,47 +22,46 @@ /* void *memset (dstpp, c, len) */ ENTRY(memset) - mov a4, a1 - cmp a3, $8 @ at least 8 bytes to do? - blt 2f - orr a2, a2, a2, lsl $8 - orr a2, a2, a2, lsl $16 + mov r3, r0 + cmp r2, #8 + bcc 2f @ less than 8 bytes to move + 1: - tst a4, $3 @ aligned yet? - strneb a2, [a4], $1 - subne a3, a3, $1 + tst r3, #3 @ aligned yet? + strneb r1, [r3], #1 + subne r2, r2, #1 bne 1b - mov ip, a2 + + orr r1, r1, r1, lsl $8 + orr r1, r1, r1, lsl $16 + 1: - cmp a3, $8 @ 8 bytes still to do? - blt 2f - stmia a4!, {a2, ip} - sub a3, a3, $8 - cmp a3, $8 @ 8 bytes still to do? - blt 2f - stmia a4!, {a2, ip} - sub a3, a3, $8 - cmp a3, $8 @ 8 bytes still to do? - blt 2f - stmia a4!, {a2, ip} - sub a3, a3, $8 - cmp a3, $8 @ 8 bytes still to do? - stmgeia a4!, {a2, ip} - subge a3, a3, $8 - bge 1b + subs r2, r2, #8 + strcs r1, [r3], #4 @ store up to 32 bytes per loop iteration + strcs r1, [r3], #4 + subcss r2, r2, #8 + strcs r1, [r3], #4 + strcs r1, [r3], #4 + subcss r2, r2, #8 + strcs r1, [r3], #4 + strcs r1, [r3], #4 + subcss r2, r2, #8 + strcs r1, [r3], #4 + strcs r1, [r3], #4 + bcs 1b + + and r2, r2, #7 2: - movs a3, a3 @ anything left? - RETINSTR(moveq,pc,lr) @ nope - rsb a3, a3, $7 - add pc, pc, a3, lsl $2 - mov r0, r0 - strb a2, [a4], $1 - strb a2, [a4], $1 - strb a2, [a4], $1 - strb a2, [a4], $1 - strb a2, [a4], $1 - strb a2, [a4], $1 - strb a2, [a4], $1 - RETINSTR(mov,pc,lr) + subs r2, r2, #1 @ store up to 4 bytes per loop iteration + strcsb r1, [r3], #1 + subcss r2, r2, #1 + strcsb r1, [r3], #1 + subcss r2, r2, #1 + strcsb r1, [r3], #1 + subcss r2, r2, #1 + strcsb r1, [r3], #1 + bcs 2b + + DO_RET(lr) END(memset) libc_hidden_builtin_def (memset) From Philip.Blundell@pobox.com Sun Sep 14 17:44:00 2003 From: Philip.Blundell@pobox.com (Philip Blundell) Date: Sun, 14 Sep 2003 17:44:00 -0000 Subject: arm mmap improvements Message-ID: <1063561443.16945.6.camel@kc.cam.armlinux.org> This patch contains a couple of performance improvements for mmap() and mmap64() on arm. p. -------------- next part -------------- 2003-09-14 Philip Blundell * sysdeps/unix/sysv/linux/arm/mmap.S: Use sys_mmap2 if it's known to be available. * sysdeps/unix/sysv/linux/arm/mmap2.S: Optimise code a little. Index: sysdeps/unix/sysv/linux/arm/mmap.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/arm/mmap.S,v retrieving revision 1.5 diff -u -r1.5 mmap.S --- sysdeps/unix/sysv/linux/arm/mmap.S 6 Jul 2001 04:56:13 -0000 1.5 +++ sysdeps/unix/sysv/linux/arm/mmap.S 14 Sep 2003 17:18:27 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,11 +17,47 @@ 02111-1307 USA. */ #include +#include + +#define EINVAL 22 .text ENTRY (__mmap) +# ifdef __ASSUME_MMAP2_SYSCALL + /* This code is actually a couple of cycles slower than the + sys_mmap version below, so it might seem like a loss. But the + code path inside the kernel is sufficiently much shorter to + make it a net gain to use mmap2 when it's known to be + available. */ + + /* shuffle args */ + str r5, [sp, #-4]! + ldr r5, [sp, #8] + str r4, [sp, #-4]! + ldr r4, [sp, #8] + + /* convert offset to pages */ + movs ip, r5, lsl #20 + bne .Linval + mov r5, r5, lsr #12 + + /* do the syscall */ + swi SYS_ify (mmap2) + + /* restore registers */ +2: + ldr r4, [sp], #4 + ldr r5, [sp], #4 + + cmn r0, $4096 + RETINSTR(movcc, pc, lr) + b PLTJMP(syscall_error) +.Linval: + mov r0, #-EINVAL + b 2b +# else /* Because we can only get five args through the syscall interface, and mmap() takes six, we need to build a parameter block and pass its address instead. The 386 port does a similar trick. */ @@ -49,6 +85,7 @@ cmn r0, $4096 RETINSTR(movcc, pc, lr) b PLTJMP(syscall_error); +#endif PSEUDO_END (__mmap) Index: sysdeps/unix/sysv/linux/arm/mmap64.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/arm/mmap64.S,v retrieving revision 1.5 diff -u -r1.5 mmap64.S --- sysdeps/unix/sysv/linux/arm/mmap64.S 27 Mar 2003 02:45:46 -0000 1.5 +++ sysdeps/unix/sysv/linux/arm/mmap64.S 14 Sep 2003 17:18:27 -0000 @@ -27,38 +27,44 @@ .text ENTRY (__mmap64) #ifdef __NR_mmap2 - stmfd sp!, {r4, r5, lr} - ldr r5, [sp, $16] - ldr r4, [sp, $12] - movs ip, r5, lsl $20 @ check that offset is page-aligned + ldr ip, [sp, $4] @ offset low part + str r5, [sp, #-4]! + ldr r5, [sp, $12] @ offset high part + str r4, [sp, #-4]! + movs r4, ip, lsl $20 @ check that offset is page-aligned + mov ip, ip, lsr $12 + moveqs r4, r5, lsr $12 @ check for overflow bne .Linval - ldr ip, [sp, $20] - mov r5, r5, lsr $12 - orr r5, r5, ip, lsl $20 @ compose page offset - movs ip, ip, lsr $12 - bne .Linval @ check for overflow + ldr r4, [sp, $8] @ load fd + orr r5, ip, r5, lsl $20 @ compose page offset mov ip, r0 swi SYS_ify (mmap2) cmn r0, $4096 - LOADREGS(ccfd, sp!, {r4, r5, pc}) # ifdef __ASSUME_MMAP2_SYSCALL - ldmfd sp!, {r4, r5, lr} + ldr r4, [sp], #4 + ldr r5, [sp], #4 + RETINSTR(movcc, pc, lr) b PLTJMP(syscall_error) # else + ldrcc r4, [sp], #4 + ldrcc r5, [sp], #4 + RETINSTR(movcc, pc, lr) cmn r0, $ENOSYS - ldmnefd sp!, {r4, r5, lr} - bne PLTJMP(syscall_error) + bne .Lerror /* The current kernel does not support mmap2. Fall back to plain mmap if the offset is small enough. */ - ldr r5, [sp, $20] + ldr r5, [sp, $16] mov r0, ip @ first arg was clobbered teq r5, $0 - ldmeqfd sp!, {r4, r5, lr} + ldreq r4, [sp], #4 + ldreq r5, [sp], #4 beq PLTJMP(__mmap) # endif .Linval: mov r0, $-EINVAL - ldmfd sp!, {r4, r5, lr} +.Lerror: + ldr r4, [sp], #4 + ldr r5, [sp], #4 b PLTJMP(syscall_error) #else /* The kernel headers do not support mmap2. Fall back to plain From drepper@redhat.com Sun Sep 14 19:55:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 14 Sep 2003 19:55:00 -0000 Subject: arm mmap improvements In-Reply-To: <1063561443.16945.6.camel@kc.cam.armlinux.org> References: <1063561443.16945.6.camel@kc.cam.armlinux.org> Message-ID: <3F64C777.7070607@redhat.com> Philip Blundell wrote: > This patch contains a couple of performance improvements for mmap() and > mmap64() on arm. I've applied this and the memset patch. Thanks, -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Mon Sep 15 16:53:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 15 Sep 2003 16:53:00 -0000 Subject: [PATCH] Use $(uses-callbacks) in CFLAGS of sources which may call user callbacks Message-ID: <20030915145155.GO12344@sunsite.ms.mff.cuni.cz> Hi! Plus a few small other things. $(uses-callbacks) is mainly so that it can be changed easily in one place. 2003-09-15 Jakub Jelinek * argp/argp.h (argp_parse, __argp_parse): Remove __THROW. * argp/Makefile (CFLAGS-argp-help.c, CFLAGS-argp-parse.c): Add $(uses-callbacks). * dirent/Makefile (CFLAGS-scandir.c, CFLAGS-scandir64.c): Likewise. * elf/Makefile (CFLAGS-dl-iterate-phdr.c, CFLAGS-dl-iterate-phdr-static.c): Add $(uses-callbacks). * elf/dl-iteratephdr.c (cancel_handler): New function. (__dl_iterate_phdr): Add __libc_cleanup_{push,pop}. * elf/link.h (dl_iterate_phdr): Remove __THROW. * io/Makefile (CFLAGS-fts.c): Merge into one assignment. Add $(uses-callbacks). (CFLAGS-ftw.c, CFLAGS-ftw64.c): Add $(uses-callbacks). * misc/Makefile (CFLAGS-tsearch.c, CFLAGS-lsearch.c): Change $(exceptions) to $(uses-callbacks). * Makeconfig (uses-callbacks): Set to $(exceptions). * posix/Makefile (CFLAGS-glob.c, CFLAGS-glob64.c): Add $(uses-callbacks). * stdlib/Makefile (CFLAGS-bsearch.c, CFLAGS-msort.c, CFLAGS-qsort.c): Likewise. nptl/ * Makefile (CFLAGS-pthread_once.c): Add $(uses-callbacks). linuxthreads/ * Makefile (CFLAGS-mutex.c): Add $(uses-callbacks). (CFLAGS-sighandler.c): Change $(exceptions) into $(uses-callbacks). --- libc/argp/argp.h.jj 2003-09-02 03:08:53.000000000 -0400 +++ libc/argp/argp.h 2003-09-15 08:12:50.000000000 -0400 @@ -380,11 +380,11 @@ struct argp_state extern error_t argp_parse (__const struct argp *__restrict __argp, int __argc, char **__restrict __argv, unsigned __flags, int *__restrict __arg_index, - void *__restrict __input) __THROW; + void *__restrict __input); extern error_t __argp_parse (__const struct argp *__restrict __argp, int __argc, char **__restrict __argv, unsigned __flags, int *__restrict __arg_index, - void *__restrict __input) __THROW; + void *__restrict __input); /* Global variables. */ --- libc/argp/Makefile.jj 2003-09-02 03:08:53.000000000 -0400 +++ libc/argp/Makefile 2003-09-15 08:13:28.000000000 -0400 @@ -28,7 +28,8 @@ routines = $(addprefix argp-, ba fmtstre tests = argp-test tst-argp1 -CFLAGS-argp-help.c = -fexceptions +CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions +CFLAGS-argp-parse.c = $(uses-callbacks) CFLAGS-argp-fmtstream.c = -fexceptions include ../Rules --- libc/nptl/Makefile.jj 2003-09-03 07:13:51.000000000 -0400 +++ libc/nptl/Makefile 2003-09-15 08:32:04.000000000 -0400 @@ -162,7 +162,8 @@ CFLAGS-forward.c = -fexceptions CFLAGS-pthread_testcancel.c = -fexceptions CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-pthread_once.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \ + -fasynchronous-unwind-tables CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables --- libc/dirent/Makefile.jj 2002-06-22 01:48:16.000000000 -0400 +++ libc/dirent/Makefile 2003-09-15 06:56:01.000000000 -0400 @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2000, 2002 Free Software Foundation, Inc. +# Copyright (C) 1991-2000, 2002, 2003 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -30,6 +30,9 @@ distribute := dirstream.h tests := list tst-seekdir opendir-tst1 bug-readdir1 +CFLAGS-scandir.c = $(uses-callbacks) +CFLAGS-scandir64.c = $(uses-callbacks) + include ../Rules opendir-tst1-ARGS = --test-dir=${common-objpfx}dirent --- libc/elf/Makefile.jj 2003-08-14 05:05:25.000000000 -0400 +++ libc/elf/Makefile 2003-09-15 08:42:17.000000000 -0400 @@ -84,6 +84,8 @@ distribute := rtld-Rules \ CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-dl-iterate-phdr.c = $(uses-callbacks) +CFLAGS-dl-iterate-phdr-static.c = $(uses-callbacks) include ../Makeconfig --- libc/elf/dl-iteratephdr.c.jj 2003-06-16 02:59:03.000000000 -0400 +++ libc/elf/dl-iteratephdr.c 2003-09-15 08:49:15.000000000 -0400 @@ -23,6 +23,12 @@ #include #include +static void +cancel_handler (void *arg __attribute__((unused))) +{ + __rtld_lock_unlock_recursive (GL(dl_load_lock)); +} + int __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data) @@ -33,6 +39,7 @@ __dl_iterate_phdr (int (*callback) (stru /* Make sure we are alone. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); + __libc_cleanup_push (cancel_handler, 0); for (l = GL(dl_loaded); l != NULL; l = l->l_next) { @@ -46,6 +53,7 @@ __dl_iterate_phdr (int (*callback) (stru } /* Release the lock. */ + __libc_cleanup_pop (0); __rtld_lock_unlock_recursive (GL(dl_load_lock)); return ret; --- libc/elf/link.h.jj 2001-07-25 16:43:14.000000000 -0400 +++ libc/elf/link.h 2003-09-15 08:52:03.000000000 -0400 @@ -106,7 +106,7 @@ __BEGIN_DECLS extern int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), - void *data) __THROW; + void *data); __END_DECLS --- libc/io/Makefile.jj 2003-09-14 14:13:40.000000000 -0400 +++ libc/io/Makefile 2003-09-15 07:10:04.000000000 -0400 @@ -63,7 +63,6 @@ distribute := ftwtest-sh include ../Rules -CFLAGS-fts.c = -Wno-uninitialized CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c = -fexceptions @@ -71,9 +70,9 @@ CFLAGS-statfs.c = -fexceptions CFLAGS-fstatfs.c = -fexceptions CFLAGS-statvfs.c = -fexceptions CFLAGS-fstatvfs.c = -fexceptions -CFLAGS-fts.c = -fexceptions -CFLAGS-ftw.c = -fexceptions -CFLAGS-ftw64.c = -fexceptions +CFLAGS-fts.c = -Wno-uninitialized $(uses-callbacks) -fexceptions +CFLAGS-ftw.c = $(uses-callbacks) -fexceptions +CFLAGS-ftw64.c = $(uses-callbacks) -fexceptions CFLAGS-lockf.c = -fexceptions CFLAGS-posix_fallocate.c = -fexceptions CFLAGS-posix_fallocate64.c = -fexceptions --- libc/linuxthreads/Makefile.jj 2003-09-02 03:08:54.000000000 -0400 +++ libc/linuxthreads/Makefile 2003-09-15 08:27:00.000000000 -0400 @@ -184,7 +184,8 @@ CFLAGS-pthread.c += -D__NO_WEAK_PTHREAD_ CFLAGS-ptfork.c += -D__NO_WEAK_PTHREAD_ALIASES CFLAGS-cancel.c += -D__NO_WEAK_PTHREAD_ALIASES -D_RPC_THREAD_SAFE_ CFLAGS-unload.c += -DPREFIX=\"$(objpfx)\" -CFLAGS-sighandler.c += $(exceptions) +CFLAGS-mutex.c += $(uses-callbacks) +CFLAGS-sighandler.c += $(uses-callbacks) ifeq (yes,$(versioning)) -include $(common-objpfx)tls.make --- libc/misc/Makefile.jj 2003-09-14 14:13:41.000000000 -0400 +++ libc/misc/Makefile 2003-09-15 07:11:49.000000000 -0400 @@ -75,8 +75,8 @@ gpl2lgpl := error.c error.h tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch -CFLAGS-tsearch.c = $(exceptions) -CFLAGS-lsearch.c = $(exceptions) +CFLAGS-tsearch.c = $(uses-callbacks) +CFLAGS-lsearch.c = $(uses-callbacks) CFLAGS-pselect.c = -fexceptions CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables --- libc/Makeconfig.jj 2003-09-15 06:43:48.000000000 -0400 +++ libc/Makeconfig 2003-09-15 06:49:31.000000000 -0400 @@ -83,6 +83,9 @@ export sysdep_dir := $(sysdep_dir) # Get the values defined by options to `configure'. include $(common-objpfx)config.make +# What flags to give to sources which call user provided callbacks +uses-callbacks = $(exceptions) + # We have a special subdir for each binary format. # For now, only ELF is fully supported. ifeq ($(elf),yes) --- libc/posix/Makefile.jj 2003-09-14 14:13:41.000000000 -0400 +++ libc/posix/Makefile 2003-09-15 07:08:23.000000000 -0400 @@ -136,8 +136,8 @@ CFLAGS-spawn.c = -fexceptions CFLAGS-spawnp.c = -fexceptions CFLAGS-spawni.c = -fexceptions CFLAGS-pause.c = -fexceptions -CFLAGS-glob.c = -fexceptions -CFLAGS-glob64.c = -fexceptions +CFLAGS-glob.c = $(uses-callbacks) -fexceptions +CFLAGS-glob64.c = $(uses-callbacks) -fexceptions tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \ --none random --col --color --colour --- libc/stdlib/Makefile.jj 2003-09-14 14:13:41.000000000 -0400 +++ libc/stdlib/Makefile 2003-09-15 06:49:48.000000000 -0400 @@ -79,9 +79,9 @@ distribute := $(distribute) $(mpn-header generated += isomac isomac.out -CFLAGS-bsearch.c = $(exceptions) -CFLAGS-msort.c = $(exceptions) -CFLAGS-qsort.c = $(exceptions) +CFLAGS-bsearch.c = $(uses-callbacks) +CFLAGS-msort.c = $(uses-callbacks) +CFLAGS-qsort.c = $(uses-callbacks) CFLAGS-system.c = -fexceptions CFLAGS-fmtmsg.c = -fexceptions Jakub From drepper@redhat.com Tue Sep 16 05:55:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 16 Sep 2003 05:55:00 -0000 Subject: [PATCH] Use $(uses-callbacks) in CFLAGS of sources which may call user callbacks In-Reply-To: <20030915145155.GO12344@sunsite.ms.mff.cuni.cz> References: <20030915145155.GO12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F66A5A9.9070201@redhat.com> Jakub Jelinek wrote: > Plus a few small other things. > $(uses-callbacks) is mainly so that it can be changed easily in one place. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jim@meyering.net Tue Sep 16 09:09:00 2003 From: jim@meyering.net (Jim Meyering) Date: Tue, 16 Sep 2003 09:09:00 -0000 Subject: statvfs suggestion In-Reply-To: <85isobj8b5.fsf@pi.meyering.net> (Jim Meyering's message of "Tue, 02 Sep 2003 21:31:58 +0200") References: <200309021423.h82ENWrV018980@skeeve.com> <85isobj8b5.fsf@pi.meyering.net> Message-ID: <85smmx5ccp.fsf_-_@pi.meyering.net> Hi Uli, [There's no pressure at all, since the coreutils work around this problem simply by using statfs on glibc systems, but I feel I should at least report the problem. Other applications may well be affected. ] For some time, now the coreutils have been avoiding the use of glibc's statvfs because it has an undesirable side-effect in some cases. When df used statvfs, it would sometimes hang unnecessarily due to a problem with an unrelated hard mount. That was because statvfs stats a directory for each entry in /proc/mounts, in order, until it finds one with matching device number. Of course, that would make df hang if even one of the file systems listed in /proc/mounts before the desired one is hard-mounted, but not available. What do you think about changing internal_statvfs.c so that it first reads/saves all entries from /proc/mounts without stat'ing each corresponding directory? Then it can stop if any mount point matches the name of the file. This is a relatively important optimization, not just for the case mentioned above that would make df hang unnecessarily, but also to avoid the potential O(N^2) stat/mount operations that you'd currently incur when iterating with getmntent, and calling statvfs on each mount point. Here's some actual code demonstrating the problem, but not the hang: $ cat statvfs-glibc-test.c #include #include int main (int argc, char **argv) { struct statvfs fsd; exit (statvfs (argv[1], &fsd)); } Note that it will stat the 10 or so directories before the desired one, while it could have stat'ed only the selected one in this case, since the file argument, "/my", to statvfs matches the name of a mount point: $ cat /proc/mounts rootfs / rootfs rw 0 0 /dev2/root2 / ext3 rw 0 0 proc /proc proc rw 0 0 devpts /dev/pts devpts rw 0 0 /dev/hda5 /tmp ext3 rw 0 0 /dev/hda3 /_boot ext3 rw 0 0 /dev/hda2 /var ext3 rw 0 0 /dev/hda7 /u ext3 rw 0 0 tmpfs /t tmpfs rw 0 0 /dev/hdc2 /misc ext3 rw 0 0 /dev/hdc3 /nobak ext3 rw 0 0 /dev/hdc4 /my ext3 rw 0 0 /dev/hde2 /e-root ext3 rw 0 0 /dev/hde3 /e ext3 rw 0 0 /dev/hdg2 /g-root ext3 rw 0 0 /dev/hdg3 /g ext3 rw 0 0 automount(pid475) /mnt/auto autofs rw 0 0 usb /proc/bus/usb usbdevfs rw 0 0 $ strace -e stat64,open ./a.out /my ... stat64("/my", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 open("/proc/mounts", O_RDONLY) = 3 stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64("/proc", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 stat64("/dev/pts", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0 stat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=8192, ...}) = 0 stat64("/_boot", {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 stat64("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64("/u", {st_mode=S_IFDIR|S_ISGID|0775, st_size=4096, ...}) = 0 stat64("/t", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=340, ...}) = 0 stat64("/misc", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64("/nobak", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64("/my", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 Jim From sjmunroe@us.ibm.com Tue Sep 16 19:30:00 2003 From: sjmunroe@us.ibm.com (Steven Munroe) Date: Tue, 16 Sep 2003 19:30:00 -0000 Subject: finishing cancellation handling Message-ID: <3F674E99.4B59AF49@us.ibm.com> Still not having much luck with the find-cps.c tool. Still having problems with "false claims" of duplicate symbols: duplicate definition of endutxent in endutxent.os previous definition in getutxent.os Patching around this I saw "fatal error 400" until I recompiled -static and -m64 (The libraries I am scaning are all 64-bit). Only 64-bit static links seem to work. Now when I run: ../find-cps64 -e -f libc_pic.a -w ../libc23/CANCEL-FILE-WAIVE open close I see: files missing .eh_frame ../find-cps64: seed 'open' not defined What is the purpose/function of the "seeds"? In this case, "open" and ".open" do exist but are both weak symbols open.os: file format elf64-powerpc rw-rw-r-- 500/500 2512 Sep 11 11:25 2003 open.os 0000000000000000 w .opd 00000000000000a4 open 0000000000000000 w F .text 0000000000000000 .open Tried __libc_open and __GI___libc_open as well with no joy. Perhaps the tool has problems with "."ed symbols? -- Steven Munroe sjmunroe@us.ibm.com Linux on PowerPC-64 Development GLIBC for PowerPC-64 Development From drepper@redhat.com Tue Sep 16 19:47:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 16 Sep 2003 19:47:00 -0000 Subject: finishing cancellation handling In-Reply-To: <3F674E99.4B59AF49@us.ibm.com> References: <3F674E99.4B59AF49@us.ibm.com> Message-ID: <3F67687D.60803@redhat.com> Steven Munroe wrote: > Perhaps the tool has problems with "."ed symbols? I've said already a few times, I haven't used the tool on ppc nor do I ever have the intention to do so. If there are major problems they quite likely stem from problems like these .-symbols. If you want the tool to work on ppc, fix it yourself. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Tue Sep 16 20:20:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 16 Sep 2003 20:20:00 -0000 Subject: [PATCH] Move sched_[sg]etaffinity to GLIBC_2.3.3 Message-ID: <20030916181834.GP12344@sunsite.ms.mff.cuni.cz> Hi! sched_[gs]etaffinity API was changed after 2.3.2 incompatibly, but nothing used the old symbols from glibc (AFAIK schedutils use kernel syscalls directly, so did versions of "run" up to these days). Better change the symbol version, so that it is clear these symbols have nothing to do with the old sched_[sg]etaffinity. 2003-09-16 Jakub Jelinek * posix/Versions (sched_getaffinity, sched_setaffinity): Change from GLIBC_2.3.2 to GLIBC_2.3.3 symbol version. --- libc/posix/Versions.jj 2002-11-19 20:05:30.000000000 -0500 +++ libc/posix/Versions 2003-09-16 16:05:33.000000000 -0400 @@ -110,14 +110,15 @@ libc { __nanosleep; } GLIBC_2.3.2 { - sched_getaffinity; sched_setaffinity; - # Note that these symbols appear in sysdeps/unix/sysv/linux/Versions # under GLIBC_2.0; the first instance in the script is taken as the # default, so linux configurations put them in GLIBC_2.0 while other # configuration put them in GLIBC_2.3.2. getresuid; getresgid; setresuid; setresgid; } + GLIBC_2.3.3 { + sched_getaffinity; sched_setaffinity; + } GLIBC_PRIVATE { # functions which have an additional interface since they are # are cancelable. Jakub From drepper@redhat.com Tue Sep 16 21:00:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 16 Sep 2003 21:00:00 -0000 Subject: [PATCH] Move sched_[sg]etaffinity to GLIBC_2.3.3 In-Reply-To: <20030916181834.GP12344@sunsite.ms.mff.cuni.cz> References: <20030916181834.GP12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F6779B2.5090803@redhat.com> Jakub Jelinek wrote: > 2003-09-16 Jakub Jelinek > > * posix/Versions (sched_getaffinity, sched_setaffinity): Change > from GLIBC_2.3.2 to GLIBC_2.3.3 symbol version. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Tue Sep 16 23:17:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 16 Sep 2003 23:17:00 -0000 Subject: [PATCH] Fix linuxthreads race Message-ID: <20030916211558.GU12344@sunsite.ms.mff.cuni.cz> Hi! If a signal other than __pthread_sig_cancel is sent to a newly created thread before it INIT_THREAD_SELF in pthread_start_thread, it will have wrong thread_self (). The following patch should fix this (tested on i386 --without-tls --without-__thread non-FS, i686 --with-tls --without-__thread non-FS and i686 --with-tls --without-__thread FS). 2003-09-17 Jakub Jelinek * pthread.c (manager_thread): Remove static, add attribute_hidden. (thread_self_stack): Rename to... (__pthread_self_stack): ... this. Remove static. (pthread_handle_sigcancel): Adjust caller. (pthread_handle_sigrestart): Do INIT_THREAD_SELF if signal is received before INIT_THREAD_SELF in pthread_start_thread. * sighandler.c (manager_thread): Define. (CHECK_THREAD_SELF): Define. (__pthread_sighandler, __pthread_sighandler_rt): Use it. * descr.h (manager_thread): Declare. * internals.h (__pthread_self_stack): New prototype. --- libc/linuxthreads/pthread.c.jj 2003-09-02 03:08:54.000000000 -0400 +++ libc/linuxthreads/pthread.c 2003-09-16 16:29:56.000000000 -0400 @@ -55,7 +55,7 @@ extern struct __res_state _res; #ifdef USE_TLS /* We need only a few variables. */ -static pthread_descr manager_thread; +pthread_descr manager_thread attribute_hidden; #else @@ -896,7 +896,7 @@ pthread_descr __pthread_find_self(void) #else -static pthread_descr thread_self_stack(void) +pthread_descr __pthread_self_stack(void) { char *sp = CURRENT_STACK_FRAME; pthread_handle h; @@ -1024,6 +1024,22 @@ static void pthread_atexit_retcode(void static void pthread_handle_sigrestart(int sig) { pthread_descr self = thread_self(); +#if defined THREAD_SELF && defined INIT_THREAD_SELF + if (self == manager_thread) + { + /* A new thread might get a cancel signal before it is fully + initialized, so that the thread register might still point to the + manager thread. Double check that this is really the manager + thread. */ + pthread_descr real_self = __pthread_self_stack(); + if (real_self != manager_thread) + { + /* Oops, thread_self() isn't working yet.. */ + self = real_self; + INIT_THREAD_SELF(self, self->p_nr); + } + } +#endif THREAD_SETMEM(self, p_signal, sig); if (THREAD_GETMEM(self, p_signal_jmp) != NULL) siglongjmp(*THREAD_GETMEM(self, p_signal_jmp), 1); @@ -1046,7 +1062,7 @@ static void pthread_handle_sigcancel(int initialized, so that the thread register might still point to the manager thread. Double check that this is really the manager thread. */ - pthread_descr real_self = thread_self_stack(); + pthread_descr real_self = __pthread_self_stack(); if (real_self == manager_thread) { __pthread_manager_sighandler(sig); --- libc/linuxthreads/internals.h.jj 2003-09-02 03:08:54.000000000 -0400 +++ libc/linuxthreads/internals.h 2003-09-16 16:29:00.000000000 -0400 @@ -363,6 +363,7 @@ extern int __pthread_condattr_init (pthr extern int __pthread_condattr_destroy (pthread_condattr_t *attr); extern pthread_t __pthread_self (void); extern pthread_descr __pthread_thread_self (void); +extern pthread_descr __pthread_self_stack (void) attribute_hidden; extern int __pthread_equal (pthread_t thread1, pthread_t thread2); extern void __pthread_exit (void *retval); extern int __pthread_getschedparam (pthread_t thread, int *policy, --- libc/linuxthreads/descr.h.jj 2003-07-23 03:56:17.000000000 -0400 +++ libc/linuxthreads/descr.h 2003-09-16 16:26:35.000000000 -0400 @@ -217,6 +217,7 @@ extern char *__pthread_manager_thread_to /* Descriptor of the manager thread */ extern struct _pthread_descr_struct __pthread_manager_thread; +extern pthread_descr manager_thread attribute_hidden; /* Indicate whether at least one thread has a user-defined stack (if 1), or all threads have stacks supplied by LinuxThreads (if 0). */ --- libc/linuxthreads/sighandler.c.jj 2002-05-03 03:36:37.000000000 -0400 +++ libc/linuxthreads/sighandler.c 2003-09-16 16:35:48.000000000 -0400 @@ -16,6 +16,31 @@ #include "internals.h" +#if defined THREAD_SELF && defined INIT_THREAD_SELF +# ifndef USE_TLS +# define manager_thread (&__pthread_manager_thread) +# endif +# define CHECK_THREAD_SELF(self) \ +do { \ + if (self == manager_thread) \ + { \ + /* A new thread might get a cancel signal before it is fully \ + initialized, so that the thread register might still point to the \ + manager thread. Double check that this is really the manager \ + thread. */ \ + pthread_descr real_self = __pthread_self_stack(); \ + if (real_self != manager_thread) \ + { \ + /* Oops, thread_self() isn't working yet.. */ \ + self = real_self; \ + INIT_THREAD_SELF(self, self->p_nr); \ + } \ + } \ +} while (0) +#else +# define CHECK_THREAD_SELF(self) do { } while (0) +#endif + /* The wrapper around user-provided signal handlers */ void __pthread_sighandler(int signo, SIGCONTEXT ctx) @@ -23,6 +48,7 @@ void __pthread_sighandler(int signo, SIG pthread_descr self; char * in_sighandler; self = thread_self(); + CHECK_THREAD_SELF(self); /* If we're in a sigwait operation, just record the signal received and return without calling the user's handler */ if (THREAD_GETMEM(self, p_sigwaiting)) { @@ -47,6 +73,7 @@ void __pthread_sighandler_rt(int signo, pthread_descr self; char * in_sighandler; self = thread_self(); + CHECK_THREAD_SELF(self); /* If we're in a sigwait operation, just record the signal received and return without calling the user's handler */ if (THREAD_GETMEM(self, p_sigwaiting)) { Jakub From jakub@redhat.com Tue Sep 16 23:43:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 16 Sep 2003 23:43:00 -0000 Subject: [PATCH] scandir cleanups Message-ID: <20030916214158.GV12344@sunsite.ms.mff.cuni.cz> Hi! If one of the scandir* callbacks (select or cmp) either pthread_exit's, throws an exception or calls some cancellation point, dp might be unclosed and some memory might leak. 2003-09-17 Jakub Jelinek * dirent/scandir.c: Include bits/libc-lock.h. (struct scandir_cancel_struct): New type. (cancel_handler): New function. (SCANDIR): Add __libc_cleanup_{push,pop}, save state into scandir_cancel_struct. --- libc/dirent/scandir.c.jj 2003-06-11 22:03:31.000000000 -0400 +++ libc/dirent/scandir.c 2003-09-16 16:12:49.000000000 -0400 @@ -20,6 +20,7 @@ #include #include #include +#include #ifndef SCANDIR #define SCANDIR scandir @@ -27,6 +28,29 @@ #define DIRENT_TYPE struct dirent #endif +#ifndef SCANDIR_CANCEL +#define SCANDIR_CANCEL +struct scandir_cancel_struct +{ + DIR *dp; + void *v; + size_t cnt; +}; + +static void +cancel_handler (void *arg) +{ + struct scandir_cancel_struct *cp = arg; + size_t i; + void **v = cp->v; + + for (i = 0; i < cp->cnt; ++i) + free (v[i]); + free (v); + (void) __closedir (cp->dp); +} +#endif + int SCANDIR (dir, namelist, select, cmp) @@ -37,7 +61,8 @@ SCANDIR (dir, namelist, select, cmp) { DIR *dp = __opendir (dir); DIRENT_TYPE **v = NULL; - size_t vsize = 0, i; + size_t vsize = 0; + struct scandir_cancel_struct c; DIRENT_TYPE *d; int save; @@ -47,7 +72,11 @@ SCANDIR (dir, namelist, select, cmp) save = errno; __set_errno (0); - i = 0; + c.dp = dp; + c.v = NULL; + c.cnt = 0; + __libc_cleanup_push (cancel_handler, &c); + while ((d = READDIR (dp)) != NULL) { int use_it = select == NULL; @@ -69,7 +98,7 @@ SCANDIR (dir, namelist, select, cmp) /* Ignore errors from select or readdir */ __set_errno (0); - if (__builtin_expect (i == vsize, 0)) + if (__builtin_expect (c.cnt == vsize, 0)) { DIRENT_TYPE **new; if (vsize == 0) @@ -80,6 +109,7 @@ SCANDIR (dir, namelist, select, cmp) if (new == NULL) break; v = new; + c.v = (void *) v; } dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d; @@ -87,7 +117,7 @@ SCANDIR (dir, namelist, select, cmp) if (vnew == NULL) break; - v[i++] = (DIRENT_TYPE *) memcpy (vnew, d, dsize); + v[c.cnt++] = (DIRENT_TYPE *) memcpy (vnew, d, dsize); } } @@ -95,23 +125,24 @@ SCANDIR (dir, namelist, select, cmp) { save = errno; - while (i > 0) - free (v[--i]); + while (c.cnt > 0) + free (v[--c.cnt]); free (v); - - i = -1; + c.cnt = -1; } else { /* Sort the list if we have a comparison function to sort with. */ if (cmp != NULL) - qsort (v, i, sizeof (*v), cmp); + qsort (v, c.cnt, sizeof (*v), cmp); *namelist = v; } + __libc_cleanup_pop (0); + (void) __closedir (dp); __set_errno (save); - return i; + return c.cnt; } Jakub From drepper@redhat.com Wed Sep 17 00:51:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 00:51:00 -0000 Subject: statvfs suggestion In-Reply-To: <85smmx5ccp.fsf_-_@pi.meyering.net> References: <200309021423.h82ENWrV018980@skeeve.com> <85isobj8b5.fsf@pi.meyering.net> <85smmx5ccp.fsf_-_@pi.meyering.net> Message-ID: <3F67AFD9.5010007@redhat.com> Jim Meyering wrote: > What do you think about changing internal_statvfs.c so that it first > reads/saves all entries from /proc/mounts without stat'ing each > corresponding directory? Then it can stop if any mount point matches > the name of the file. This really is no solution. The name passed to statvfs need not be the actual mount point. And what about fstatvfs where we don't have a name? I added some code which cuts down on the number of stats by comparing another value we know must match: the filesystem name. While doing this, though, I found that adding additional tests for the name comparison isn't any more work so I added this as well. It's no solution, but it might help in one situation or another. The result is in CVS. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From drepper@redhat.com Wed Sep 17 01:19:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 01:19:00 -0000 Subject: [PATCH] scandir cleanups In-Reply-To: <20030916214158.GV12344@sunsite.ms.mff.cuni.cz> References: <20030916214158.GV12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F67B66B.90502@redhat.com> Jakub Jelinek wrote: > 2003-09-17 Jakub Jelinek > > * dirent/scandir.c: Include bits/libc-lock.h. > (struct scandir_cancel_struct): New type. > (cancel_handler): New function. > (SCANDIR): Add __libc_cleanup_{push,pop}, save state into > scandir_cancel_struct. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From schwidefsky@de.ibm.com Wed Sep 17 09:36:00 2003 From: schwidefsky@de.ibm.com (Martin Schwidefsky) Date: Wed, 17 Sep 2003 09:36:00 -0000 Subject: [PATCH] Change s390 ssize_t back to long int Message-ID: Hi Ulrich, > I've applied the patch now. It should be clear that this is a break of > the ABI from early glibc versions. Yes, Jakub discussed this with me and we came to the conclusion that this is acceptable. We only break if someone uses gcc 3.x with the old ssize_t type of int to compile c++ code and mixes the binaries with code compiled with gcc 3.x with the new ssize_t of long. The if here is that gcc 3.x should only be used with a new libc which has a ssize_t of long. blue skies, Martin From jim@meyering.net Wed Sep 17 12:00:00 2003 From: jim@meyering.net (Jim Meyering) Date: Wed, 17 Sep 2003 12:00:00 -0000 Subject: statvfs suggestion In-Reply-To: <3F67AFD9.5010007@redhat.com> (Ulrich Drepper's message of "Tue, 16 Sep 2003 17:50:33 -0700") References: <200309021423.h82ENWrV018980@skeeve.com> <85isobj8b5.fsf@pi.meyering.net> <85smmx5ccp.fsf_-_@pi.meyering.net> <3F67AFD9.5010007@redhat.com> Message-ID: <851xuf1v6c.fsf@pi.meyering.net> Ulrich Drepper wrote: > Jim Meyering wrote: >> What do you think about changing internal_statvfs.c so that it first >> reads/saves all entries from /proc/mounts without stat'ing each >> corresponding directory? Then it can stop if any mount point matches >> the name of the file. > > This really is no solution. The name passed to statvfs need not be the > actual mount point. And what about fstatvfs where we don't have a name? > > I added some code which cuts down on the number of stats by comparing > another value we know must match: the filesystem name. > > While doing this, though, I found that adding additional tests for the > name comparison isn't any more work so I added this as well. It's no > solution, but it might help in one situation or another. The result is > in CVS. Thanks for doing that. IMHO any change that converts an O(N^2) process into an O(N) one is more than a partial solution :-) From drepper@redhat.com Wed Sep 17 15:09:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 15:09:00 -0000 Subject: statvfs suggestion In-Reply-To: <200309171137.h8HBbHW6024549@skeeve.com> References: <200309171137.h8HBbHW6024549@skeeve.com> Message-ID: <3F6878D2.4080503@redhat.com> Aharon Robbins wrote: > Isn't the real solution to get statvfs into the kernel? statfs already > does most of the work; the problem is geting the mount options. Well, feel free to try it. Welcome to the world of kernel politics. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From Philip.Blundell@pobox.com Wed Sep 17 16:37:00 2003 From: Philip.Blundell@pobox.com (Philip Blundell) Date: Wed, 17 Sep 2003 16:37:00 -0000 Subject: fix linuxthreads/tst-popen2 on arm Message-ID: <1063816642.16948.84.camel@kc.cam.armlinux.org> Here's a patch for the arm vfork code in linuxthreads. p. -------------- next part -------------- 2003-09-17 Philip Blundell * sysdeps/unix/sysv/linux/arm/vfork.S: Branch to fork if libpthread is loaded. Elide backwards compatibility code when not required. Index: linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S,v retrieving revision 1.2 diff -u -p -r1.2 vfork.S --- linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S 15 Jan 2003 01:06:06 -0000 1.2 +++ linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S 17 Sep 2003 16:34:32 -0000 @@ -20,36 +20,59 @@ #include #define _ERRNO_H 1 #include +#include -/* Clone the calling process, but without copying the whole address -pace. +/* Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is - replaced by a call to `execve'. Return -1 for errors, 0 to the new -rocess, + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ PSEUDO_PROLOGUE ENTRY (__vfork) - SINGLE_THREAD_P - bne HIDDEN_JUMPTARGET (__fork) #ifdef __NR_vfork + +#ifdef SHARED + ldr ip, 1f + ldr r0, 2f +3: add ip, pc, ip + ldr r0, [ip, r0] +#else + ldr r0, 1f +#endif + movs r0, r0 + bne HIDDEN_JUMPTARGET (__fork) + swi __NR_vfork cmn a1, #4096 RETINSTR(movcc, pc, lr) +#ifndef __ASSUME_VFORK_SYSCALL /* Check if vfork syscall is known at all. */ - ldr a2, =-ENOSYS - teq a1, a2 + cmn a1, #ENOSYS bne PLTJMP(C_SYMBOL_NAME(__syscall_error)) #endif +#endif + +#ifndef __ASSUME_VFORK_SYSCALL /* If we don't have vfork, fork is close enough. */ swi __NR_fork cmn a1, #4096 RETINSTR(movcc, pc, lr) +#elif !defined __NR_vfork +# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined" +#endif b PLTJMP(C_SYMBOL_NAME(__syscall_error)) + +#ifdef SHARED +1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8 +2: .word __libc_pthread_functions(GOTOFF) +#else + .weak pthread_create +1: .word pthread_create +#endif PSEUDO_END (__vfork) libc_hidden_def (__vfork) From jakub@redhat.com Wed Sep 17 16:58:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 17 Sep 2003 16:58:00 -0000 Subject: [PATCH] Some more alignment tests, memstream cleanup Message-ID: <20030917145614.GW12344@sunsite.ms.mff.cuni.cz> Hi! Two separate things actually: 1) new alignment tests 2) after latest change memstream.c has static unused _IO_wmem_jumps (and removing that shows two more static unused functions) 2003-09-17 Jakub Jelinek * elf/Makefile (distribute): Add tst-alignmod.c. (tests): Add tst-align. (modules-names): Add tst-alignmod. (CFLAGS-tst-align.c, CFLAGS-tst-alignmod.c): Add $(stack-align-test-flags). ($(objpfx)tst-align): Depend on libdl. ($(objpfx)tst-align.out): Depend on tst-alignmod.so. * elf/tst-align.c: New test. * elf/tst-alignmod.c: New test. * misc/Makefile (CFLAGS-tst-tsearch.c): Add $(stack-align-test-flags). * misc/tst-tsearch.c: Include tst-stack-align.h. (stack_align_check): New array. (cmp_fn, walk_action): Use TEST_STACK_ALIGN (). (main): Report error if stack was not enough aligned in cmp_fn or walk_action. * stdlib/Makefile (CFLAGS-tst-qsort.c): Add $(stack-align-test-flags). * stdlib/tst-qsort.c: Include tst-stack-align.h. (align_check): New var. (compare): Use TEST_STACK_ALIGN () macro. (main): Report error if stack was not enough aligned in compare. * sysdeps/i386/i686/Makefile (stack-align-test-flags): Remove unneeded -mpreferred-stack-boundary=4. * sysdeps/x86_64/tst-stack-align.h: New file. * libio/memstream.c (_IO_wmem_jumps): Remove unused structure. (_IO_wmem_sync, _IO_wmem_finish): Remove unused functions. --- libc/elf/Makefile.jj 2003-09-17 07:42:30.000000000 -0400 +++ libc/elf/Makefile 2003-09-17 12:34:18.000000000 -0400 @@ -71,7 +71,7 @@ distribute := rtld-Rules \ tst-tlsmod1.c tst-tlsmod2.c tst-tlsmod3.c tst-tlsmod4.c \ tst-tlsmod5.c tst-tlsmod6.c tst-tlsmod7.c tst-tlsmod8.c \ tst-tlsmod9.c tst-tlsmod10.c tst-tlsmod11.c \ - tst-tlsmod12.c tst-tls10.h \ + tst-tlsmod12.c tst-tls10.h tst-alignmod.c \ circlemod1.c circlemod1a.c circlemod2.c circlemod2a.c \ circlemod3.c circlemod3a.c nodlopenmod2.c \ tls-macros.h \ @@ -150,7 +150,7 @@ tests += loadtest restest1 preloadtest l neededtest3 neededtest4 unload2 lateglobal initfirst global \ restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \ circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \ - tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 + tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-align # reldep9 test-srcs = tst-pathopt tests-vis-yes = vismain @@ -177,7 +177,8 @@ modules-names = testobj1 testobj2 testob circlemod1 circlemod1a circlemod2 circlemod2a \ circlemod3 circlemod3a \ reldep8mod1 reldep8mod2 reldep8mod3 \ - reldep9mod1 reldep9mod2 reldep9mod3 + reldep9mod1 reldep9mod2 reldep9mod3 \ + tst-alignmod ifeq (yes,$(have-initfini-array)) modules-names += tst-array2dep endif @@ -648,6 +649,11 @@ $(objpfx)tst-tls13.out: $(objpfx)tst-tls $(objpfx)tst-tls14: $(objpfx)tst-tlsmod14a.so $(libdl) $(objpfx)tst-tls14.out:$(objpfx)tst-tlsmod14b.so +CFLAGS-tst-align.c = $(stack-align-test-flags) +CFLAGS-tst-alignmod.c = $(stack-align-test-flags) +$(objpfx)tst-align: $(libdl) +$(objpfx)tst-align.out: $(objpfx)tst-alignmod.so + ifdef libdl $(objpfx)tst-tls9-static: $(common-objpfx)dlfcn/libdl.a $(objpfx)tst-tls9-static.out: $(objpfx)tst-tlsmod5.so $(objpfx)tst-tlsmod6.so --- libc/elf/tst-align.c.jj 2003-09-17 12:03:05.000000000 -0400 +++ libc/elf/tst-align.c 2003-09-17 12:07:05.000000000 -0400 @@ -0,0 +1,54 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +static int +do_test (void) +{ + static const char modname[] = "tst-alignmod.so"; + int result = 0; + void (*fp) (int *); + void *h; + + h = dlopen (modname, RTLD_LAZY); + if (h == NULL) + { + printf ("cannot open '%s': %s\n", modname, dlerror ()); + exit (1); + } + + fp = dlsym (h, "in_dso"); + if (fp == NULL) + { + printf ("cannot get symbol 'in_dso': %s\n", dlerror ()); + exit (1); + } + + fp (&result); + + dlclose (h); + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" --- libc/elf/tst-alignmod.c.jj 2003-09-17 12:05:52.000000000 -0400 +++ libc/elf/tst-alignmod.c 2003-09-17 12:16:50.000000000 -0400 @@ -0,0 +1,53 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +static int res, *resp; + +static void __attribute__((constructor)) +con (void) +{ + res = TEST_STACK_ALIGN () ? -1 : 1; +} + +void +in_dso (int *result) +{ + if (!res) + { + puts ("constructor has not been run"); + *result = 1; + } + else if (res != 1) + { + puts ("constructor has been run without sufficient alignment"); + *result = 1; + } + + resp = result; +} + +static void __attribute__((destructor)) +des (void) +{ + if (TEST_STACK_ALIGN ()) + *resp = 1; +} --- libc/libio/memstream.c.jj 2003-09-15 06:37:15.000000000 -0400 +++ libc/libio/memstream.c 2003-09-17 11:12:20.000000000 -0400 @@ -32,8 +32,6 @@ struct _IO_FILE_memstream static int _IO_mem_sync __P ((_IO_FILE* fp)); static void _IO_mem_finish __P ((_IO_FILE* fp, int)); -static int _IO_wmem_sync __P ((_IO_FILE* fp)); -static void _IO_wmem_finish __P ((_IO_FILE* fp, int)); static struct _IO_jump_t _IO_mem_jumps = @@ -60,30 +58,6 @@ static struct _IO_jump_t _IO_mem_jumps = JUMP_INIT(imbue, _IO_default_imbue) }; -static struct _IO_jump_t _IO_wmem_jumps = -{ - JUMP_INIT_DUMMY, - JUMP_INIT (finish, (_IO_finish_t) _IO_wmem_finish), - JUMP_INIT (overflow, (_IO_overflow_t) _IO_wstr_overflow), - JUMP_INIT (underflow, (_IO_underflow_t) _IO_wstr_underflow), - JUMP_INIT (uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)), - JUMP_INIT (pbackfail, (_IO_pbackfail_t) _IO_wstr_pbackfail), - JUMP_INIT (xsputn, (_IO_xsputn_t) INTUSE(_IO_wdefault_xsputn)), - JUMP_INIT (xsgetn, (_IO_xsgetn_t) INTUSE(_IO_wdefault_xsgetn)), - JUMP_INIT (seekoff, _IO_wstr_seekoff), - JUMP_INIT (seekpos, _IO_default_seekpos), - JUMP_INIT (setbuf, _IO_default_setbuf), - JUMP_INIT (sync, (_IO_sync_t) _IO_wmem_sync), - JUMP_INIT (doallocate, INTUSE(_IO_wdefault_doallocate)), - JUMP_INIT (read, _IO_default_read), - JUMP_INIT (write, _IO_default_write), - JUMP_INIT (seek, _IO_default_seek), - JUMP_INIT (close, _IO_default_close), - JUMP_INIT (stat, _IO_default_stat), - JUMP_INIT(showmanyc, _IO_default_showmanyc), - JUMP_INIT(imbue, _IO_default_imbue) -}; - /* Open a stream that writes into a malloc'd buffer that is expanded as necessary. *BUFLOC and *SIZELOC are updated with the buffer's location and the number of characters written on fflush or fclose. */ @@ -172,55 +146,3 @@ _IO_mem_finish (fp, dummy) INTUSE(_IO_default_finish) (fp, 0); } - - -static int -_IO_wmem_sync (fp) - _IO_FILE* fp; -{ - struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp; - int res; - - res = _IO_default_sync (fp); - if (res < 0) - return res; - - if (fp->_wide_data->_IO_write_ptr == fp->_wide_data->_IO_write_end) - { - _IO_wstr_overflow (fp, L'\0'); - --fp->_wide_data->_IO_write_ptr; - } - else - *fp->_wide_data->_IO_write_ptr = '\0'; - - *mp->bufloc = (char *) fp->_wide_data->_IO_write_base; - *mp->sizeloc = (fp->_wide_data->_IO_write_ptr - - fp->_wide_data->_IO_write_base); - - return 0; -} - - -static void -_IO_wmem_finish (fp, dummy) - _IO_FILE* fp; - int dummy; -{ - struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp; - - *mp->bufloc = (char *) realloc (fp->_wide_data->_IO_write_base, - (fp->_wide_data->_IO_write_ptr - - fp->_wide_data->_IO_write_base + 1) - * sizeof (wchar_t)); - if (*mp->bufloc != NULL) - { - ((wchar_t *) (*mp->bufloc))[fp->_wide_data->_IO_write_ptr - - fp->_wide_data->_IO_write_base] = '\0'; - *mp->sizeloc = (fp->_wide_data->_IO_write_ptr - - fp->_wide_data->_IO_write_base); - } - - fp->_wide_data->_IO_buf_base = NULL; - - INTUSE(_IO_default_finish) (fp, 0); -} --- libc/misc/tst-tsearch.c.jj 2001-07-06 00:55:36.000000000 -0400 +++ libc/misc/tst-tsearch.c 2003-09-17 12:22:55.000000000 -0400 @@ -1,5 +1,5 @@ /* Test program for tsearch et al. - Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1997, 2000, 2001, 2003 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 @@ -25,6 +25,7 @@ #include #include #include +#include #define SEED 0 #define BALANCED 1 @@ -72,10 +73,14 @@ static int depths[SIZE]; /* Maximum depth during a tree walk. */ static int max_depth; +static int stack_align_check[2]; + /* Compare two keys. */ static int cmp_fn (const void *a, const void *b) { + if (!stack_align_check[0]) + stack_align_check[0] = TEST_STACK_ALIGN () ? -1 : 1; return *(const int *) a - *(const int *) b; } @@ -103,6 +108,9 @@ walk_action (const void *nodep, const VI { int key = **(int **) nodep; + if (!stack_align_check[1]) + stack_align_check[1] = TEST_STACK_ALIGN () ? -1 : 1; + if (depth > max_depth) max_depth = depth; if (which == leaf || which == preorder) @@ -329,5 +337,17 @@ main (int argc, char **argv) total_error |= error; } + for (i = 0; i < 2; ++i) + if (stack_align_check[i] == 0) + { + printf ("stack alignment check %d not run\n", i); + total_error |= 1; + } + else if (stack_align_check[i] != 1) + { + printf ("stack insufficiently aligned in check %d\n", i); + total_error |= 1; + } + return total_error; } --- libc/misc/Makefile.jj 2003-09-17 07:42:31.000000000 -0400 +++ libc/misc/Makefile 2003-09-17 12:23:52.000000000 -0400 @@ -89,6 +89,7 @@ CFLAGS-mkstemp64.c = -fexceptions CFLAGS-getsysstats.c = -fexceptions CFLAGS-getusershell.c = -fexceptions CFLAGS-err.c = -fexceptions +CFLAGS-tst-tsearch.c = $(stack-align-test-flags) include ../Rules --- libc/stdlib/Makefile.jj 2003-09-17 07:42:32.000000000 -0400 +++ libc/stdlib/Makefile 2003-09-17 10:57:18.000000000 -0400 @@ -97,6 +97,7 @@ CFLAGS-atexit.c = -DHAVE_DOT_HIDDEN endif CFLAGS-tst-bsearch.c = $(stack-align-test-flags) +CFLAGS-tst-qsort.c = $(stack-align-test-flags) include ../Rules --- libc/stdlib/tst-qsort.c.jj 2002-01-29 04:05:09.000000000 -0500 +++ libc/stdlib/tst-qsort.c 2003-09-17 10:59:48.000000000 -0400 @@ -1,17 +1,24 @@ /* Test case by Paul Eggert */ #include #include +#include struct big { char c[4 * 1024]; }; struct big *array; struct big *array_end; +static int align_check; + int compare (void const *a1, void const *b1) { struct big const *a = a1; struct big const *b = b1; + + if (!align_check) + align_check = TEST_STACK_ALIGN () ? -1 : 1; + if (! (array <= a && a < array_end && array <= b && b < array_end)) { @@ -38,5 +45,11 @@ main (int argc, char **argv) qsort (array, array_members, sizeof *array, compare); + if (align_check == -1) + { + puts ("stack not sufficiently aligned"); + exit (EXIT_FAILURE); + } + return 0; } --- libc/sysdeps/i386/i686/Makefile.jj 2003-09-17 05:12:39.000000000 -0400 +++ libc/sysdeps/i386/i686/Makefile 2003-09-17 08:59:02.000000000 -0400 @@ -4,4 +4,4 @@ static-only-routines += hp-timing endif # So that we can test __m128's alignment -stack-align-test-flags += -msse -mpreferred-stack-boundary=4 +stack-align-test-flags += -msse --- libc/sysdeps/x86_64/tst-stack-align.h.jj 2003-09-17 08:58:42.000000000 -0400 +++ libc/sysdeps/x86_64/tst-stack-align.h 2003-09-17 08:58:11.000000000 -0400 @@ -0,0 +1,47 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#define TEST_STACK_ALIGN() \ + ({ \ + /* AMD64 ABI mandates 16byte aligned stack. \ + Unfortunately, current GCC doesn't support __int128 or __float128 \ + types, so use aligned attribute instead. */ \ + struct _S \ + { \ + int _i __attribute__((aligned (16))); \ + int _pad[3]; \ + } _s = { ._i = 18 }; \ + double _d = 12.0; \ + long double _ld = 15.0; \ + int _ret = 0; \ + printf ("__int128: %d %p %zu\n", _s._i, &_s, __alignof (_s)); \ + if ((((uintptr_t) &_s) & (__alignof (_s) - 1)) != 0) \ + _ret = 1; \ + \ + printf ("double: %g %p %zu\n", _d, &_d, __alignof (double)); \ + if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0) \ + _ret = 1; \ + \ + printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double)); \ + if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0) \ + _ret = 1; \ + _ret; \ + }) Jakub From pb@nexus.co.uk Wed Sep 17 17:07:00 2003 From: pb@nexus.co.uk (Philip Blundell) Date: Wed, 17 Sep 2003 17:07:00 -0000 Subject: miscellaneous arm patches Message-ID: <1063818462.20301.87.camel@kc.cam.armlinux.org> Here's a small collection of arm tweaks. p. -------------- next part -------------- 2003-09-17 Philip Blundell * sysdeps/arm/dl-machine.h (CALL_ROUTINE): Deleted. (BX): Define. (ELF_MACHINE_RUNTIME_TRAMPOLINE): Optimise a little. * sysdeps/arm/sysdep.h (DO_RET): New. * sysdeps/unix/sysv/linux/arm/vfork.S: Add #error if __NR_vfork required but not defined. Improve test of error code. Index: sysdeps/arm/dl-machine.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/arm/dl-machine.h,v retrieving revision 1.43 diff -u -r1.43 dl-machine.h --- sysdeps/arm/dl-machine.h 31 Jul 2003 06:33:51 -0000 1.43 +++ sysdeps/arm/dl-machine.h 17 Sep 2003 17:01:52 -0000 @@ -123,22 +123,10 @@ return lazy; } -/* This code is used in dl-runtime.c to call the `fixup' function - and then redirect to the address it returns. */ - // macro for handling PIC situation.... -#ifdef PIC -#define CALL_ROUTINE(x) "\ - ldr sl,0f\n\ - add sl, pc, sl\n\ -1: ldr r2, 2f\n\ - mov lr, pc\n\ - add pc, sl, r2\n\ - b 3f\n\ -0: .word _GLOBAL_OFFSET_TABLE_ - 1b - 4\n\ -2: .word " #x "(GOTOFF)\n\ -3: " +#if defined(__THUMB_INTERWORK__) +#define BX(x) "bx\t" #x #else -#define CALL_ROUTINE(x) " bl " #x +#define BX(x) "mov\tpc, " #x #endif #ifndef PROF @@ -153,8 +141,11 @@ @ ip contains &GOT[n+3] (pointer to function)\n\ @ lr points to &GOT[2]\n\ \n\ - @ save almost everything; lr is already on the stack\n\ - stmdb sp!,{r0-r3,sl,fp}\n\ + @ stack arguments\n\ + stmdb sp!,{r0-r3}\n\ +\n\ + @ get pointer to linker struct\n\ + ldr r0, [lr, #-4]\n\ \n\ @ prepare to call fixup()\n\ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\ @@ -162,20 +153,17 @@ sub r1, r1, #4\n\ add r1, r1, r1\n\ \n\ - @ get pointer to linker struct\n\ - ldr r0, [lr, #-4]\n\ -\n\ @ call fixup routine\n\ - " CALL_ROUTINE(fixup) "\n\ + bl fixup\n\ \n\ @ save the return\n\ mov ip, r0\n\ \n\ - @ restore the stack\n\ - ldmia sp!,{r0-r3,sl,fp,lr}\n\ + @ get arguments and return address back\n\ + ldmia sp!, {r0-r3,lr}\n\ \n\ @ jump to the newly found address\n\ - mov pc, ip\n\ + " BX(ip) "\n\ \n\ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ \n\ @@ -183,8 +171,11 @@ .type _dl_runtime_profile, #function\n\ .align 2\n\ _dl_runtime_profile:\n\ - @ save almost everything; lr is already on the stack\n\ - stmdb sp!,{r0-r3,sl,fp}\n\ + @ stack arguments\n\ + stmdb sp!, {r0-r3}\n\ +\n\ + @ get pointer to linker struct\n\ + ldr r0, [lr, #-4]\n\ \n\ @ prepare to call fixup()\n\ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\ @@ -192,20 +183,17 @@ sub r1, r1, #4\n\ add r1, r1, r1\n\ \n\ - @ get pointer to linker struct\n\ - ldr r0, [lr, #-4]\n\ -\n\ @ call profiling fixup routine\n\ - " CALL_ROUTINE(profile_fixup) "\n\ + bl profile_fixup\n\ \n\ @ save the return\n\ mov ip, r0\n\ \n\ - @ restore the stack\n\ - ldmia sp!,{r0-r3,sl,fp,lr}\n\ + @ get arguments and return address back\n\ + ldmia sp!, {r0-r3,lr}\n\ \n\ @ jump to the newly found address\n\ - mov pc, ip\n\ + " BX(ip) "\n\ \n\ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ .previous\n\ @@ -225,8 +213,11 @@ @ ip contains &GOT[n+3] (pointer to function)\n\ @ lr points to &GOT[2]\n\ \n\ - @ save almost everything; return add is already on the stack\n\ - stmdb sp!,{r0-r3,sl,fp}\n\ + @ stack arguments\n\ + stmdb sp!, {r0-r3}\n\ +\n\ + @ get pointer to linker struct\n\ + ldr r0, [lr, #-4]\n\ \n\ @ prepare to call fixup()\n\ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\ @@ -234,20 +225,17 @@ sub r1, r1, #4\n\ add r1, r1, r1\n\ \n\ - @ get pointer to linker struct\n\ - ldr r0, [lr, #-4]\n\ -\n\ @ call profiling fixup routine\n\ - " CALL_ROUTINE(fixup) "\n\ + bl fixup\n\ \n\ @ save the return\n\ mov ip, r0\n\ \n\ - @ restore the stack\n\ - ldmia sp!,{r0-r3,sl,fp,lr}\n\ + @ get arguments and return address back\n\ + ldmia sp!, {r0-r3,lr}\n\ \n\ @ jump to the newly found address\n\ - mov pc, ip\n\ + " BX(ip) "\n\ \n\ .size _dl_runtime_profile, .-_dl_runtime_profile\n\ .previous\n\ Index: sysdeps/unix/sysv/linux/arm/vfork.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/arm/vfork.S,v retrieving revision 1.7 diff -u -r1.7 vfork.S --- sysdeps/unix/sysv/linux/arm/vfork.S 27 Mar 2003 02:45:46 -0000 1.7 +++ sysdeps/unix/sysv/linux/arm/vfork.S 17 Sep 2003 17:01:52 -0000 @@ -38,8 +38,7 @@ b PLTJMP(C_SYMBOL_NAME(__syscall_error)) # else /* Check if vfork syscall is known at all. */ - ldr a2, =-ENOSYS - teq a1, a2 + cmn a2, #ENOSYS bne PLTJMP(C_SYMBOL_NAME(__syscall_error)) # endif #endif @@ -50,6 +49,8 @@ cmn a1, #4096 RETINSTR(movcc, pc, lr) b PLTJMP(C_SYMBOL_NAME(__syscall_error)) +#elif !defined __NR_vfork +# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined" #endif PSEUDO_END (__vfork) Index: sysdeps/arm/sysdep.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/arm/sysdep.h,v retrieving revision 1.9 diff -u -r1.9 sysdep.h --- sysdeps/arm/sysdep.h 21 Mar 2003 20:51:59 -0000 1.9 +++ sysdeps/arm/sysdep.h 17 Sep 2003 17:05:26 -0000 @@ -52,11 +52,20 @@ ldm##cond base,reglist #define RETINSTR(instr, regs...)\ instr regs +#ifdef __THUMB_INTERWORK__ +#define DO_RET(_reg) \ + bx _reg +#else +#define DO_RET(_reg) \ + mov pc, _reg +#endif #else /* APCS-26 */ #define LOADREGS(cond, base, reglist...)\ ldm##cond base,reglist^ #define RETINSTR(instr, regs...)\ instr##s regs +#define DO_RET(_reg) \ + movs pc, _reg #endif /* Define an entry point visible from C. */ From drepper@redhat.com Wed Sep 17 18:08:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 18:08:00 -0000 Subject: fix linuxthreads/tst-popen2 on arm In-Reply-To: <1063816642.16948.84.camel@kc.cam.armlinux.org> References: <1063816642.16948.84.camel@kc.cam.armlinux.org> Message-ID: <3F68A2B2.3030706@redhat.com> Philip Blundell wrote: > Here's a patch for the arm vfork code in linuxthreads. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From drepper@redhat.com Wed Sep 17 18:10:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 18:10:00 -0000 Subject: miscellaneous arm patches In-Reply-To: <1063818462.20301.87.camel@kc.cam.armlinux.org> References: <1063818462.20301.87.camel@kc.cam.armlinux.org> Message-ID: <3F68A34D.5060703@redhat.com> Philip Blundell wrote: > Here's a small collection of arm tweaks. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From drepper@redhat.com Wed Sep 17 18:16:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Sep 2003 18:16:00 -0000 Subject: [PATCH] Some more alignment tests, memstream cleanup In-Reply-To: <20030917145614.GW12344@sunsite.ms.mff.cuni.cz> References: <20030917145614.GW12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F68A4CE.6030008@redhat.com> Jakub Jelinek wrote: > Two separate things actually: > 1) new alignment tests > 2) after latest change memstream.c has static unused _IO_wmem_jumps > (and removing that shows two more static unused functions) Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Thu Sep 18 18:48:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 18 Sep 2003 18:48:00 -0000 Subject: [PATCH] Fix open_memstream/syslog, pthread_getattr_np test for linuxthreads Message-ID: <20030918164622.GZ12344@sunsite.ms.mff.cuni.cz> Hi! Some small changes: 1) With _IO_old_init, fp->_mode will be unitialized memory and thus if we're unlucky e.g. syslog segfaults 2) Port of the NPTL changes (pthread_getattr_np test and comment change) to linuxthreads 2003-09-18 Jakub Jelinek * libio/memstream.c (open_memstream): Use _IO_init instead of _IO_old_init. nptl/ * tst-attr3.c (tf, do_test): Print stack start/end/size and guardsize for each thread. linuxthreads/ * sysdeps/pthread/pthread.h (pthread_getattr_np): Clarify usage. * tst-attr1.c: New test. * Makefile (tests): Add tst-attr1. --- libc/libio/memstream.c.jj 2003-09-17 11:12:20.000000000 -0400 +++ libc/libio/memstream.c 2003-09-18 14:20:01.000000000 -0400 @@ -86,7 +86,7 @@ open_memstream (bufloc, sizeloc) buf = malloc (_IO_BUFSIZ); if (buf == NULL) return NULL; - _IO_old_init (&new_f->fp._sf._sbf._f, 0); + _IO_init (&new_f->fp._sf._sbf._f, 0); _IO_JUMPS ((struct _IO_FILE_plus *) &new_f->fp._sf._sbf) = &_IO_mem_jumps; _IO_str_init_static_internal (&new_f->fp._sf, buf, _IO_BUFSIZ, buf); new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF; --- libc/nptl/tst-attr3.c.jj Wed Sep 17 14:22:57 2003 +++ libc/nptl/tst-attr3.c Thu Sep 18 14:36:46 2003 @@ -92,6 +92,9 @@ tf (void *arg) error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack"); result = tf; } + else + printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize, + stacksize); size_t guardsize1, guardsize2; err = pthread_attr_getguardsize (&a, &guardsize1); @@ -114,6 +117,8 @@ tf (void *arg) guardsize1, guardsize2); result = tf; } + else + printf ("thread guardsize %zd\n", guardsize1); } int scope1, scope2; @@ -262,6 +267,9 @@ do_test (void) error (0, 0, "pthread_attr_getstack returned range does not cover main's stack"); result = 1; } + else + printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr, + stackaddr + stacksize, stacksize); size_t guardsize; err = pthread_attr_getguardsize (&a, &guardsize); --- libc/linuxthreads/sysdeps/pthread/pthread.h.jj 2003-08-29 06:30:14.000000000 -0400 +++ libc/linuxthreads/sysdeps/pthread/pthread.h 2003-09-18 14:40:39.000000000 -0400 @@ -289,7 +289,9 @@ extern int pthread_attr_getstacksize (__ __THROW; #ifdef __USE_GNU -/* Get thread attributes corresponding to the already running thread TH. */ +/* Initialize thread attribute *ATTR with attributes corresponding to the + already running thread TH. It shall be called on unitialized ATTR + and destroyed with pthread_attr_destroy when no longer needed. */ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW; #endif --- libc/linuxthreads/tst-attr1.c.jj 2003-09-18 14:38:16.000000000 -0400 +++ libc/linuxthreads/tst-attr1.c 2003-09-18 14:42:09.000000000 -0400 @@ -0,0 +1,358 @@ +/* pthread_getattr_np test. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +static void * +tf (void *arg) +{ + pthread_attr_t a, *ap, a2; + int err; + void *result = NULL; + + if (arg == NULL) + { + ap = &a2; + err = pthread_attr_init (ap); + if (err) + { + error (0, err, "pthread_attr_init failed"); + return tf; + } + } + else + ap = (pthread_attr_t *) arg; + + err = pthread_getattr_np (pthread_self (), &a); + if (err) + { + error (0, err, "pthread_getattr_np failed"); + result = tf; + } + + int detachstate1, detachstate2; + err = pthread_attr_getdetachstate (&a, &detachstate1); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = tf; + } + else + { + err = pthread_attr_getdetachstate (ap, &detachstate2); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = tf; + } + else if (detachstate1 != detachstate2) + { + error (0, 0, "detachstate differs %d != %d", + detachstate1, detachstate2); + result = tf; + } + } + + void *stackaddr; + size_t stacksize; + err = pthread_attr_getstack (&a, &stackaddr, &stacksize); + if (err) + { + error (0, err, "pthread_attr_getstack failed"); + result = tf; + } + else if ((void *) &a < stackaddr + || (void *) &a >= stackaddr + stacksize) + { + error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack"); + result = tf; + } + else + printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize, + stacksize); + + size_t guardsize1, guardsize2; + err = pthread_attr_getguardsize (&a, &guardsize1); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = tf; + } + else + { + err = pthread_attr_getguardsize (ap, &guardsize2); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = tf; + } + else if (guardsize1 != guardsize2) + { + error (0, 0, "guardsize differs %zd != %zd", + guardsize1, guardsize2); + result = tf; + } + else + printf ("thread guardsize %zd\n", guardsize1); + } + + int scope1, scope2; + err = pthread_attr_getscope (&a, &scope1); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = tf; + } + else + { + err = pthread_attr_getscope (ap, &scope2); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = tf; + } + else if (scope1 != scope2) + { + error (0, 0, "scope differs %d != %d", + scope1, scope2); + result = tf; + } + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = tf; + } + + if (ap == &a2) + { + err = pthread_attr_destroy (ap); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = tf; + } + } + + return result; +} + + +static int +do_test (void) +{ + int result = 0; + pthread_attr_t a; + + int err = pthread_attr_init (&a); + if (err) + { + error (0, err, "pthread_attr_init failed"); + result = 1; + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + err = pthread_getattr_np (pthread_self (), &a); + if (err) + { + error (0, err, "pthread_getattr_np failed"); + result = 1; + } + + int detachstate; + err = pthread_attr_getdetachstate (&a, &detachstate); + if (err) + { + error (0, err, "pthread_attr_getdetachstate failed"); + result = 1; + } + else if (detachstate != PTHREAD_CREATE_JOINABLE) + { + error (0, 0, "initial thread not joinable"); + result = 1; + } + + void *stackaddr; + size_t stacksize; + err = pthread_attr_getstack (&a, &stackaddr, &stacksize); + if (err) + { + error (0, err, "pthread_attr_getstack failed"); + result = 1; + } + else if ((void *) &a < stackaddr + || (void *) &a >= stackaddr + stacksize) + { + error (0, 0, "pthread_attr_getstack returned range does not cover main's stack"); + result = 1; + } + else + printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr, + stackaddr + stacksize, stacksize); + + size_t guardsize; + err = pthread_attr_getguardsize (&a, &guardsize); + if (err) + { + error (0, err, "pthread_attr_getguardsize failed"); + result = 1; + } + else if (guardsize != 0) + { + error (0, 0, "pthread_attr_getguardsize returned %zd != 0", + guardsize); + result = 1; + } + + int scope; + err = pthread_attr_getscope (&a, &scope); + if (err) + { + error (0, err, "pthread_attr_getscope failed"); + result = 1; + } + else if (scope != PTHREAD_SCOPE_SYSTEM) + { + error (0, 0, "pthread_attr_getscope returned %d != PTHREAD_SCOPE_SYSTEM", + scope); + result = 1; + } + + int inheritsched; + err = pthread_attr_getinheritsched (&a, &inheritsched); + if (err) + { + error (0, err, "pthread_attr_getinheritsched failed"); + result = 1; + } + else if (inheritsched != PTHREAD_INHERIT_SCHED) + { + error (0, 0, "pthread_attr_getinheritsched returned %d != PTHREAD_INHERIT_SCHED", + inheritsched); + result = 1; + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + pthread_t th; + err = pthread_create (&th, NULL, tf, NULL); + if (err) + { + error (0, err, "pthread_create #1 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #1 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_init (&a); + if (err) + { + error (0, err, "pthread_attr_init failed"); + result = 1; + } + + err = pthread_create (&th, &a, tf, &a); + if (err) + { + error (0, err, "pthread_create #2 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #2 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_setguardsize (&a, 16 * sysconf (_SC_PAGESIZE)); + if (err) + { + error (0, err, "pthread_attr_setguardsize failed"); + result = 1; + } + + err = pthread_create (&th, &a, tf, &a); + if (err) + { + error (0, err, "pthread_create #3 failed"); + result = 1; + } + else + { + void *ret; + err = pthread_join (th, &ret); + if (err) + { + error (0, err, "pthread_join #3 failed"); + result = 1; + } + else if (ret != NULL) + result = 1; + } + + err = pthread_attr_destroy (&a); + if (err) + { + error (0, err, "pthread_attr_destroy failed"); + result = 1; + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" --- libc/linuxthreads/Makefile.jj 2003-09-17 05:13:28.000000000 -0400 +++ libc/linuxthreads/Makefile 2003-09-18 14:39:43.000000000 -0400 @@ -109,7 +109,7 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ ex17 ex18 tst-cancel tst-context bug-sleep \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ - tst-cancel6 tst-cancel7 tst-popen tst-popen2 + tst-cancel6 tst-cancel7 tst-popen tst-popen2 tst-attr1 test-srcs = tst-signal # These tests are linked with libc before libpthread tests-reverse += tst-cancel5 Jakub From drepper@redhat.com Thu Sep 18 19:15:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 18 Sep 2003 19:15:00 -0000 Subject: [PATCH] Fix open_memstream/syslog, pthread_getattr_np test for linuxthreads In-Reply-To: <20030918164622.GZ12344@sunsite.ms.mff.cuni.cz> References: <20030918164622.GZ12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F6A0423.2060005@redhat.com> Jakub Jelinek wrote: > Some small changes: > [...] Thanks, applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From Philip.Blundell@pobox.com Fri Sep 19 00:08:00 2003 From: Philip.Blundell@pobox.com (Philip Blundell) Date: Fri, 19 Sep 2003 00:08:00 -0000 Subject: problem with syslog, libpthread and dlopen Message-ID: <1063930132.17019.55.camel@kc.cam.armlinux.org> Some Debian users have been reporting problems with syslog() blocking forever when an object that's linked against libpthread has been previously loaded with dlopen. If the main program is linked with -lpthread directly, or it's loaded with LD_PRELOAD, the bug does not occur. What seems to happen is that the __libc_cleanup_push and __libc_cleanup_pop calls in openlog() have no effect, because libc's GOT entries for _pthread_cleanup_push and _pthread_cleanup_pop are set to NULL. But the call to __libc_lock_lock goes via __libc_pthread_functions, which has now been initialized, so openlog() returns with the lock still held. Then the next call to a syslog function attempts to claim the lock a second time, and deadlock ensues. A testcase is at: http://lists.debian.org/debian-glibc/2003/debian-glibc-200309/msg00310.html What's the right way to fix this? Should _pthread_cleanup_push/pop be called through __libc_pthread_functions as well? Thanks p. From jakub@redhat.com Fri Sep 19 20:36:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 19 Sep 2003 20:36:00 -0000 Subject: [PATCH] Add static_link_warning to dlopen Message-ID: <20030919183448.GD12344@sunsite.ms.mff.cuni.cz> Hi! Using dlopen in statically linked apps has the same problems as using NSS/iconv, so we should warn about it too. Well, there might be an exception if the statically linked program is dlopening libraries which are self-contained and don't need anything from glibc (e.g. by using callbacks into the statically linked program), but I guess it is so rare compared to the libs which actually need libc that it should be warned always. 2003-09-19 Jakub Jelinek * dlfcn/dlopen.c (dlopen): Add static_link_warning. --- libc/dlfcn/dlopen.c.jj 2001-07-06 00:54:45.000000000 -0400 +++ libc/dlfcn/dlopen.c 2003-09-19 16:08:44.000000000 -0400 @@ -54,3 +54,4 @@ __dlopen_check (const char *file, int mo } #include versioned_symbol (libdl, __dlopen_check, dlopen, GLIBC_2_1); +static_link_warning (dlopen) Jakub From drepper@redhat.com Fri Sep 19 20:41:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 19 Sep 2003 20:41:00 -0000 Subject: [PATCH] Add static_link_warning to dlopen In-Reply-To: <20030919183448.GD12344@sunsite.ms.mff.cuni.cz> References: <20030919183448.GD12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F6B69A1.2060408@redhat.com> Jakub Jelinek wrote: > Using dlopen in statically linked apps has the same problems as using > NSS/iconv, so we should warn about it too. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From Philip.Blundell@pobox.com Mon Sep 22 17:53:00 2003 From: Philip.Blundell@pobox.com (Philip Blundell) Date: Mon, 22 Sep 2003 17:53:00 -0000 Subject: problem with syslog, libpthread and dlopen In-Reply-To: <1063930132.17019.55.camel@kc.cam.armlinux.org> References: <1063930132.17019.55.camel@kc.cam.armlinux.org> Message-ID: <1064253162.17019.188.camel@kc.cam.armlinux.org> On Fri, 2003-09-19 at 01:08, Philip Blundell wrote: > What's the right way to fix this? Should _pthread_cleanup_push/pop be > called through __libc_pthread_functions as well? Here's the patch I'm currently using for this. Any comments? Thanks p. -------------- next part -------------- 2003-09-22 Philip Blundell * forward.c: Add _pthread_cleanup_push, _pthread_cleanup_pop. * sysdeps/pthread/pthread-functions.h (struct pthread_functions): Likewise. * pthread.c (__pthread_elements): Initialise these new elements. * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_push): Use __libc_maybe_call. (__libc_cleanup_pop): Likewise. Index: linuxthreads/forward.c =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/forward.c,v retrieving revision 1.5 diff -u -r1.5 forward.c --- linuxthreads/forward.c 2 Sep 2003 00:37:04 -0000 1.5 +++ linuxthreads/forward.c 18 Sep 2003 23:36:32 -0000 @@ -173,3 +173,7 @@ 0) FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) + +FORWARD2 (_pthread_cleanup_push, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return) + +FORWARD2 (_pthread_cleanup_pop, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return) Index: linuxthreads/pthread.c =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/pthread.c,v retrieving revision 1.130 diff -u -r1.130 pthread.c --- linuxthreads/pthread.c 17 Sep 2003 09:39:16 -0000 1.130 +++ linuxthreads/pthread.c 18 Sep 2003 23:36:32 -0000 @@ -279,7 +279,9 @@ .ptr_pthread_cleanup_upto = __pthread_cleanup_upto, .ptr_pthread_sigaction = __pthread_sigaction, .ptr_pthread_sigwait = __pthread_sigwait, - .ptr_pthread_raise = __pthread_raise + .ptr_pthread_raise = __pthread_raise, + .ptr__pthread_cleanup_push = _pthread_cleanup_push, + .ptr__pthread_cleanup_pop = _pthread_cleanup_pop }; #ifdef SHARED # define ptr_pthread_functions &__pthread_functions Index: linuxthreads/sysdeps/pthread/pthread-functions.h =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/pthread/pthread-functions.h,v retrieving revision 1.3 diff -u -r1.3 pthread-functions.h --- linuxthreads/sysdeps/pthread/pthread-functions.h 10 Sep 2003 22:27:19 -0000 1.3 +++ linuxthreads/sysdeps/pthread/pthread-functions.h 18 Sep 2003 23:36:33 -0000 @@ -83,6 +83,11 @@ int (*ptr_pthread_raise) (int sig); int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *, const struct timespec *); + void (*ptr__pthread_cleanup_push) (struct _pthread_cleanup_buffer * buffer, + void (*routine)(void *), void * arg); + + void (*ptr__pthread_cleanup_pop) (struct _pthread_cleanup_buffer * buffer, + int execute); }; /* Variable in libc.so. */ Index: linuxthreads/sysdeps/pthread/bits/libc-lock.h =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/pthread/bits/libc-lock.h,v retrieving revision 1.31 diff -u -r1.31 libc-lock.h --- linuxthreads/sysdeps/pthread/bits/libc-lock.h 8 Aug 2003 07:40:17 -0000 1.31 +++ linuxthreads/sysdeps/pthread/bits/libc-lock.h 18 Sep 2003 23:36:33 -0000 @@ -265,18 +265,12 @@ } #define __libc_cleanup_push(fct, arg) \ - { struct _pthread_cleanup_buffer _buffer; \ - int _avail = _pthread_cleanup_push != NULL; \ - if (_avail) { \ - _pthread_cleanup_push (&_buffer, (fct), (arg)); \ - } + { struct _pthread_cleanup_buffer _buffer; \ + __libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0) #define __libc_cleanup_pop(execute) \ - if (_avail) { \ - _pthread_cleanup_pop (&_buffer, execute); \ - } \ - } - + __libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0); \ + } /* Create thread-specific key. */ #define __libc_key_create(KEY, DESTRUCTOR) \ From drepper@redhat.com Tue Sep 23 05:51:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 Sep 2003 05:51:00 -0000 Subject: problem with syslog, libpthread and dlopen In-Reply-To: <1064253162.17019.188.camel@kc.cam.armlinux.org> References: <1063930132.17019.55.camel@kc.cam.armlinux.org> <1064253162.17019.188.camel@kc.cam.armlinux.org> Message-ID: <3F6FDF11.5060903@redhat.com> Philip Blundell wrote: > Here's the patch I'm currently using for this. Any comments? Looks OK, I've applied it. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Wed Sep 24 13:06:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 Sep 2003 13:06:00 -0000 Subject: [PATCH] Fix nscd build Message-ID: <20030924110354.GI12344@sunsite.ms.mff.cuni.cz> Hi! 1) configure hasn't been commited 2) if have-fpie != yes, then Rules will see still others := nscd_nischeck (and not others := nscd_nischeck nscd), as it is assigned later, which means nscd binary is not built 2003-09-24 Jakub Jelinek * nscd/Makefile (others): Add nscd before including ../Rules. * configure: Rebuilt. --- libc/configure.jj 2003-09-24 08:14:24.000000000 -0400 +++ libc/configure 2003-09-24 08:40:47.000000000 -0400 @@ -5455,6 +5455,33 @@ fi echo "$as_me:$LINENO: result: $libc_cv_z_execstack" >&5 echo "${ECHO_T}$libc_cv_z_execstack" >&6 + + echo "$as_me:$LINENO: checking for -fpie" >&5 +echo $ECHO_N "checking for -fpie... $ECHO_C" >&6 +if test "${libc_cv_fpie+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + then + libc_cv_fpie=yes + else + libc_cv_fpie=no + fi + rm -f conftest* +fi +echo "$as_me:$LINENO: result: $libc_cv_fpie" >&5 +echo "${ECHO_T}$libc_cv_fpie" >&6 + + fi if test $elf != yes; then @@ -7842,6 +7869,7 @@ s,@libc_cv_Bgroup@,$libc_cv_Bgroup,;t t s,@ASFLAGS_config@,$ASFLAGS_config,;t t s,@libc_cv_z_combreloc@,$libc_cv_z_combreloc,;t t s,@libc_cv_z_execstack@,$libc_cv_z_execstack,;t t +s,@libc_cv_fpie@,$libc_cv_fpie,;t t s,@libc_cv_have_initfini@,$libc_cv_have_initfini,;t t s,@libc_cv_cpp_asm_debuginfo@,$libc_cv_cpp_asm_debuginfo,;t t s,@no_whole_archive@,$no_whole_archive,;t t --- libc/nscd/Makefile.jj 2003-09-24 05:35:35.000000000 -0400 +++ libc/nscd/Makefile 2003-09-24 08:33:30.000000000 -0400 @@ -35,6 +35,9 @@ nscd-modules := nscd connections pwdcach ifeq ($(have-thread-library),yes) others := nscd_nischeck +ifneq (yesyes,$(have-fpie)$(build-shared)) +others += nscd +endif install-sbin := nscd nscd_nischeck extra-objs := $(nscd-modules:=.o) nscd_nischeck.o @@ -84,8 +87,6 @@ $(objpfx)nscd: $(addprefix $(objpfx),$(n $(LDFLAGS) $(LDFLAGS-$(@F)) \ -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \ -o $@ $^ $(common-objpfx)libc_nonshared.a -else -others += nscd endif # This makes sure -DNOT_IN_libc is passed for all these modules. Jakub From jakub@redhat.com Wed Sep 24 15:06:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 Sep 2003 15:06:00 -0000 Subject: [PATCH] Fix sys/sysmacros.h in C++ Message-ID: <20030924122928.GJ12344@sunsite.ms.mff.cuni.cz> Hi! In C++, we need to duplicate throw(), so that they match. Also, I wonder whether a) we shouldn't use different inline function names, so that programs not using sys/sysmacros.h can use major/minor/makedev symbols (__major/__minor/__makedev?) b) if not, shouldn't the exported functions from libc be at least weak? 2003-09-24 Jakub Jelinek * sysdeps/unix/sysv/linux/sys/sysmacros.h (major, minor, makedev): Add __THROW. --- libc/sysdeps/unix/sysv/linux/sys/sysmacros.h.jj 24 Sep 2003 09:35:49 -0000 +++ libc/sysdeps/unix/sysv/linux/sys/sysmacros.h 24 Sep 2003 14:26:00 -0000 @@ -33,19 +33,19 @@ extern unsigned long long int inline mak # if defined __GNUC__ && __GNUC__ >= 2 extern inline unsigned int -major (unsigned long long int __dev) +major (unsigned long long int __dev) __THROW { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); } extern inline unsigned int -minor (unsigned long long int __dev) +minor (unsigned long long int __dev) __THROW { return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); } extern inline unsigned long long int -makedev (unsigned int __major, unsigned int __minor) +makedev (unsigned int __major, unsigned int __minor) __THROW { return ((__minor & 0xff) | ((__major & 0xfff) << 8) | (((unsigned long long int) (__minor & ~0xff)) << 12) Jakub From jakub@redhat.com Wed Sep 24 17:22:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 Sep 2003 17:22:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches, export back at GLIBC_2.1 Message-ID: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> Hi! Roland's execstack code needs __libc_stack_end set already during dl_main, not after it. The following patch does that (tested on a bunch of arches). I haven't touched hppa, mips, can maintainers do something about it? Also, for ia64, the __libc_stack_end setting code in RTLD_START should be removed, but removing of that requires rebundling the whole assembly. Any volunteers? 2003-09-24 Jakub Jelinek * elf/Versions (ld): Export __libc_stack_end@GLIBC_2.1 instead of __libc_stack_end@GLIBC_PRIVATE. * sysdeps/generic/dl-sysdep.c (DL_STACK_END): Define if not defined. (_dl_sysdep_start): Set __libc_stack_end here. * sysdeps/alpha/dl-machine.h (RTLD_START): Remove setting of __libc_stack_end. * sysdeps/arm/dl-machine.h (RTLD_START): Likewise. * sysdeps/cris/dl-machine.h (RTLD_START): Likewise. * sysdeps/i386/dl-machine.h (RTLD_START): Likewise. * sysdeps/m68k/dl-machine.h (RTLD_START): Likewise. * sysdeps/s390/s390-32/dl-machine.h (RTLD_START): Likewise. * sysdeps/s390/s390-64/dl-machine.h (RTLD_START): Likewise. * sysdeps/sh/dl-machine.h (RTLD_START): Likewise. * sysdeps/x86_64/dl-machine.h (RTLD_START): Likewise. * sysdeps/ia64/dl-machine.h (DL_STACK_END): Define. * sysdeps/sparc/sparc32/dl-machine.h (DL_STACK_END): Define. (RTLD_START): Remove setting of __libc_stack_end. * sysdeps/sparc/sparc64/dl-machine.h (DL_STACK_END): Define. (RTLD_START): Remove setting of __libc_stack_end. --- libc/elf/Versions.jj 2003-09-23 10:14:05.000000000 -0400 +++ libc/elf/Versions 2003-09-24 05:37:50.000000000 -0400 @@ -36,6 +36,8 @@ ld { GLIBC_2.1 { # functions used in other libraries _dl_mcount; + # historically used by Garbage Collectors + __libc_stack_end; } GLIBC_2.3 { # runtime interface to TLS @@ -43,7 +45,7 @@ ld { } GLIBC_PRIVATE { # Those are in the dynamic linker, but used by libc.so. - __libc_enable_secure; __libc_stack_end; + __libc_enable_secure; _dl_argv; _dl_catch_error; _dl_check_map_versions; _dl_debug_printf; _dl_debug_state; _dl_dst_count; _dl_dst_substitute; _dl_init; _dl_lookup_symbol; _dl_lookup_symbol_skip; --- libc/sysdeps/alpha/dl-machine.h.jj 2003-07-31 04:35:53.000000000 -0400 +++ libc/sysdeps/alpha/dl-machine.h 2003-09-24 04:34:21.000000000 -0400 @@ -319,8 +319,6 @@ _dl_start_user: \n\ .prologue 0 \n\ /* Save the user entry point address in s0. */ \n\ mov $0, $9 \n\ - /* Store the highest stack address. */ \n\ - stq $30, __libc_stack_end \n\ /* See if we were run as a command with the executable \n\ file name as an extra leading argument. */ \n\ ldl $1, _dl_skip_args($gp) !gprel \n\ --- libc/sysdeps/arm/dl-machine.h.jj 2003-09-22 11:35:41.000000000 -0400 +++ libc/sysdeps/arm/dl-machine.h 2003-09-24 04:35:37.000000000 -0400 @@ -265,10 +265,6 @@ _dl_start_user:\n\ ldr sl, .L_GET_GOT\n\ add sl, pc, sl\n\ .L_GOT_GOT:\n\ - @ Store the highest stack address\n\ - ldr r1, .L_STACK_END\n\ - ldr r1, [sl, r1]\n\ - str sp, [r1]\n\ @ See if we were run as a command with the executable file\n\ @ name as an extra leading argument.\n\ ldr r4, .L_SKIP_ARGS\n\ @@ -311,8 +307,6 @@ _dl_start_user:\n\ .word _dl_starting_up(GOT)\n\ .L_FINI_PROC:\n\ .word _dl_fini(GOT)\n\ -.L_STACK_END:\n\ - .word __libc_stack_end(GOT)\n\ .L_LOADED:\n\ .word _rtld_local(GOT)\n\ .previous\n\ --- libc/sysdeps/cris/dl-machine.h.jj 2003-09-17 07:42:32.000000000 -0400 +++ libc/sysdeps/cris/dl-machine.h 2003-09-24 04:36:14.000000000 -0400 @@ -188,9 +188,6 @@ _dl_start_user:\n\ ; Point R0 at the GOT.\n\ move.d $pc,$r0\n\ sub.d .:GOTOFF,$r0\n\ - ; Remember the highest stack address.\n\ - move.d [$r0+__libc_stack_end:GOT16],$r13\n\ - move.d $sp,[$r13]\n\ ; See if we were run as a command with the executable file\n\ ; name as an extra leading argument.\n\ move.d [$r0+_dl_skip_args:GOT16],$r13\n\ --- libc/sysdeps/generic/dl-sysdep.c.jj 2003-07-15 11:14:39.000000000 -0400 +++ libc/sysdeps/generic/dl-sysdep.c 2003-09-24 04:31:10.000000000 -0400 @@ -69,6 +69,9 @@ static ElfW(auxv_t) *_dl_auxv; } while (0) #endif +#ifndef DL_STACK_END +# define DL_STACK_END(cookie) ((void *) (cookie)) +#endif ElfW(Addr) _dl_sysdep_start (void **start_argptr, @@ -98,6 +101,7 @@ _dl_sysdep_start (void **start_argptr, ElfW(Word) new_sysinfo = 0; #endif + __libc_stack_end = DL_STACK_END (start_argptr); DL_FIND_ARG_COMPONENTS (start_argptr, _dl_argc, INTUSE(_dl_argv), _environ, _dl_auxv); --- libc/sysdeps/i386/dl-machine.h.jj 2003-09-23 11:03:03.000000000 -0400 +++ libc/sysdeps/i386/dl-machine.h 2003-09-24 04:38:49.000000000 -0400 @@ -276,17 +276,15 @@ _dl_runtime_profile:\n\ .globl _start\n\ .globl _dl_start_user\n\ _start:\n\ - # Point %ebx at the GOT.\n\ - call 0b\n\ - addl $_GLOBAL_OFFSET_TABLE_, %ebx\n\ # Note that _dl_start gets the parameter in %eax.\n\ movl %esp, %eax\n\ - # Store the highest stack address\n\ - movl %eax, __libc_stack_end@GOTOFF(%ebx)\n\ call _dl_start\n\ _dl_start_user:\n\ # Save the user entry point address in %edi.\n\ movl %eax, %edi\n\ + # Point %ebx at the GOT.\n\ + call 0b\n\ + addl $_GLOBAL_OFFSET_TABLE_, %ebx\n\ # See if we were run as a command with the executable file\n\ # name as an extra leading argument.\n\ movl _dl_skip_args@GOTOFF(%ebx), %eax\n\ --- libc/sysdeps/ia64/dl-machine.h.jj 2003-08-26 17:07:43.000000000 -0400 +++ libc/sysdeps/ia64/dl-machine.h 2003-09-24 04:44:19.000000000 -0400 @@ -267,6 +267,10 @@ elf_machine_runtime_setup (struct link_m strong_alias (_dl_runtime_resolve, _dl_runtime_profile); #endif +/* Undo the adds out0 = 16, sp below to get at the value we want in + __libc_stack_end. */ +#define DL_STACK_END(cookie) \ + ((void *) (((long) (cookie)) - 16)) /* Initial entry point code for the dynamic linker. The C function `_dl_start' is the real entry point; --- libc/sysdeps/m68k/dl-machine.h.jj 2003-07-31 04:35:58.000000000 -0400 +++ libc/sysdeps/m68k/dl-machine.h 2003-09-24 04:54:45.000000000 -0400 @@ -157,9 +157,6 @@ _start:\n\ _dl_start_user:\n\ | Save the user entry point address in %a4.\n\ move.l %d0, %a4\n\ - | Remember the highest stack address.\n\ - move.l __libc_stack_end@GOTPC(%pc), %a0\n\ - move.l %sp, (%a0)\n\ | See if we were run as a command with the executable file\n\ | name as an extra leading argument.\n\ move.l _dl_skip_args(%pc), %d0\n\ --- libc/sysdeps/s390/s390-32/dl-machine.h.jj 2003-08-06 14:36:16.000000000 -0400 +++ libc/sysdeps/s390/s390-32/dl-machine.h 2003-09-24 05:05:21.000000000 -0400 @@ -262,9 +262,6 @@ _dl_start_user:\n\ # Point %r12 at the GOT.\n\ l %r12,.Ladr0-.Llit(%r13)\n\ ar %r12,%r13\n\ - # Store the highest stack address\n\ - l %r1,__libc_stack_end@GOT(%r12)\n\ - st %r15, 0(%r1)\n\ # See if we were run as a command with the executable file\n\ # name as an extra leading argument.\n\ l %r1,_dl_skip_args@GOT12(0,%r12)\n\ --- libc/sysdeps/s390/s390-64/dl-machine.h.jj 2003-08-06 14:36:16.000000000 -0400 +++ libc/sysdeps/s390/s390-64/dl-machine.h 2003-09-24 05:05:55.000000000 -0400 @@ -235,10 +235,6 @@ _dl_start_user:\n\ lgr %r8,%r2\n\ # Point %r12 at the GOT.\n\ larl %r12,_GLOBAL_OFFSET_TABLE_\n\ - # Store the highest stack address\n\ - lghi %r1,__libc_stack_end@GOT\n\ - lg %r1,0(%r1,%r12)\n\ - stg %r15, 0(%r1)\n\ # See if we were run as a command with the executable file\n\ # name as an extra leading argument.\n\ lghi %r1,_dl_skip_args@GOT\n\ --- libc/sysdeps/sh/dl-machine.h.jj 2003-07-31 04:36:01.000000000 -0400 +++ libc/sysdeps/sh/dl-machine.h 2003-09-24 05:07:19.000000000 -0400 @@ -334,11 +334,7 @@ _dl_start_user:\n\ add r0,r12\n\ .align 2\n\ 1: .long _GLOBAL_OFFSET_TABLE_\n\ -2: ! Store the highest stack address\n\ - mov.l .L_stack_end,r0\n\ - mov.l @(r0,r12),r0\n\ - mov.l r15,@r0\n\ - ! See if we were run as a command with the executable file\n\ +2: ! See if we were run as a command with the executable file\n\ ! name as an extra leading argument.\n\ mov.l .L_dl_skip_args,r0\n\ mov.l @(r0,r12),r0\n\ @@ -381,8 +377,6 @@ _dl_start_user:\n\ .align 2\n\ .L_dl_start:\n\ .long _dl_start@PLT\n\ -.L_stack_end:\n\ - .long __libc_stack_end@GOT\n\ .L_dl_skip_args:\n\ .long _dl_skip_args@GOT\n\ .L_dl_init:\n\ --- libc/sysdeps/sparc/sparc32/dl-machine.h.jj 2003-08-26 17:07:46.000000000 -0400 +++ libc/sysdeps/sparc/sparc32/dl-machine.h 2003-09-24 05:11:04.000000000 -0400 @@ -248,6 +248,11 @@ elf_machine_runtime_setup (struct link_m /* The SPARC overlaps DT_RELA and DT_PLTREL. */ #define ELF_MACHINE_PLTREL_OVERLAP 1 +/* Undo the sub %sp, 6*4, %sp; add %sp, 22*4, %o0 below to get at the + value we want in __libc_stack_end. */ +#define DL_STACK_END(cookie) \ + ((void *) (((long) (cookie)) - (22 - 6) * 4)) + /* Initial entry point code for the dynamic linker. The C function `_dl_start' is the real entry point; its return value is the user program's entry point. */ @@ -274,16 +279,10 @@ _dl_start_user:\n\ add %l7, %o7, %l7\n\ /* Save the user entry point address in %l0 */\n\ mov %o0, %l0\n\ - /* Store the highest stack address. */\n\ - sethi %hi(__libc_stack_end), %g2\n\ - or %g2, %lo(__libc_stack_end), %g2\n\ - ld [%l7 + %g2], %l1\n\ - sethi %hi(_dl_skip_args), %g2\n\ - add %sp, 6*4, %l2\n\ - or %g2, %lo(_dl_skip_args), %g2\n\ - st %l2, [%l1]\n\ /* See if we were run as a command with the executable file name as an\n\ extra leading argument. If so, adjust the contents of the stack. */\n\ + sethi %hi(_dl_skip_args), %g2\n\ + or %g2, %lo(_dl_skip_args), %g2\n\ ld [%l7+%g2], %i0\n\ ld [%i0], %i0\n\ tst %i0\n\ --- libc/sysdeps/sparc/sparc64/dl-machine.h.jj 2003-07-31 04:36:02.000000000 -0400 +++ libc/sysdeps/sparc/sparc64/dl-machine.h 2003-09-24 05:14:58.000000000 -0400 @@ -666,6 +666,11 @@ elf_machine_runtime_setup (struct link_m /* The PLT uses Elf64_Rela relocs. */ #define elf_machine_relplt elf_machine_rela +/* Undo the sub %sp, 6*8, %sp; add %sp, STACK_BIAS + 22*8, %o0 below + to get at the value we want in __libc_stack_end. */ +#define DL_STACK_END(cookie) \ + ((void *) (((long) (cookie)) - (22 - 6) * 8 - STACK_BIAS)) + /* Initial entry point code for the dynamic linker. The C function `_dl_start' is the real entry point; its return value is the user program's entry point. */ @@ -694,20 +699,14 @@ elf_machine_runtime_setup (struct link_m "1: call 11f\n" \ " sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \ "11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n" \ -" /* Store the highest stack address. */\n" \ -" sethi %hi(__libc_stack_end), %g5\n" \ +" sethi %hi(_dl_skip_args), %g5\n" \ " add %l7, %o7, %l7\n" \ -" or %g5, %lo(__libc_stack_end), %g5\n" \ +" or %g5, %lo(_dl_skip_args), %g5\n" \ " /* Save the user entry point address in %l0. */\n" \ " mov %o0, %l0\n" \ -" ldx [%l7 + %g5], %l1\n" \ -" sethi %hi(_dl_skip_args), %g5\n" \ -" add %sp, 6*8, %l2\n" \ " /* See if we were run as a command with the executable file name as an\n" \ " extra leading argument. If so, we must shift things around since we\n" \ " must keep the stack doubleword aligned. */\n" \ -" or %g5, %lo(_dl_skip_args), %g5\n" \ -" stx %l2, [%l1]\n" \ " ldx [%l7 + %g5], %i0\n" \ " ld [%i0], %i0\n" \ " brz,pt %i0, 2f\n" \ --- libc/sysdeps/x86_64/dl-machine.h.jj 2003-09-24 04:20:43.000000000 -0400 +++ libc/sysdeps/x86_64/dl-machine.h 2003-09-24 05:16:28.000000000 -0400 @@ -260,8 +260,6 @@ _dl_runtime_profile:\n\ .globl _start\n\ .globl _dl_start_user\n\ _start:\n\ - # Store the highest stack address\n\ - movq %rsp, __libc_stack_end(%rip)\n\ movq %rsp, %rdi\n\ call _dl_start\n\ _dl_start_user:\n\ Jakub From davidm@napali.hpl.hp.com Wed Sep 24 19:20:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Wed, 24 Sep 2003 19:20:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches, export back at GLIBC_2.1 In-Reply-To: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> References: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> Message-ID: <16241.61056.949014.678340@napali.hpl.hp.com> >>>>> On Wed, 24 Sep 2003 15:47:04 +0200, Jakub Jelinek said: Jakub> Also, for ia64, the __libc_stack_end setting code in Jakub> RTLD_START should be removed, but removing of that requires Jakub> rebundling the whole assembly. You mean something along these lines? (In my opinion, the explicit bundling should be removed in such assembly code. It only hurts readability.) --david Index: sysdeps/ia64/dl-machine.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/ia64/dl-machine.h,v retrieving revision 1.28 diff -u -r1.28 dl-machine.h --- sysdeps/ia64/dl-machine.h 18 Aug 2003 22:04:56 -0000 1.28 +++ sysdeps/ia64/dl-machine.h 24 Sep 2003 18:57:03 -0000 @@ -318,21 +318,14 @@ " .save ar.pfs, r32\n" \ " .body\n" \ " { .mii\n" \ -" /* Save the pointer to the user entry point fptr in loc2. */\n" \ -" mov loc2 = ret0\n" \ -" /* Store the highest stack address. */\n" \ -" addl r2 = @ltoff(__libc_stack_end#), gp\n" \ " addl r3 = @gprel(_dl_skip_args), gp\n" \ -" ;;\n" \ -" }\n" \ -" { .mmi\n" \ -" ld8 r2 = [r2]\n" \ -" ld4 r3 = [r3]\n" \ " adds r11 = 24, sp /* Load the address of argv. */\n" \ +" /* Save the pointer to the user entry point fptr in loc2. */\n" \ +" mov loc2 = ret0\n" \ " ;;\n" \ " }\n" \ " { .mii\n" \ -" st8 [r2] = sp\n" \ +" ld4 r3 = [r3]\n" \ " adds r10 = 16, sp /* Load the address of argc. */\n" \ " mov out2 = r11\n" \ " ;;\n" \ @@ -401,7 +394,7 @@ " br.call.sptk.many b0 = _dl_init_internal#\n" \ " ;;\n" \ " }\n" \ -" /* Pass our finializer function to the user,\n" \ +" /* Pass our finalizer function to the user,\n" \ " and jump to the user's entry point. */\n" \ " { .mmi\n" \ " ld8 r3 = [loc2], 8\n" \ From sjmunroe@us.ibm.com Wed Sep 24 20:15:00 2003 From: sjmunroe@us.ibm.com (Steven Munroe) Date: Wed, 24 Sep 2003 20:15:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches,... Message-ID: <3F71E53D.F128E61D@us.ibm.com> Jakub Jelinek Wed, 24 Sep 2003 15:47:04 writes: > The following patch does that (tested on a bunch of arches). Actually it does not include PowerPC 32/64. Currently for PowerPC linux __libc_stack_end is set in libc_start_main, but this is not soon enough to support execstack and the execstack tests in make check fails (because __libc_stack_end is not set). The attached patch uses DL_PLATFORM_INIT to capture the argv pointer and store that into __libc_stack_end during _dl_sysdep_start before the call to dl_main. This will work for both powerpc32 and powerpc64. This is soon enough to pass the stack-end into _dl_make_stack_executable but it still fails in the mprotect with a "Permission Denied". I'll pursue that issue further. I would like an explanation of why we are doing this. Generally arbitrarily marking the stack executable is a bad idea. So I would like a explaination (pointer to one) of the function we trying to provide and the conditions under which it will be used. 2003-09-24 Steven Munroe * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c [DL_PLATFORM_INIT]: Define (frob_stack_end): New function. -- Steven Munroe sjmunroe@us.ibm.com Linux on PowerPC-64 Development GLIBC for PowerPC-64 Development -------------- next part -------------- diff -urN libc23-cvstip-20030923/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c libc23/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c --- libc23-cvstip-20030923/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c 2003-03-15 18:40:44.000000000 -0600 +++ libc23/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c 2003-09-24 13:19:34.000000000 -0500 @@ -25,6 +25,16 @@ extern int __cache_line_size; weak_extern (__cache_line_size) +#define DL_PLATFORM_INIT frob_stack_end (start_argptr) + +extern void *__libc_stack_end; + +static inline void +frob_stack_end (void *arg) +{ + __libc_stack_end = arg; /* Initialize the break. */ +} + /* Scan the Aux Vector for the "Data Cache Block Size" entry. If found verify that the static extern __cache_line_size is defined by checking for not NULL. If it is defined then assign the cache block size From drepper@redhat.com Wed Sep 24 20:27:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Sep 2003 20:27:00 -0000 Subject: [PATCH] Fix sys/sysmacros.h in C++ In-Reply-To: <20030924122928.GJ12344@sunsite.ms.mff.cuni.cz> References: <20030924122928.GJ12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F71FDEA.4090207@redhat.com> Jakub Jelinek wrote: > Also, I wonder whether > a) we shouldn't use different inline function names, so that > programs not using sys/sysmacros.h can use major/minor/makedev > symbols (__major/__minor/__makedev?) I've renamed the function definitions. Not with a __ prefix, but instead with gnu_dev_. No leading underscores (these are public interfaces) and the gnu_dev_ prefix is hardly used anywhere else. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From drepper@redhat.com Wed Sep 24 20:41:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Sep 2003 20:41:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches,... In-Reply-To: <3F71E53D.F128E61D@us.ibm.com> References: <3F71E53D.F128E61D@us.ibm.com> Message-ID: <3F720133.1050701@redhat.com> Steven Munroe wrote: > I would like an explanation of why we are doing this. Generally arbitrarily > marking the stack executable is a bad idea. Nobody disagrees. The execstack functionality is exactly there to avoid having an executable stack unless really needed. To to this binaries need to be marked appropriately and the defaults (what happens if the status isn't known for a file) have to be selected correctly for each platform. See Jakub patches to ld, see the extra section gcc creates to mark stack usage (.note.GNU-stack). -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Wed Sep 24 20:50:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 Sep 2003 20:50:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches, export back at GLIBC_2.1 In-Reply-To: <16241.61056.949014.678340@napali.hpl.hp.com> References: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> <16241.61056.949014.678340@napali.hpl.hp.com> Message-ID: <20030924184756.GL12344@sunsite.ms.mff.cuni.cz> On Wed, Sep 24, 2003 at 12:20:32PM -0700, David Mosberger wrote: > >>>>> On Wed, 24 Sep 2003 15:47:04 +0200, Jakub Jelinek said: > > Jakub> Also, for ia64, the __libc_stack_end setting code in > Jakub> RTLD_START should be removed, but removing of that requires > Jakub> rebundling the whole assembly. > > You mean something along these lines? (In my opinion, the explicit Yes. Thanks. Jakub From drepper@redhat.com Wed Sep 24 21:31:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Sep 2003 21:31:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches, export back at GLIBC_2.1 In-Reply-To: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> References: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F720CD7.6080604@redhat.com> Jakub Jelinek wrote: > Roland's execstack code needs __libc_stack_end set already during dl_main, > not after it. I applied the patch. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From drepper@redhat.com Wed Sep 24 21:32:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Sep 2003 21:32:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches, export back at GLIBC_2.1 In-Reply-To: <16241.61056.949014.678340@napali.hpl.hp.com> References: <20030924134704.GK12344@sunsite.ms.mff.cuni.cz> <16241.61056.949014.678340@napali.hpl.hp.com> Message-ID: <3F720D20.6050205@redhat.com> David Mosberger wrote: > You mean something along these lines? I applied the patch. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Wed Sep 24 21:38:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 Sep 2003 21:38:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches,... In-Reply-To: <3F71E53D.F128E61D@us.ibm.com> References: <3F71E53D.F128E61D@us.ibm.com> Message-ID: <20030924193622.GM12344@sunsite.ms.mff.cuni.cz> On Wed, Sep 24, 2003 at 01:41:01PM -0500, Steven Munroe wrote: > Jakub Jelinek Wed, 24 Sep 2003 15:47:04 writes: > > > The following patch does that (tested on a bunch of arches). > > Actually it does not include PowerPC 32/64. Currently for PowerPC linux > __libc_stack_end is set in libc_start_main, but this is not soon enough to > support execstack and the execstack tests in make check fails (because > __libc_stack_end is not set). The attached patch uses DL_PLATFORM_INIT to > capture the argv pointer and store that into __libc_stack_end during > _dl_sysdep_start before the call to dl_main. This will work for both powerpc32 > and powerpc64. > > This is soon enough to pass the stack-end into _dl_make_stack_executable but it > still fails in the mprotect with a "Permission Denied". I'll pursue that issue > further. > > I would like an explanation of why we are doing this. Generally arbitrarily > marking the stack executable is a bad idea. So I would like a explaination > (pointer to one) of the function we trying to provide and the conditions under > which it will be used. Normally on ppc32 all processes get executable stack, which is not exactly secure. But you cannot disable it blindly for all processes, as you don't know if they really need it or not. ppc32 needs executable stack for trampolines (e.g. when you take address of a nested function in C). Recent GCC+binutils mark objects with .note.GNU-stack segment (either "" or "x" depending on whether it needs executable stack or not) and ld merges this into PT_GNU_STACK segment. If a binary has PT_GNU_STACK PF_R|PF_W|PF_X (or no PT_GNU_STACK segment), kernel needs to assume the program needs (or might need) executable stack. If a binary has PT_GNU_STACK PF_R|PF_W, kernel can assume the program doesn't need executable stack and can change its VMA permissions. This all can be done in gcc/binutils and kernel, no glibc help needed. But now, if you have PT_GNU_STACK PF_R|PF_W binary which dlopens some library which needs or might need executable stack (or depends on such library through DT_NEEDED), kernel which only sees that binary and the dynamic linker and might tighten stack permissions while they actually need to be executable for the library. Here is when ld.so needs to change the permissions. In similar situation to ppc32 are most other linux arches (i386, amd64, ...). The only special arches here are ia64 and ppc64, as there trampolines don't actually need executable stack. Because of this I chose not to add .note.GNU-stack/PT_GNU_STACK marking for these two arches. Unfortunately, on both these arches kernel defaults to executable stack as I found out today and thus there can be programs which rely on this and so for binary compatibility need to be assumed as needing executable stack too. Which means I'll probably have to mark all ia64/ppc64 gcc output with .section .note.GNU-stack, "" and let all binaries be marked too (which one can always override using -Wa,--execstack or -Wl,-z,execstack). > 2003-09-24 Steven Munroe > > * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c > [DL_PLATFORM_INIT]: Define > (frob_stack_end): New function. Why do you need this? Isn't the __libc_stack_end patch I've posted sufficient for ppc32/ppc64? Certainly I haven't seen any tst-execstack* failures on either ppc32 or ppc64. ppc32: sysdeps/powerpc/powerpc32/dl-start.S sets mr r3,r1 which becomes argument to _dl_start, which passes arg directly do _dl_start_final and that one to _dl_sysdep_start. sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c includes sysdeps/generic/dl-sysdep.c for _dl_sysdep_start and there my patch sets __libc_stack_end to that argument. ppc64: similarly, just the first step is in sysdeps/powerpc/powerpc64/dl-machine.h (RTLD_START): mr 3,1 Jakub From davidm@napali.hpl.hp.com Wed Sep 24 22:13:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Wed, 24 Sep 2003 22:13:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches,... In-Reply-To: <20030924193622.GM12344@sunsite.ms.mff.cuni.cz> References: <3F71E53D.F128E61D@us.ibm.com> <20030924193622.GM12344@sunsite.ms.mff.cuni.cz> Message-ID: <16242.5901.43570.577970@napali.hpl.hp.com> >>>>> On Wed, 24 Sep 2003 21:36:22 +0200, Jakub Jelinek said: Jakub> The only special arches here are ia64 and ppc64, as there Jakub> trampolines don't actually need executable stack. Because of Jakub> this I chose not to add .note.GNU-stack/PT_GNU_STACK marking Jakub> for these two arches. Unfortunately, on both these arches Jakub> kernel defaults to executable stack as I found out today and Jakub> thus there can be programs which rely on this and so for Jakub> binary compatibility need to be assumed as needing executable Jakub> stack too. Why do you say this? $ uname -a Linux wailua.hpl.hp.com 2.6.0-test5 #30 Tue Sep 16 11:28:09 PDT 2003 ia64 GNU/Linux $ cat /proc/self/maps |grep 60000fff7 60000fff7fffc000-60000fff80000000 rw-p 00000000 00:00 0 We stopped turning on execute permission some time again (2.4.1x). For ia64 Linux, there is an ELF OS flag which can be set to force executable data/stack (the user-tool to do this is called "chatr"). --david From sjmunroe@us.ibm.com Wed Sep 24 22:49:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Wed, 24 Sep 2003 22:49:00 -0000 Subject: [PATCH] Set __libc_stack_end earlier on all arches,... Message-ID: David Mosberger writes: > > On Wed, 24 Sep 2003 21:36:22 +0200, Jakub Jelinek said: > > Jakub> The only special arches here are ia64 and ppc64, as there > Jakub> trampolines don't actually need executable stack. Because of > Jakub> this I chose not to add .note.GNU-stack/PT_GNU_STACK marking > Jakub> for these two arches. Unfortunately, on both these arches > Jakub> kernel defaults to executable stack as I found out today and > Jakub> thus there can be programs which rely on this and so for > Jakub> binary compatibility need to be assumed as needing executable > Jakub> stack too. > >Why do you say this? Also for PPC64 : 000001ff7fffd000-000001ff80000000 rw-p ffffffffffffe000 00:00 0 From jakub@redhat.com Thu Sep 25 12:42:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 25 Sep 2003 12:42:00 -0000 Subject: [PATCH] Fix syslog(3) in non-C non-US locales Message-ID: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> Hi! According to http://www.ietf.org/rfc/rfc3164.txt syslog is supposed to write to the pipe %h %e %T hostname in C locale. But glibc is writing %h %e %T time in current locale's format, which does not comply (and e.g. for CJK locales where some abmon names start with space it even confuses syslogd so much to print date twice). 2003-09-25 Jakub Jelinek * misc/syslog.c: Include locale.h. (vsyslog): Add date always in C locale %h %e %T format. --- libc/misc/syslog.c.jj 2003-07-15 11:04:37.000000000 -0400 +++ libc/misc/syslog.c 2003-09-25 08:25:50.000000000 -0400 @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 #include #include #include +#include #if __STDC__ #include @@ -187,10 +188,11 @@ vsyslog(pri, fmt, ap) prioff = fprintf (f, "<%d>", pri); (void) time (&now); #ifdef USE_IN_LIBIO - f->_IO_write_ptr += strftime (f->_IO_write_ptr, - f->_IO_write_end - f->_IO_write_ptr, - "%h %e %T ", - __localtime_r (&now, &now_tm)); + f->_IO_write_ptr += strftime_l (f->_IO_write_ptr, + f->_IO_write_end - f->_IO_write_ptr, + "%h %e %T ", + __localtime_r (&now, &now_tm), + &_nl_C_locobj); #else f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp, "%h %e %T ", __localtime_r (&now, &now_tm)); Jakub From schwab@suse.de Thu Sep 25 13:15:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Thu, 25 Sep 2003 13:15:00 -0000 Subject: [PATCH] Fix syslog(3) in non-C non-US locales In-Reply-To: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Thu, 25 Sep 2003 12:40:24 +0200") References: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > --- libc/misc/syslog.c.jj 2003-07-15 11:04:37.000000000 -0400 > +++ libc/misc/syslog.c 2003-09-25 08:25:50.000000000 -0400 > @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 > #include > #include > #include > +#include > > #if __STDC__ > #include > @@ -187,10 +188,11 @@ vsyslog(pri, fmt, ap) > prioff = fprintf (f, "<%d>", pri); > (void) time (&now); > #ifdef USE_IN_LIBIO > - f->_IO_write_ptr += strftime (f->_IO_write_ptr, > - f->_IO_write_end - f->_IO_write_ptr, > - "%h %e %T ", > - __localtime_r (&now, &now_tm)); > + f->_IO_write_ptr += strftime_l (f->_IO_write_ptr, s/strftime_l/__strftime_l/? Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N??rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From jakub@redhat.com Thu Sep 25 13:17:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 25 Sep 2003 13:17:00 -0000 Subject: [PATCH] Fix syslog(3) in non-C non-US locales In-Reply-To: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> References: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> Message-ID: <20030925111522.GO12344@sunsite.ms.mff.cuni.cz> On Thu, Sep 25, 2003 at 12:40:24PM +0200, Jakub Jelinek wrote: > Hi! > > According to http://www.ietf.org/rfc/rfc3164.txt > syslog is supposed to write to the pipe > %h %e %T hostname > in C locale. > But glibc is writing %h %e %T time in current locale's format, which > does not comply (and e.g. for CJK locales where some abmon names > start with space it even confuses syslogd so much to print date twice). Just noticed it eats unnecessary .plt slot. Here is a better patch: 2003-09-25 Jakub Jelinek * misc/syslog.c: Include locale.h. (vsyslog): Add date always in C locale %h %e %T format. --- libc/misc/syslog.c.jj 2003-07-15 11:04:37.000000000 -0400 +++ libc/misc/syslog.c 2003-09-25 09:07:29.000000000 -0400 @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 #include #include #include +#include #if __STDC__ #include @@ -187,10 +188,11 @@ vsyslog(pri, fmt, ap) prioff = fprintf (f, "<%d>", pri); (void) time (&now); #ifdef USE_IN_LIBIO - f->_IO_write_ptr += strftime (f->_IO_write_ptr, - f->_IO_write_end - f->_IO_write_ptr, - "%h %e %T ", - __localtime_r (&now, &now_tm)); + f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr, + f->_IO_write_end - f->_IO_write_ptr, + "%h %e %T ", + __localtime_r (&now, &now_tm), + &_nl_C_locobj); #else f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp, "%h %e %T ", __localtime_r (&now, &now_tm)); Jakub From jakub@redhat.com Thu Sep 25 13:18:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 25 Sep 2003 13:18:00 -0000 Subject: [PATCH] Fix syslog(3) in non-C non-US locales In-Reply-To: References: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> Message-ID: <20030925111547.GP12344@sunsite.ms.mff.cuni.cz> On Thu, Sep 25, 2003 at 03:15:34PM +0200, Andreas Schwab wrote: > > #ifdef USE_IN_LIBIO > > - f->_IO_write_ptr += strftime (f->_IO_write_ptr, > > - f->_IO_write_end - f->_IO_write_ptr, > > - "%h %e %T ", > > - __localtime_r (&now, &now_tm)); > > + f->_IO_write_ptr += strftime_l (f->_IO_write_ptr, > > s/strftime_l/__strftime_l/? Just posted that... Jakub From drepper@redhat.com Thu Sep 25 15:51:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 25 Sep 2003 15:51:00 -0000 Subject: [PATCH] Fix syslog(3) in non-C non-US locales In-Reply-To: <20030925111522.GO12344@sunsite.ms.mff.cuni.cz> References: <20030925104024.GN12344@sunsite.ms.mff.cuni.cz> <20030925111522.GO12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F730EC6.9060806@redhat.com> Jakub Jelinek wrote: > 2003-09-25 Jakub Jelinek > > * misc/syslog.c: Include locale.h. > (vsyslog): Add date always in C locale %h %e %T format. Applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From schwab@suse.de Fri Sep 26 08:35:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Fri, 26 Sep 2003 08:35:00 -0000 Subject: Fix sigprocmask call in ia64/getcontext Message-ID: When setcontext was fixed the same bug in getcontext was left alone. Andreas. 2003-09-26 Andreas Schwab * sysdeps/unix/sysv/linux/ia64/getcontext.S: Pass fourth argument to rt_sigprocmask system call. --- sysdeps/unix/sysv/linux/ia64/getcontext.S.~1.7.~ 2003-03-28 10:11:41.000000000 +0100 +++ sysdeps/unix/sysv/linux/ia64/getcontext.S 2003-09-26 10:25:18.000000000 +0200 @@ -35,7 +35,7 @@ ENTRY(__getcontext) .prologue - alloc r16 = ar.pfs, 1, 0, 3, 0 + alloc r16 = ar.pfs, 1, 0, 4, 0 // sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask): @@ -45,6 +45,7 @@ ENTRY(__getcontext) mov out0 = SIG_BLOCK mov out1 = 0 add out2 = r2, in0 + mov out3 = 8 // sizeof kernel sigset_t break __BREAK_SYSCALL flushrs // save dirty partition on rbs -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N??rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From drepper@redhat.com Fri Sep 26 08:42:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 Sep 2003 08:42:00 -0000 Subject: Fix sigprocmask call in ia64/getcontext In-Reply-To: References: Message-ID: <3F73FBED.7000608@redhat.com> Andreas Schwab wrote: > When setcontext was fixed the same bug in getcontext was left alone. Thanks, applied. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From aj@suse.de Fri Sep 26 16:51:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 Sep 2003 16:51:00 -0000 Subject: Convert prototypes to ISO C90 Message-ID: Here's a trivial patch to convert some prototypes to ISO C90. Ok to commit? Andreas 2003-09-26 Andreas Jaeger * intl/loadmsgcat.c: Convert prototypes to ISO C90. * ctype/isctype.c (__isctype): Likewise. * intl/bindtextdom.c: Likewise. * intl/dcgettext.c (DCGETTEXT): Likewise. * intl/dcigettext.c: Likewise. * intl/dcngettext.c (DCNGETTEXT): Likewise. * intl/dgettext.c (DGETTEXT): Likewise. * intl/finddomain.c (_nl_find_domain): Likewise. * intl/localealias.c: Likewise. * intl/ngettext.c (NGETTEXT): Likewise. * intl/plural-eval.c (plural_eval): Likewise. * locale/nl_langinfo.c (__nl_langinfo_l): Likewise. ============================================================ Index: intl/bindtextdom.c --- intl/bindtextdom.c 11 Dec 2002 22:58:28 -0000 1.21 +++ intl/bindtextdom.c 26 Sep 2003 16:50:55 -0000 @@ -1,5 +1,5 @@ /* Implementation of the bindtextdomain(3) function - Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995-1998,2000,2001,2002,2003 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 @@ -99,10 +99,8 @@ static void set_binding_values PARAMS (( If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither modified nor returned. */ static void -set_binding_values (domainname, dirnamep, codesetp) - const char *domainname; - const char **dirnamep; - const char **codesetp; +set_binding_values (const char *domainname, const char **dirnamep, + const char **codesetp) { struct binding *binding; int modified; @@ -349,9 +347,7 @@ set_binding_values (domainname, dirnamep /* Specify that the DOMAINNAME message catalog will be found in DIRNAME rather than in the system locale data base. */ char * -BINDTEXTDOMAIN (domainname, dirname) - const char *domainname; - const char *dirname; +BINDTEXTDOMAIN (const char *domainname, const char *dirname) { set_binding_values (domainname, &dirname, NULL); return (char *) dirname; @@ -360,9 +356,7 @@ BINDTEXTDOMAIN (domainname, dirname) /* Specify the character encoding in which the messages from the DOMAINNAME message catalog will be returned. */ char * -BIND_TEXTDOMAIN_CODESET (domainname, codeset) - const char *domainname; - const char *codeset; +BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset) { set_binding_values (domainname, NULL, &codeset); return (char *) codeset; ============================================================ Index: intl/dcgettext.c --- intl/dcgettext.c 11 Dec 2002 22:58:28 -0000 1.35 +++ intl/dcgettext.c 26 Sep 2003 16:50:55 -0000 @@ -1,5 +1,5 @@ /* Implementation of the dcgettext(3) function. - Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995-1999,2000,2001,2002,2003 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 @@ -45,10 +45,7 @@ /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ char * -DCGETTEXT (domainname, msgid, category) - const char *domainname; - const char *msgid; - int category; +DCGETTEXT (const char *domainname, const char *msgid, int category) { return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category); } ============================================================ Index: intl/dcigettext.c --- intl/dcigettext.c 11 Jun 2003 21:45:34 -0000 1.45 +++ intl/dcigettext.c 26 Sep 2003 16:50:56 -0000 @@ -380,13 +380,8 @@ static int enable_secure; CATEGORY locale and, if PLURAL is nonzero, search over string depending on the plural form determined by N. */ char * -DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) - const char *domainname; - const char *msgid1; - const char *msgid2; - int plural; - unsigned long int n; - int category; +DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, + int plural, unsigned long int n, int category) { #ifndef HAVE_ALLOCA struct block_list *block_list = NULL; @@ -668,11 +663,9 @@ DCIGETTEXT (domainname, msgid1, msgid2, char * internal_function -_nl_find_msg (domain_file, domainbinding, msgid, lengthp) - struct loaded_l10nfile *domain_file; - struct binding *domainbinding; - const char *msgid; - size_t *lengthp; +_nl_find_msg (struct loaded_l10nfile *domain_file, + struct binding *domainbinding, + const char *msgid, size_t *lengthp) { struct loaded_domain *domain; nls_uint32 nstrings; @@ -979,11 +972,8 @@ _nl_find_msg (domain_file, domainbinding /* Look up a plural variant. */ static char * internal_function -plural_lookup (domain, n, translation, translation_len) - struct loaded_l10nfile *domain; - unsigned long int n; - const char *translation; - size_t translation_len; +plural_lookup (struct loaded_l10nfile *domain, unsigned long int n, + const char *translation, size_t translation_len) { struct loaded_domain *domaindata = (struct loaded_domain *) domain->data; unsigned long int index; ============================================================ Index: intl/dcngettext.c --- intl/dcngettext.c 11 Dec 2002 22:58:28 -0000 1.7 +++ intl/dcngettext.c 26 Sep 2003 16:50:56 -0000 @@ -1,5 +1,5 @@ /* Implementation of the dcngettext(3) function. - Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001, 2002, 2003 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 @@ -45,12 +45,8 @@ /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ char * -DCNGETTEXT (domainname, msgid1, msgid2, n, category) - const char *domainname; - const char *msgid1; - const char *msgid2; - unsigned long int n; - int category; +DCNGETTEXT (const char *domainname, const char *msgid1, const char *msgid2, + unsigned long int n, int category) { return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category); } ============================================================ Index: intl/dgettext.c --- intl/dgettext.c 11 Dec 2002 22:58:28 -0000 1.10 +++ intl/dgettext.c 26 Sep 2003 16:50:56 -0000 @@ -1,5 +1,5 @@ /* Implementation of the dgettext(3) function. - Copyright (C) 1995-1997, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997,2000,2001,2002,2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -47,9 +47,7 @@ /* Look up MSGID in the DOMAINNAME message catalog of the current LC_MESSAGES locale. */ char * -DGETTEXT (domainname, msgid) - const char *domainname; - const char *msgid; +DGETTEXT (const char *domainname, const char *msgid) { return DCGETTEXT (domainname, msgid, LC_MESSAGES); } ============================================================ Index: intl/finddomain.c --- intl/finddomain.c 1 Nov 2002 20:43:55 -0000 1.29 +++ intl/finddomain.c 26 Sep 2003 16:50:56 -0000 @@ -1,5 +1,5 @@ /* Handle list of needed message catalogs - Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper , 1995. @@ -48,11 +48,8 @@ static struct loaded_l10nfile *_nl_loade established bindings. */ struct loaded_l10nfile * internal_function -_nl_find_domain (dirname, locale, domainname, domainbinding) - const char *dirname; - char *locale; - const char *domainname; - struct binding *domainbinding; +_nl_find_domain (const char *dirname, char *locale, const char *domainname, + struct binding *domainbinding) { struct loaded_l10nfile *retval; const char *language; ============================================================ Index: intl/loadmsgcat.c --- intl/loadmsgcat.c 3 Sep 2003 17:44:46 -0000 1.49 +++ intl/loadmsgcat.c 26 Sep 2003 16:50:56 -0000 @@ -485,8 +485,7 @@ int _nl_msg_cat_cntr; /* Expand a system dependent string segment. Return NULL if unsupported. */ static const char * -get_sysdep_segment_value (name) - const char *name; +get_sysdep_segment_value (const char *name) { /* Test for an ISO C 99 section 7.8.1 format string directive. Syntax: @@ -743,10 +742,9 @@ get_sysdep_segment_value (name) Return the header entry. */ const char * internal_function -_nl_init_domain_conv (domain_file, domain, domainbinding) - struct loaded_l10nfile *domain_file; - struct loaded_domain *domain; - struct binding *domainbinding; +_nl_init_domain_conv (struct loaded_l10nfile *domain_file, + struct loaded_domain *domain, + struct binding *domainbinding) { /* Find out about the character set the file is encoded with. This can be found (in textual form) in the entry "". If this @@ -862,8 +860,7 @@ _nl_init_domain_conv (domain_file, domai /* Frees the codeset dependent parts of an opened message catalog. */ void internal_function -_nl_free_domain_conv (domain) - struct loaded_domain *domain; +_nl_free_domain_conv (struct loaded_domain *domain) { if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1) free (domain->conv_tab); @@ -883,9 +880,7 @@ _nl_free_domain_conv (domain) message catalog do nothing. */ void internal_function -_nl_load_domain (domain_file, domainbinding) - struct loaded_l10nfile *domain_file; - struct binding *domainbinding; +_nl_load_domain (struct loaded_l10nfile *domain_file, struct binding *domainbinding) { int fd; size_t size; @@ -1280,8 +1275,7 @@ _nl_load_domain (domain_file, domainbind #ifdef _LIBC void internal_function -_nl_unload_domain (domain) - struct loaded_domain *domain; +_nl_unload_domain (struct loaded_domain *domain) { if (domain->plural != &__gettext_germanic_plural) __gettext_free_exp (domain->plural); ============================================================ Index: intl/localealias.c --- intl/localealias.c 4 Sep 2003 08:25:12 -0000 1.42 +++ intl/localealias.c 26 Sep 2003 16:50:56 -0000 @@ -130,16 +130,15 @@ static size_t maxmap; /* Prototypes for local functions. */ -static size_t read_alias_file PARAMS ((const char *fname, int fname_len)) +static size_t read_alias_file (const char *fname, int fname_len) internal_function; -static int extend_alias_table PARAMS ((void)); -static int alias_compare PARAMS ((const struct alias_map *map1, - const struct alias_map *map2)); +static int extend_alias_table (void); +static int alias_compare (const struct alias_map *map1, + const struct alias_map *map2); const char * -_nl_expand_alias (name) - const char *name; +_nl_expand_alias (const char *name) { static const char *locale_alias_path = LOCALE_ALIAS_PATH; struct alias_map *retval; @@ -201,9 +200,7 @@ _nl_expand_alias (name) static size_t internal_function -read_alias_file (fname, fname_len) - const char *fname; - int fname_len; +read_alias_file (const char *fname, int fname_len) { FILE *fp; char *full_fname; @@ -362,7 +359,7 @@ read_alias_file (fname, fname_len) static int -extend_alias_table () +extend_alias_table (void) { size_t new_size; struct alias_map *new_map; @@ -381,9 +378,7 @@ extend_alias_table () static int -alias_compare (map1, map2) - const struct alias_map *map1; - const struct alias_map *map2; +alias_compare (const struct alias_map *map1, const struct alias_map *map2) { #if defined _LIBC || defined HAVE_STRCASECMP return strcasecmp (map1->alias, map2->alias); ============================================================ Index: intl/ngettext.c --- intl/ngettext.c 11 Dec 2002 22:58:28 -0000 1.10 +++ intl/ngettext.c 26 Sep 2003 16:50:56 -0000 @@ -1,5 +1,5 @@ /* Implementation of ngettext(3) function. - Copyright (C) 1995, 1997, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2000, 2001, 2002, 2003 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 @@ -55,10 +55,7 @@ LC_MESSAGES locale. If not found, returns MSGID itself (the default text). */ char * -NGETTEXT (msgid1, msgid2, n) - const char *msgid1; - const char *msgid2; - unsigned long int n; +NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n) { return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES); } ============================================================ Index: intl/plural-eval.c --- intl/plural-eval.c 27 Nov 2001 22:52:33 -0000 1.1 +++ intl/plural-eval.c 26 Sep 2003 16:50:57 -0000 @@ -1,5 +1,5 @@ /* Plural expression evaluation. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,9 +23,7 @@ static unsigned long int plural_eval (st static unsigned long int internal_function -plural_eval (pexp, n) - struct expression *pexp; - unsigned long int n; +plural_eval (struct expression *pexp, unsigned long int n) { switch (pexp->nargs) { ============================================================ Index: ctype/isctype.c --- ctype/isctype.c 1 Sep 2002 18:24:55 -0000 1.1 +++ ctype/isctype.c 26 Sep 2003 16:50:57 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 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 @@ -21,9 +21,7 @@ #undef __isctype int -__isctype (ch, mask) - int ch; - int mask; +__isctype (int ch, int mask) { return (((uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128) [(int) (ch)] & mask); ============================================================ Index: locale/nl_langinfo.c --- locale/nl_langinfo.c 29 Aug 2002 02:17:54 -0000 1.16 +++ locale/nl_langinfo.c 26 Sep 2003 16:50:57 -0000 @@ -1,5 +1,5 @@ /* User interface for extracting locale-dependent parameters. - Copyright (C) 1995,96,97,99,2000,01,02 Free Software Foundation, Inc. + Copyright (C) 1995,96,97,99,2000,01,02,03 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,13 +28,10 @@ #ifdef USE_IN_EXTENDED_LOCALE_MODEL char * -__nl_langinfo_l (item, l) - nl_item item; - __locale_t l; +__nl_langinfo_l (nl_item item, __locale_t l) #else char * -nl_langinfo (item) - nl_item item; +nl_langinfo (nl_item item) #endif { int category = _NL_ITEM_CATEGORY (item); -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From drepper@redhat.com Fri Sep 26 17:12:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 Sep 2003 17:12:00 -0000 Subject: Convert prototypes to ISO C90 In-Reply-To: References: Message-ID: <3F74735E.1020303@redhat.com> Andreas Jaeger wrote: > Here's a trivial patch to convert some prototypes to ISO C90. Why? -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From aj@suse.de Fri Sep 26 17:59:00 2003 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 Sep 2003 17:59:00 -0000 Subject: Convert prototypes to ISO C90 In-Reply-To: <3F74735E.1020303@redhat.com> (Ulrich Drepper's message of "Fri, 26 Sep 2003 10:11:58 -0700") References: <3F74735E.1020303@redhat.com> Message-ID: Ulrich Drepper writes: > Andreas Jaeger wrote: >> Here's a trivial patch to convert some prototypes to ISO C90. > > > Why? They avoid redundancy (variable is only used once) and are clearer IMHO, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From drepper@redhat.com Fri Sep 26 18:05:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 Sep 2003 18:05:00 -0000 Subject: Convert prototypes to ISO C90 In-Reply-To: References: <3F74735E.1020303@redhat.com> Message-ID: <3F747FF3.40201@redhat.com> Andreas Jaeger wrote: > They avoid redundancy (variable is only used once) and are clearer IMHO, The reason why in many places K&R is used is to get exactly the right level of warnings re missing prototypes. Leave it as is, there is no reason to change it. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From davidm@napali.hpl.hp.com Sat Sep 27 04:21:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Sat, 27 Sep 2003 04:21:00 -0000 Subject: support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub Message-ID: <200309270421.h8R4LTKs031759@napali.hpl.hp.com> The patch below is relative to the CVS sysdep.h and adds support for doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall stubs (which enable light-weight system calls). It's hasn't been thoroughly tested (I'm just about to go on a trip and wanted to getthis out), but it ought to work in theory and it has held up so far. With this patch, the number of "break" syscalls in libc.so drops from ~160 down to about 40 and those that are left probably won't go away (they're in places where the new syscall stubs can't be used, e.g., clone2()). Ian, do you think you could make the equivalent changes for your NPTL-enabled libc packages? --david diff -u -r1.17 sysdep.h --- sysdeps/unix/sysv/linux/ia64/sysdep.h 16 Aug 2003 08:00:24 -0000 1.17 +++ sysdeps/unix/sysv/linux/ia64/sysdep.h 27 Sep 2003 04:12:02 -0000 @@ -23,6 +23,7 @@ #include #include +#include /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h @@ -95,9 +96,32 @@ cmp.eq p6,p0=-1,r10; \ (p6) br.cond.spnt.few __syscall_error; -#define DO_CALL(num) \ +#define DO_CALL_VIA_BREAK(num) \ mov r15=num; \ - break __BREAK_SYSCALL; + break __BREAK_SYSCALL + +#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread) + +/* Use the lightweight stub only if (a) we have a suitably modern + thread-control block (HAVE_TLS_SUPPORT) and (b) we're not compiling + the runtime loader (which might do syscalls before being fully + relocated). */ + +#define DO_CALL(num) \ + .prologue; \ + adds r2 = SYSINFO_OFFSET, r13;; \ + ld8 r2 = [r2]; \ + .save ar.pfs, r11; \ + mov r11 = ar.pfs;; \ + .body; \ + mov r15 = num; \ + mov b7 = r2; \ + br.call.sptk.many b6 = b7;; \ + .restore sp; \ + mov ar.pfs = r11 +#else +#define DO_CALL(num) DO_CALL_VIA_BREAK(num) +#endif #undef PSEUDO_END #define PSEUDO_END(name) .endp C_SYMBOL_NAME(name); @@ -144,6 +168,47 @@ (non-negative) errno on error or the return value on success. */ #undef INLINE_SYSCALL +#undef INTERNAL_SYSCALL +#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread) + +#define DO_INLINE_SYSCALL(name, nr, args...) \ + register long _r8 __asm ("r8"); \ + register long _r10 __asm ("r10"); \ + register long _r15 __asm ("r15") = __NR_##name; \ + long _retval; \ + LOAD_ARGS_##nr (args); \ + /* \ + * Don't specify any unwind info here. We mark ar.pfs as clobbered. This will force \ + * the compiler to save ar.pfs somewhere and emit appropriate unwind info for that \ + * save. \ + */ \ + __asm __volatile ("adds r2 = -8, r13;;\n" \ + "ld8 r2 = [r2];;\n" \ + "mov b7=r2;\n" \ + "br.call.sptk.many b6=b7;;\n" \ + : "=r" (_r8), "=r" (_r10), "=r" (_r15) ASM_OUTARGS_##nr \ + : "2" (_r15) ASM_ARGS_##nr \ + : "memory", "ar.pfs" ASM_CLOBBERS_##nr); \ + _retval = _r8; + +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL(name, nr, args) \ + if (_r10 == -1) \ + { \ + __set_errno (_retval); \ + _retval = -1; \ + } \ + _retval; }) + +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL(name, nr, args) \ + err = _r10; \ + _retval; }) + +#else /* !new syscall-stub */ + #define INLINE_SYSCALL(name, nr, args...) \ ({ \ register long _r8 asm ("r8"); \ @@ -164,10 +229,6 @@ } \ _retval; }) -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long int err - -#undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ \ register long _r8 asm ("r8"); \ @@ -183,6 +244,11 @@ _retval = _r8; \ err = _r10; \ _retval; }) + +#endif /* !new syscall-stub */ + +#undef INTERNAL_SYSCALL_DECL +#define INTERNAL_SYSCALL_DECL(err) long int err #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1) From jakub@redhat.com Mon Sep 29 22:22:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 29 Sep 2003 22:22:00 -0000 Subject: [PATCH] Quiet warnings in sys/sysmacros.h with -pedantic Message-ID: <20030929202023.GT12344@sunsite.ms.mff.cuni.cz> Hi! 2003-09-30 Jakub Jelinek * sysdeps/unix/sysv/linux/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor, gnu_dev_makedev): Add __extension__. --- libc/sysdeps/unix/sysv/linux/sys/sysmacros.h 29 Sep 2003 21:54:15 -0000 1.13 +++ libc/sysdeps/unix/sysv/linux/sys/sysmacros.h 29 Sep 2003 22:20:43 -0000 @@ -26,28 +26,27 @@ not going to hack weird hacks to support the dev_t representation they need. */ #ifdef __GLIBC_HAVE_LONG_LONG -extern __inline unsigned int gnu_dev_major (unsigned long long int __dev) - __THROW; -extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev) - __THROW; -extern __inline unsigned long long int gnu_dev_makedev (unsigned int __major, - unsigned int __minor) - __THROW; +__extension__ extern __inline unsigned int + gnu_dev_major (unsigned long long int __dev) __THROW; +__extension__ extern __inline unsigned int + gnu_dev_minor (unsigned long long int __dev) __THROW; +__extension__ extern __inline unsigned long long int + gnu_dev_makedev (unsigned int __major, unsigned int __minor) __THROW; # if defined __GNUC__ && __GNUC__ >= 2 -extern __inline unsigned int +__extension__ extern __inline unsigned int gnu_dev_major (unsigned long long int __dev) __THROW { return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); } -extern __inline unsigned int +__extension__ extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev) __THROW { return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); } -extern __inline unsigned long long int +__extension__ extern __inline unsigned long long int gnu_dev_makedev (unsigned int __major, unsigned int __minor) __THROW { return ((__minor & 0xff) | ((__major & 0xfff) << 8) Jakub From drepper@redhat.com Tue Sep 30 23:58:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 30 Sep 2003 23:58:00 -0000 Subject: support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub In-Reply-To: <200309270421.h8R4LTKs031759@napali.hpl.hp.com> References: <200309270421.h8R4LTKs031759@napali.hpl.hp.com> Message-ID: <3F7A1874.5020609@redhat.com> David Mosberger wrote: > The patch below is relative to the CVS sysdep.h and adds support for > doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall > stubs No, it doesn't. The patch is very incomplete. Try again, after testing. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `---------------------------