]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sun, 16 Feb 2003 10:57:38 +0000 (10:57 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 16 Feb 2003 10:57:38 +0000 (10:57 +0000)
* tst-rwlock6.c: More pthread_rwlock_timedwrlock and
pthread_rwlock_timedrdlock tests.
* tst-rwlock7.c: More pthread_rwlock_timedwrlock tests.
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
Check for invalid tv_nsec field.
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
Likewise.

* pthread_mutex_trylock.c (__pthread_mutex_trylock): Protect
recursive mutex of overflow.

* tst-attr1.c (do_test): Add test for pthread_mutexattr_setpshared.

nptl/ChangeLog
nptl/pthread_mutex_trylock.c
nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
nptl/tst-attr1.c
nptl/tst-clock1.c
nptl/tst-rwlock6.c
nptl/tst-rwlock7.c
nptl/tst-umask1.c

index 7e611221a495650f2b3b4f5bded99a8c6122df39..72414b17ab09fd3542a4ca1e59b558ceed2e1ce8 100644 (file)
@@ -1,5 +1,18 @@
 2003-02-16  Ulrich Drepper  <drepper@redhat.com>
 
+       * tst-rwlock6.c: More pthread_rwlock_timedwrlock and
+       pthread_rwlock_timedrdlock tests.
+       * tst-rwlock7.c: More pthread_rwlock_timedwrlock tests.
+       * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+       Check for invalid tv_nsec field.
+       * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+       Likewise.
+
+       * pthread_mutex_trylock.c (__pthread_mutex_trylock): Protect
+       recursive mutex of overflow.
+
+       * tst-attr1.c (do_test): Add test for pthread_mutexattr_setpshared.
+
        * libc-cancellation.c (__libc_enable_asynccancel): Rwrite to avoid
        going into an endless loop.
        * Makefile (tests): Add tst-cancel9.
index aae506739f146bee4d9893453e00d8ac3bf1bc6e..394a9cba9b08693e99cb820483ee5da5f0d2cc91 100644 (file)
@@ -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.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -36,6 +36,10 @@ __pthread_mutex_trylock (mutex)
       if (mutex->__data.__owner == pd)
        {
          /* Just bump the counter.  */
+         if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+           /* Overflow of the counter.  */
+           return EAGAIN;
+
          ++mutex->__data.__count;
          return 0;
        }
index 97b94a3074113cc22ec074b739e770a4f9751946..756ece29e059567110270ef01993c6b3e7b330b3 100644 (file)
@@ -1,6 +1,5 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
index 2e99ac669a1e06a63ef28c89f9b6fd89bf15e11e..b275b8b9227188631fddf1685b0f147963c4890d 100644 (file)
@@ -27,6 +27,7 @@
 #define FUTEX_WAKE             1
 
 #define EAGAIN         11
+#define EINVAL         22
 #define EDEADLK                35
 #define ETIMEDOUT      110
 
@@ -71,7 +72,11 @@ pthread_rwlock_timedrdlock:
        cmpl    $0, FLAGS(%ebp)
        je      5f
 
-3:     incl    READERS_QUEUED(%ebp)
+       /* Check the value of the timeout parameter.  */
+3:     cmpl    $1000000000, 4(%edi)
+       jae     19f
+
+       incl    READERS_QUEUED(%ebp)
        je      4f
 
        LOCK
@@ -189,4 +194,7 @@ pthread_rwlock_timedrdlock:
 
 18:    movl    $ETIMEDOUT, %ecx
        jmp     9b
+
+19:    movl    $EINVAL, %ecx
+       jmp     9b
        .size   pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
index bf8f1d48db1e2de3c22ccd2878166b00e6efa073..ec8f4b9f6d7068cc9b2b91e3780128289a427ec1 100644 (file)
@@ -27,6 +27,7 @@
 #define FUTEX_WAKE             1
 
 #define EAGAIN         11
+#define EINVAL         22
 #define EDEADLK                35
 #define ETIMEDOUT      110
 
@@ -69,7 +70,11 @@ pthread_rwlock_timedwrlock:
        cmp     $0, NR_READERS(%ebp)
        je      5f
 
-3:     incl    WRITERS_QUEUED(%ebp)
+       /* Check the value of the timeout parameter.  */
+3:     cmpl    $1000000000, 4(%edi)
+       jae     19f
+
+       incl    WRITERS_QUEUED(%ebp)
        je      4f
 
        LOCK
@@ -156,7 +161,7 @@ pthread_rwlock_timedwrlock:
 
 14:    cmpl    %gs:8, %eax
        jne     3b
-       movl    $EDEADLK, %ecx
+20:    movl    $EDEADLK, %ecx
        jmp     9b
 
 6:     movl    %ebp, %eax
@@ -181,4 +186,7 @@ pthread_rwlock_timedwrlock:
 
 18:    movl    $ETIMEDOUT, %ecx
        jmp     9b
+
+19:    movl    $EINVAL, %ecx
+       jmp     9b
        .size   pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
index bfa7075018e4e80029e47d786c4b52f82f09626e..c5870beb5b7cc038457a1b0fa39a76e8dcf1b23b 100644 (file)
@@ -35,6 +35,14 @@ do_test (void)
       exit (1);
     }
 
