From 86a9ee5e87cc084ccce131cd51166c98ea87f28f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 18 Mar 2003 11:17:57 +0000 Subject: Update. 2003-03-18 Ulrich Drepper * 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. --- nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h | 3 ++ nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h | 3 ++ .../unix/sysv/linux/i386/bits/pthreadtypes.h | 1 + .../sysv/linux/i386/i486/pthread_cond_timedwait.S | 51 +++++++++++++++++++++- .../unix/sysv/linux/ia64/bits/pthreadtypes.h | 1 + nptl/sysdeps/unix/sysv/linux/internaltypes.h | 9 +++- nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym | 1 + .../unix/sysv/linux/powerpc/bits/pthreadtypes.h | 2 +- .../unix/sysv/linux/s390/bits/pthreadtypes.h | 1 + .../sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h | 3 +- .../sysv/linux/x86_64/pthread_cond_timedwait.S | 1 - 11 files changed, 69 insertions(+), 7 deletions(-) (limited to 'nptl/sysdeps/unix/sysv') diff --git a/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h b/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h index f40e3c633a..2e2a609625 100644 --- a/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h +++ b/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h @@ -132,4 +132,7 @@ /* 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 */ diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h index ad50705d4f..556c5fd873 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/posix_opt.h @@ -138,4 +138,7 @@ /* 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 */ diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h index 756ece29e0..c14f1b1ef6 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h @@ -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; 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 c1ce3bec17..151018ce23 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 @@ -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) diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h index ebe2818d4b..5b4127c76b 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h @@ -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; diff --git a/nptl/sysdeps/unix/sysv/linux/internaltypes.h b/nptl/sysdeps/unix/sysv/linux/internaltypes.h index 9ae35eff9a..17d78e4b9f 100644 --- a/nptl/sysdeps/unix/sysv/linux/internaltypes.h +++ b/nptl/sysdeps/unix/sysv/linux/internaltypes.h @@ -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; }; diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym b/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym index 17c1825483..5eb535e157 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym @@ -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) diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h index 332f50f1a1..728712a8c6 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h @@ -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; diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h index 7c207beb53..aae8e90cdc 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h @@ -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; diff --git a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h index 97b94a3074..09890d3a19 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h @@ -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 , 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; 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 9da9af8d01..97a642e65e 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 @@ -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) -- cgit v1.2.3