]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 18 Mar 2003 11:17:57 +0000 (11:17 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 18 Mar 2003 11:17:57 +0000 (11:17 +0000)
2003-03-18  Ulrich Drepper  <drepper@redhat.com>

* pthread_condattr_getclock.c: New file.
* pthread_condattr_setclock.c: New file.
* sysdeps/pthread/pthread.h: Declare these new functions.
* Versions [GLIBC_2.3.3] (libpthread): Add the new functions.
* Makefile (libpthread-routines): Add the new functions.
* sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_condattr):
Renamed field to value.  Document use of the bits.
* pthread_condattr_getpshared.c: Adjust for struct pthread_condattr
change.
* pthread_condattr_setpshared.c: Likewise.
* sysdeps/unix/sysv/linux/lowlevelcond.sym: Add cond_clock symbol.
* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
Add __clock field.
* sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
Implement clock selection.
* sysdeps/pthread/pthread_cond_timedwait.c: Likewise.
* pthread-errnos.sym: Add ENOSYS.
* sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
_POSIX_CLOCK_SELECTION.
* sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.

* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Remove
invalid .size directive.

22 files changed:
Versions.def
nptl/ChangeLog
nptl/Makefile
nptl/Versions
nptl/pthread-errnos.sym
nptl/pthread_condattr_getclock.c [new file with mode: 0644]
nptl/pthread_condattr_getpshared.c
nptl/pthread_condattr_setclock.c [new file with mode: 0644]
nptl/pthread_condattr_setpshared.c
nptl/sysdeps/pthread/pthread.h
nptl/sysdeps/pthread/pthread_cond_timedwait.c
nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h
nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/internaltypes.h
nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym
nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S

index 861863434fa01965099b11582e8893ec76bebe98..e8728b1986039d0ca29fec4f3d7f0f9de5760f6d 100644 (file)
@@ -73,6 +73,7 @@ libpthread {
   GLIBC_2.2.3
   GLIBC_2.2.6
   GLIBC_2.3.2
+  GLIBC_2.3.3
   GLIBC_PRIVATE
 }
 libresolv {
index 14e1e1c21ef21cb0c74311332926b16f48800b0c..579e9852985775078dedcb21b6ebd79ad7373dc0 100644 (file)
@@ -1,3 +1,33 @@
+2003-03-18  Ulrich Drepper  <drepper@redhat.com>
+
+       * pthread_condattr_getclock.c: New file.
+       * pthread_condattr_setclock.c: New file.
+       * sysdeps/pthread/pthread.h: Declare these new functions.
+       * Versions [GLIBC_2.3.3] (libpthread): Add the new functions.
+       * Makefile (libpthread-routines): Add the new functions.
+       * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_condattr):
+       Renamed field to value.  Document use of the bits.
+       * pthread_condattr_getpshared.c: Adjust for struct pthread_condattr
+       change.
+       * pthread_condattr_setpshared.c: Likewise.
+       * sysdeps/unix/sysv/linux/lowlevelcond.sym: Add cond_clock symbol.
+       * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+       Add __clock field.
+       * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+       * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+       * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+       * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+       Implement clock selection.
+       * sysdeps/pthread/pthread_cond_timedwait.c: Likewise.
+       * pthread-errnos.sym: Add ENOSYS.
+       * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+       _POSIX_CLOCK_SELECTION.
+       * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+
+       * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Remove
+       invalid .size directive.
+
 2003-03-17  Roland McGrath  <roland@redhat.com>
 
        * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait):
index b59ffd86bb007ae361bdd5b52e9ac99ec7d23be4..5c8676f26c632f86ab9625ef767e22a647016e5b 100644 (file)
@@ -76,6 +76,7 @@ libpthread-routines = init events version \
                      old_pthread_cond_signal old_pthread_cond_broadcast \
                      pthread_condattr_init pthread_condattr_destroy \
                      pthread_condattr_getpshared pthread_condattr_setpshared \
+                     pthread_condattr_getclock pthread_condattr_setclock \
                      pthread_spin_init pthread_spin_destroy \
                      pthread_spin_lock pthread_spin_trylock \
                      pthread_spin_unlock \
index c6346ef8b5fc03e78f91c4e4a4b46a54f219b27c..1d6e6b258263b92c21b7e9aecf6fbfb564dcca73 100644 (file)
@@ -206,6 +206,11 @@ libpthread {
     pthread_tryjoin_np; pthread_timedjoin_np;
   }
 