+  pthread_mutexattr_t ma;
+
+  if (pthread_mutexattr_init (&ma) != 0)
+    {
+      puts ("mutexattr_init failed");
+      exit (1);
+    }
+
   /* XXX Remove if default value is clear.  */
   pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
   pthread_attr_setschedpolicy (&a, SCHED_OTHER);
@@ -143,6 +151,31 @@ contentionscope changed to %d by invalid setscope call\n", s);
              exit (1);
            }
        }
+
+      if (r != PTHREAD_PROCESS_PRIVATE && r != PTHREAD_PROCESS_SHARED)
+       {
+         int e = pthread_mutexattr_setpshared (&ma, r);
+
+         if (e == 0)
+           {
+             printf ("mutexattr_setpshared with value %ld succeeded\n", r);
+             exit (1);
+           }
+
+         int s;
+         if (pthread_mutexattr_getpshared (&ma, &s) != 0)
+           {
+             puts ("mutexattr_getpshared failed");
+             exit (1);
+           }
+
+         if (s != PTHREAD_PROCESS_PRIVATE)
+           {
+             printf ("\
+pshared changed to %d by invalid mutexattr_setpshared call\n", s);
+             exit (1);
+           }
+       }
     }
 
   return 0;
index e0ab3024d339f4a267169560060d61eede09e4a3..fbb5fa907e09afaed458a2ee2bc76066ab602037 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <pthread.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
 
index f0a96e89657b90c037d74e5d64308de09a424b45..ea7f4ba634f4efe2fd739fcd3debcb054c9e0ef0 100644 (file)
@@ -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.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -76,6 +76,24 @@ tf (void *arg)
       pthread_exit ((void *) 1l);
     }
 
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10;
+  /* Note that the following operation makes ts invalid.  */
+  ts.tv_nsec += 1000000000;
+
+  err = pthread_rwlock_timedrdlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("2nd timedrdlock succeeded");
+      pthread_exit ((void *) 1l);
+    }
+  if (err != EINVAL)
+    {
+      puts ("2nd timedrdlock did not return EINVAL");
+      pthread_exit ((void *) 1l);
+    }
+
   return NULL;
 }
 
@@ -128,6 +146,36 @@ do_test (void)
          exit (1);
        }
 
+      (void) gettimeofday (&tv, NULL);
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ++ts.tv_sec;
+      int e = pthread_rwlock_timedrdlock (&r, &ts);
+      if (e == 0)
+       {
+         puts ("timedrdlock succeeded");
+         exit (1);
+       }
+      if (e != EDEADLK)
+       {
+         puts ("timedrdlock did not return EDEADLK");
+         exit (1);
+       }
+
+      (void) gettimeofday (&tv, NULL);
+      TIMEVAL_TO_TIMESPEC (&tv, &ts);
+      ++ts.tv_sec;
+      e = pthread_rwlock_timedwrlock (&r, &ts);
+      if (e == 0)
+       {
+         puts ("2nd timedwrlock succeeded");
+         exit (1);
+       }
+      if (e != EDEADLK)
+       {
+         puts ("2nd timedwrlock did not return EDEADLK");
+         exit (1);
+       }
+
       pthread_t th;
       if (pthread_create (&th, NULL, tf, &r) != 0)
        {
index 41e5af3ba8e70257a97f3b372f608c0dfe265cf1..4d7af6ca77b2b275f99e1d3ef56552d10e6728bf 100644 (file)
@@ -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.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -76,6 +76,24 @@ tf (void *arg)
       pthread_exit ((void *) 1l);
     }
 
+  (void) gettimeofday (&tv, NULL);
+  TIMEVAL_TO_TIMESPEC (&tv, &ts);
+  ts.tv_sec += 10;
+  /* Note that the following operation makes ts invalid.  */
+  ts.tv_nsec += 1000000000;
+
+  err = pthread_rwlock_timedwrlock (r, &ts);
+  if (err == 0)
+    {
+      puts ("2nd timedwrlock succeeded");
+      pthread_exit ((void *) 1l);
+    }
+  if (err != EINVAL)
+    {
+      puts ("2nd timedwrlock did not return EINVAL");
+      pthread_exit ((void *) 1l);
+    }
+
   return NULL;
 }
 
@@ -124,7 +142,7 @@ do_test (void)
       /* Get a read lock.  */
       if (pthread_rwlock_timedrdlock (&r, &ts) != 0)
        {
-         printf ("round %d: rwlock_wrlock failed\n", cnt);
+         printf ("round %d: rwlock_timedrdlock failed\n", cnt);
          exit (1);
        }
 
index 22e3831b11e97bf937ab21e086facd13a5b4a4ab..42d2e6810cfbfe7014b1c8c91997f6776f47b377 100644 (file)
@@ -104,7 +104,7 @@ do_test (const char *fname)
   pthread_barrier_init (&bar, NULL, 2);
 
   pthread_t th;
-  if (pthread_create (&th, NULL, tf, fname) != 0)
+  if (pthread_create (&th, NULL, tf, (void *) fname) != 0)
     {
       puts ("cannot create thread");
       exit (1);