diff mbox

[v2] pthread_cond_timedwait: always use clock_gettime

Message ID 1451517369-2692-1-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno Dec. 30, 2015, 11:16 p.m. UTC
Since we require at least a 2.6.32 Linux kernel, the clock_gettime
syscall is always available for all architectures we support. Remove
the corresponding compatibility code.

	* nptl/pthread_cond_timedwait.c [!__NR_clock_gettime]
	(__pthread_cond_timedwait): Remove compatibility code.
	* sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
	[!__NR_clock_gettime] (__pthread_cond_timedwait): Likewise.
---
 ChangeLog                                             |  7 +++++++
 nptl/pthread_cond_timedwait.c                         | 10 ----------
 sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S | 18 ------------------
 3 files changed, 7 insertions(+), 28 deletions(-)

v1 -> v2: do the same cleanup on nptl/pthread_cond_timedwait.c as
suggested by Mike Frysinger.

Comments

Mike Frysinger Dec. 31, 2015, 12:58 a.m. UTC | #1
On 31 Dec 2015 00:16, Aurelien Jarno wrote:
> Since we require at least a 2.6.32 Linux kernel, the clock_gettime
> syscall is always available for all architectures we support. Remove
> the corresponding compatibility code.

OK
-mike
diff mbox

Patch

diff --git a/ChangeLog b/ChangeLog
index df00cb5..27a1237 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@ 
 2015-12-30  Aurelien Jarno  <aurelien@aurel32.net>
 
+	* nptl/pthread_cond_timedwait.c [!__NR_clock_gettime]
+	(__pthread_cond_timedwait): Remove compatibility code.
+	* sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
+	[!__NR_clock_gettime] (__pthread_cond_timedwait): Likewise.
+
+2015-12-30  Aurelien Jarno  <aurelien@aurel32.net>
+
 	* sysdeps/unix/sysv/linux/dl-openat64.c [!__NR_openat] (openat64):
 	Remove compatibility code.
 
diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c
index 10b0a61..10925f2 100644
--- a/nptl/pthread_cond_timedwait.c
+++ b/nptl/pthread_cond_timedwait.c
@@ -117,7 +117,6 @@  __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
      || !defined lll_futex_timed_wait_bitset)
       struct timespec rt;
       {
-# ifdef __NR_clock_gettime
 	INTERNAL_SYSCALL_DECL (err);
 	(void) INTERNAL_VSYSCALL (clock_gettime, err, 2,
 				  (cond->__data.__nwaiters
@@ -126,15 +125,6 @@  __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
 	/* 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.  */
-	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)
 	{
diff --git a/sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S b/sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
index 130c090..cd8931a 100644
--- a/sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
+++ b/sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
@@ -555,7 +555,6 @@  __pthread_cond_timedwait:
 
 	/* Get the current time.  */
 108:	movl	%ebx, %edx
-# ifdef __NR_clock_gettime
 	/* Get the clock number.  */
 	movl	cond_nwaiters(%ebx), %ebx
 	andl	$((1 << nwaiters_shift) - 1), %ebx
@@ -571,23 +570,6 @@  __pthread_cond_timedwait:
 	movl	4(%ebp), %edx
 	subl	24(%esp), %ecx
 	subl	28(%esp), %edx
-# else
-	/* Get the current time.  */
-	leal	24(%esp), %ebx
-	xorl	%ecx, %ecx
-	movl	$__NR_gettimeofday, %eax
-	ENTER_KERNEL
-	movl	%edx, %ebx
-
-	/* Compute relative timeout.  */
-	movl	28(%esp), %eax
-	movl	$1000, %edx
-	mul	%edx		/* Milli seconds to nano seconds.  */
-	movl	(%ebp), %ecx
-	movl	4(%ebp), %edx
-	subl	24(%esp), %ecx
-	subl	%eax, %edx
-# endif
 	jns	112f
 	addl	$1000000000, %edx
 	subl	$1, %ecx