+  GLIBC_2.3.3 {
+    # Unix CS option.
+    pthread_condattr_getclock; pthread_condattr_setclock;
+  }
+
   GLIBC_PRIVATE {
     __pthread_initialize_minimal; __pthread_cleanup_upto;
     __pthread_clock_gettime; __pthread_clock_settime;
index a3289c6dcc666166053a94d1ad232f6c9c80a884..2bb4d0d3ca5e2c7ded345573990344be1db21fa2 100644 (file)
@@ -7,5 +7,6 @@ EBUSY           EBUSY
 EDEADLK                EDEADLK
 EINTR          EINTR
 EINVAL         EINVAL
+ENOSYS         ENOSYS
 ETIMEDOUT      ETIMEDOUT
 EWOULDBLOCK    EWOULDBLOCK
diff --git a/nptl/pthread_condattr_getclock.c b/nptl/pthread_condattr_getclock.c
new file mode 100644 (file)
index 0000000..f8be655
--- /dev/null
@@ -0,0 +1,31 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_condattr_getclock (attr, clock_id)
+     const pthread_condattr_t *attr;
+     clockid_t *clock_id;
+{
+  *clock_id = ((((const struct pthread_condattr *) attr)->value) & 0xfe) >> 1;
+
+  return 0;
+}
index 7b91f14f46bd942c6d5a89884436c1ecdfec1b21..b44eac94e75d9a636a294536c52dd10e7bf2799c 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.
 
@@ -25,7 +25,7 @@ pthread_condattr_getpshared (attr, pshared)
      const pthread_condattr_t *attr;
      int *pshared;
 {
-  *pshared = ((const struct pthread_condattr *) attr)->pshared;
+  *pshared = ((const struct pthread_condattr *) attr)->value & 1;
 
   return 0;
 }
diff --git a/nptl/pthread_condattr_setclock.c b/nptl/pthread_condattr_setclock.c
new file mode 100644 (file)
index 0000000..09488af
--- /dev/null
@@ -0,0 +1,66 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdbool.h>
+#include <time.h>
+#include <sysdep.h>
+#include "pthreadP.h"
+#include <kernel-features.h>
+
+
+int
+pthread_condattr_setclock (attr, clock_id)
+     pthread_condattr_t *attr;
+     clockid_t clock_id;
+{
+  /* Only a few clocks are allowed.  CLOCK_REALTIME is always allowed.
+     CLOCK_MONOTONIC only if the kernel has the necessary support.  */
+  if (clock_id == CLOCK_MONOTONIC)
+    {
+#ifndef __ASSUME_POSIX_TIMERS
+# ifdef __NR_clock_getres
+      /* Check whether the clock is available.  */
+      static int avail;
+
+      if (avail == 0)
+       {
+         struct timespec ts;
+
+         INTERNAL_SYSCALL_DECL (err);
+         int val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC,
+                                     &ts);
+         avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
+       }
+
+      if (avail < 0)
+# endif
+       /* Not available.  */
+       return EINVAL;
+#endif
+    }
+  else if (clock_id != CLOCK_REALTIME)
+    return EINVAL;
+
+  int *valuep = &((struct pthread_condattr *) attr)->value;
+
+  *valuep = (*valuep & ~0xfe) | (clock_id << 1);
+
+  return 0;
+}
index 518c1c791ea4399c70e20cc0ccc9577b3201d58e..f47afccef007f1a9625de5ddc3622e2ac9c728e7 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.
 
@@ -24,7 +24,9 @@ pthread_condattr_setpshared (attr, pshared)
      pthread_condattr_t *attr;
      int pshared;
 {
-  ((struct pthread_condattr *) attr)->pshared = pshared;
+  int *valuep = &((struct pthread_condattr *) attr)->value;
+
+  *valuep = (*valuep & ~1) | (pshared != 0);
 
   return 0;
 }
index 135b255a53020c50574e0cbdc7503ede8cff576c..36a996a66418cee459cd66f199e3df5ea0e55bc5 100644 (file)
@@ -602,6 +602,18 @@ extern int pthread_condattr_getpshared (__const pthread_condattr_t *
 extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
                                         int __pshared) __THROW;
 
+#ifdef __USE_XOPEN2K
+/* Get the clock selected for the conditon variable attribute ATTR.  */
+extern int pthread_condattr_getclock (__const pthread_condattr_t *
+                                     __restrict __attr,
+                                     __clockid_t *__restrict __clock_id)
+     __THROW;
+
+/* Set the clock selected for the conditon variable attribute ATTR.  */
+extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
+                                     __clockid_t __clock_id) __THROW;
+
+#endif
 
 
 #ifdef __USE_XOPEN2K
