From 7c3164bc6650ceeecd67841dfb8fcf399d12a93f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 18 Jun 2004 04:29:42 +0000 Subject: [PATCH] Update. 2004-06-17 Ulrich Drepper * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait): Also check for negativ nanoseconds. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S (__pthread_cond_timedwait): Check for invalid nanosecond in timeout value. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. * tst-cond19.c: New file. * Makefile: Add rules to build and run tst-cond19. --- nptl/ChangeLog | 11 ++++ nptl/Makefile | 4 +- nptl/sysdeps/pthread/pthread_cond_timedwait.c | 2 +- .../sysv/linux/i386/i486/pthread_cond_timedwait.S | 4 ++ .../sysv/linux/x86_64/pthread_cond_timedwait.S | 5 ++ nptl/tst-cond19.c | 76 ++++++++++++++++++++++ sysdeps/powerpc/powerpc64/memcpy.S | 12 ++-- sysdeps/unix/sysv/linux/sched_setaffinity.c | 9 ++- 8 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 nptl/tst-cond19.c diff --git a/nptl/ChangeLog b/nptl/ChangeLog index a835cf6..2cf0063 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,14 @@ +2004-06-17 Ulrich Drepper + + * sysdeps/pthread/pthread_cond_timedwait.c + (__pthread_cond_timedwait): Also check for negativ nanoseconds. + * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S + (__pthread_cond_timedwait): Check for invalid nanosecond in + timeout value. + * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. + * tst-cond19.c: New file. + * Makefile: Add rules to build and run tst-cond19. + 2004-06-15 Steven Munroe * tst-context1.c (GUARD_PATTERN): Defined. diff --git a/nptl/Makefile b/nptl/Makefile index fd3ed9f..d2ae1b7 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -194,7 +194,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \ tst-spin1 tst-spin2 tst-spin3 \ tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \ tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \ - tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 \ + tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \ tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \ tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \ tst-rwlock11 tst-rwlock12 tst-rwlock13 \ @@ -454,6 +454,7 @@ $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library) ifeq (yes,$(build-shared)) $(objpfx)tst-cond11: $(common-objpfx)rt/librt.so +$(objpfx)tst-cond19: $(common-objpfx)rt/librt.so $(objpfx)tst-cancel17: $(common-objpfx)rt/librt.so $(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.so $(objpfx)tst-cancel18: $(common-objpfx)rt/librt.so @@ -465,6 +466,7 @@ LDFLAGS-tst-_res1mod2.so = -Wl,-soname,tst-_res1mod2.so $(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library) else $(objpfx)tst-cond11: $(common-objpfx)rt/librt.a +$(objpfx)tst-cond19: $(common-objpfx)rt/librt.a $(objpfx)tst-cancel17: $(common-objpfx)rt/librt.a $(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.a $(objpfx)tst-cancel18: $(common-objpfx)rt/librt.a diff --git a/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/nptl/sysdeps/pthread/pthread_cond_timedwait.c index 940b51b..7de2b29 100644 --- a/nptl/sysdeps/pthread/pthread_cond_timedwait.c +++ b/nptl/sysdeps/pthread/pthread_cond_timedwait.c @@ -50,7 +50,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) int result = 0; /* Catch invalid parameters. */ - if (abstime->tv_nsec >= 1000000000) + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) return EINVAL; /* Make sure we are along. */ diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S index 305fa4d..1d24b1a 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S @@ -55,6 +55,10 @@ __pthread_cond_timedwait: movl 20(%esp), %ebx movl 28(%esp), %ebp + cmpl $1000000000, 4(%ebp) + movl $EINVAL, %eax + jae 18f + /* Get internal lock. */ movl $1, %edx xorl %eax, %eax diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S index e75f05e..5c6a471 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S @@ -54,6 +54,11 @@ __pthread_cond_timedwait: #define FRAME_SIZE 80 subq $FRAME_SIZE, %rsp .Lsubq: + + cmpq $1000000000, 8(%rdx) + movl $EINVAL, %rax + jae 18f + /* Stack frame: rsp + 80 diff --git a/nptl/tst-cond19.c b/nptl/tst-cond19.c new file mode 100644 index 0000000..1c9bb7d --- /dev/null +++ b/nptl/tst-cond19.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2004. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + + +static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; + + +static int +do_test (void) +{ + int result = 0; + struct timespec ts; + + if (clock_gettime (CLOCK_REALTIME, &ts) != 0) + { + puts ("clock_gettime failed"); + return 1; + } + + ts.tv_nsec = -1; + + int e = pthread_cond_timedwait (&cond, &mut, &ts); + if (e == 0) + { + puts ("first cond_timedwait did not fail"); + result = 1; + } + else if (e != EINVAL) + { + puts ("first cond_timedwait did not return EINVAL"); + result = 1; + } + + ts.tv_nsec = 2000000000; + + e = pthread_cond_timedwait (&cond, &mut, &ts); + if (e == 0) + { + puts ("second cond_timedwait did not fail"); + result = 1; + } + else if (e != EINVAL) + { + puts ("second cond_timedwait did not return EINVAL"); + result = 1; + } + + return result; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/sysdeps/powerpc/powerpc64/memcpy.S b/sysdeps/powerpc/powerpc64/memcpy.S index c6d7645..f3448e0 100644 --- a/sysdeps/powerpc/powerpc64/memcpy.S +++ b/sysdeps/powerpc/powerpc64/memcpy.S @@ -79,6 +79,8 @@ EALIGN (BP_SYM (memcpy), 5, 0) rldicl. 0,12,0,61 cmpldi cr6,31,7 ble- cr6,.L2 /* less than 8 bytes left. */ + srdi 11,31,3 + andi. 10,12,7 bne- 0,.L6 /* Source is not DW aligned. */ srdi. 9,31,3 mr 10,3 @@ -164,19 +166,17 @@ EALIGN (BP_SYM (memcpy), 5, 0) ld 30,-16(1) blr + .align 4 .L6: - srdi 11,31,3 - mr 4,3 - mr 5,12 /* Copy doublewords where the destination is aligned but the source is not. Use aligned doubleword loads from the source, shifted to realign the data, to allow aligned destination stores. */ - andi. 10,5,7 + subf 5,10,12 andi. 0,11,1 - subf 5,10,5 - ld 6,0(5) sldi 10,10,3 + mr 4,3 + ld 6,0(5) ld 7,8(5) subfic 9,10,64 beq 2f diff --git a/sysdeps/unix/sysv/linux/sched_setaffinity.c b/sysdeps/unix/sysv/linux/sched_setaffinity.c index 36f73d4..5b1b8ee 100644 --- a/sysdeps/unix/sysv/linux/sched_setaffinity.c +++ b/sysdeps/unix/sysv/linux/sched_setaffinity.c @@ -60,9 +60,12 @@ __sched_setaffinity_new (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset) does not request to set a bit beyond that. */ for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt) if (((char *) cpuset)[cnt] != '\0') - /* Found a nonzero byte. This means the user request cannot be - fulfilled. */ - return EINVAL; + { + /* Found a nonzero byte. This means the user request cannot be + fulfilled. */ + __set_errno (EINVAL); + return -1; + } return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset); } -- 2.7.4