index af9929c500e24cf58b9f84ab8ce5d5014168ffc6..e0200b4cd8358d3a21a4e82f386bc82a0d0e9608 100644 (file)
@@ -92,14 +92,37 @@ __pthread_cond_timedwait (cond, mutex, abstime)
 
   while (1)
     {
+      struct timespec rt;
+#ifdef __NR_clock_gettime
+      INTERNAL_SYSCALL_DECL (err);
+      int val = INTERNAL_SYSCALL (clock_gettime, err, 2, cond->__data.__clock,
+                                 &ts);
+# ifndef __ASSUME_POSIX_TIMERS
+      if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (val, err), 0))
+       {
+         struct timeval tv;
+         (void) gettimeofday (&tv, NULL);
+
+         /* Convert the absolute timeout value to a relative timeout.  */
+         rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+         rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+       }
+      else
+# endif
+       {
+         /* Convert the absolute timeout value to a relative timeout.  */
+         rt.tv_sec = abstime->tv_sec - rt.tv_sec;
+         rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
+       }
+#else
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
       (void) gettimeofday (&tv, NULL);
 
       /* Convert the absolute timeout value to a relative timeout.  */
-      struct timespec rt;
       rt.tv_sec = abstime->tv_sec - tv.tv_sec;
       rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+#endif
       if (rt.tv_nsec < 0)
        {
          rt.tv_nsec += 1000000000;
index f40e3c633a2930b107f015968f4b496a92f8cd5f..2e2a6096252a143bc1397f9c4be0cbab080af0f5 100644 (file)
 /* The monotonic clock might be available.  */
 #define _POSIX_MONOTONIC_CLOCK 0
 
+/* The clock selection interfaces are available.  */
+#define _POSIX_CLOCK_SELECTION 200112L
+
 #endif /* posix_opt.h */
index ad50705d4f4ed425d22eec5b53fce16d535a0e46..556c5fd8738fed9cbed8c3009dc8abdf3e87634d 100644 (file)
 /* The monotonic clock might be available.  */
 #define _POSIX_MONOTONIC_CLOCK 0
 
+/* The clock selection interfaces are available.  */
+#define _POSIX_CLOCK_SELECTION 200112L
+
 #endif /* posix_opt.h */
index 756ece29e059567110270ef01993c6b3e7b330b3..c14f1b1ef631e894a2a35138730dec6b742e96a9 100644 (file)
@@ -74,6 +74,7 @@ typedef union
   struct
   {
     int __lock;
+    int __clock;
     unsigned long long int __total_seq;
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
index c1ce3bec1759e73d0ee1a9650fa35bfde5e0d17c..151018ce23c6c87fd36d582c2600be9106d7d013 100644 (file)
@@ -112,6 +112,29 @@ __pthread_cond_timedwait:
 
        /* Get the current time.  */
        movl    %ebx, %edx
+#ifdef __NR_clock_gettime
+       /* Get the clock number.  Note that the field in the condvar
+          structure stores the number minus 1.  */
+       movl    cond_clock(%ebx), %ebx
+       /* Only clocks 0 and 1 are allowed.  Both are handled in the
+          kernel.  */
+       leal    12(%esp), %ecx
+       movl    $__NR_clock_gettime, %eax
+       ENTER_KERNEL
+# ifndef __ASSUME_POSIX_TIMERS
+       cmpl    $-ENOSYS, %eax
+       je      19f
+# endif
+       movl    %edx, %ebx
+
+       /* Compute relative timeout.  */
+       movl    (%ebp), %ecx
+       movl    4(%ebp), %edx
+       subl    12(%esp), %ecx
+       subl    16(%esp), %edx
+#else
+       /* Get the current time.  */
+       movl    %ebx, %edx
        leal    12(%esp), %ebx
        xorl    %ecx, %ecx
        movl    $SYS_gettimeofday, %eax
@@ -126,6 +149,7 @@ __pthread_cond_timedwait:
        movl    4(%ebp), %edx
        subl    12(%esp), %ecx
        subl    %eax, %edx
+#endif
        jns     12f
        addl    $1000000000, %edx
        subl    $1, %ecx
@@ -133,7 +157,7 @@ __pthread_cond_timedwait:
        js      13f
 
        /* Store relative timeout.  */
-       movl    %ecx, 12(%esp)
+21:    movl    %ecx, 12(%esp)
        movl    %edx, 16(%esp)
        leal    12(%esp), %esi
        xorl    %ecx, %ecx      /* movl $FUTEX_WAIT, %ecx */
@@ -275,7 +299,30 @@ __pthread_cond_timedwait:
 
 17:    popl    %eax
        jmp     18b
-       .size   __pthread_cond_wait, .-__pthread_cond_wait
+
+#if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
+       /* clock_gettime not available.  */
+19:    leal    12(%esp), %ebx
+       xorl    %ecx, %ecx
+       movl    $SYS_gettimeofday, %eax
+       ENTER_KERNEL
+       movl    %edx, %ebx
+
+       /* Compute relative timeout.  */
+       movl    16(%esp), %eax
+       movl    $1000, %edx
+       mul     %edx            /* Milli seconds to nano seconds.  */
+       movl    (%ebp), %ecx
+       movl    4(%ebp), %edx
+       subl    12(%esp), %ecx
+       subl    %eax, %edx
+       jns     20f
+       addl    $1000000000, %edx
+       subl    $1, %ecx
+20:    testl   %ecx, %ecx
+       js      13b
+       jmp     21b
+#endif
        .size   __pthread_cond_timedwait, .-__pthread_cond_timedwait
 versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
                  GLIBC_2_3_2)
index ebe2818d4b1a992e9dd898c3e36771ceba3b22ea..5b4127c76b37e0a822afe4c6675cccfce399b69c 100644 (file)
@@ -74,6 +74,7 @@ typedef union
   struct
   {
     int __lock;
+    int __clock;
     unsigned long long int __total_seq;
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
index 9ae35eff9a14f89e28b8ffd22e8a7aa2f1bdacba..17d78e4b9f1c076b06aabc29c8d095c4f4b31103 100644 (file)
@@ -63,8 +63,13 @@ struct pthread_mutexattr
 /* Conditional variable attribute data structure.  */
 struct pthread_condattr
 {
-  /* Flag whether coditional variable will be shareable between processes.  */
-  int pshared;
+  /* Combination of values:
+
+     Bit 0  : flag whether coditional variable will be shareable between
+             processes.
+
+     Bit 1-7: clock ID.  */
+  int value;
 };
 
 
index 17c1825483e445d3998f90fd4c0cf738ee70d77d..5eb535e15700d135334945f63877889eead6b920 100644 (file)
@@ -4,6 +4,7 @@
 --
 
 cond_lock      offsetof (pthread_cond_t, __data.__lock)
+cond_clock     offsetof (pthread_cond_t, __data.__clock)
 total_seq      offsetof (pthread_cond_t, __data.__total_seq)
 wakeup_seq     offsetof (pthread_cond_t, __data.__wakeup_seq)
 woken_seq      offsetof (pthread_cond_t, __data.__woken_seq)
index 332f50f1a12548ae22446e9bd032e26c5769e2c5..728712a8c6ca4ebe70f1ffd36e715938f852d2fb 100644 (file)
@@ -89,7 +89,7 @@ typedef union
   struct
   {
     int __lock;
-    int __pad;
+    int __clock;
     unsigned long long int __total_seq;
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
index 7c207beb53fc6b54d9e2408afc2a1e140198218d..aae8e90cdcf870b33f1e9ff59aaf7fdd5101bddb 100644 (file)
@@ -88,6 +88,7 @@ typedef union
   struct
   {
     int __lock;
+    int __clock;
     unsigned long long int __total_seq;
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
index 97b94a3074113cc22ec074b739e770a4f9751946..09890d3a19eb6dc99a88c727c1a1a2fcd7fb81a4 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.
 
@@ -75,6 +75,7 @@ typedef union
   struct
   {
     int __lock;
+    int __clock;
     unsigned long long int __total_seq;
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
index 9da9af8d016c8aaaa6997aee294331a14d542b30..97a642e65eaf0109347639260c2e815d7709279d 100644 (file)
@@ -265,7 +265,6 @@ __pthread_cond_timedwait:
 
 17:    movq    (%rsp), %rax
        jmp     18b
-       .size   __pthread_cond_wait, .-__pthread_cond_wait
        .size   __pthread_cond_timedwait, .-__pthread_cond_timedwait
 versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait,
                  GLIBC_2_3_2)
This page took 0.072005 seconds and 5 git commands to generate.