a2cf7d
commit 38cc11daa43b11b12a7774405accee1007de1adf
a2cf7d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
a2cf7d
Date:   Wed Jan 16 16:22:29 2019 +0000
a2cf7d
a2cf7d
    nptl: Remove pthread_clock_gettime pthread_clock_settime
a2cf7d
    
a2cf7d
    This patch removes CLOCK_THREAD_CPUTIME_ID and CLOCK_PROCESS_CPUTIME_ID support
a2cf7d
    from clock_gettime and clock_settime generic implementation.  For Linux, kernel
a2cf7d
    already provides supports through the syscall and Hurd HTL lacks
a2cf7d
    __pthread_clock_gettime and __pthread_clock_settime internal implementation.
a2cf7d
    
a2cf7d
    As described in clock_gettime man-page [1] on 'Historical note for SMP
a2cf7d
    system', implementing CLOCK_{THREAD,PROCESS}_CPUTIME_ID with timer registers
a2cf7d
    is error-prone and susceptible to timing and accurary issues that the libc
a2cf7d
    can not deal without kernel support.
a2cf7d
    
a2cf7d
    This allows removes unused code which, however, still incur in some runtime
a2cf7d
    overhead in thread creation (the struct pthread cpuclock_offset
a2cf7d
    initialization).
a2cf7d
    
a2cf7d
    If hurd eventually wants to support them it should either either implement as
a2cf7d
    a kernel facility (or something related due its architecture) or in system
a2cf7d
    specific implementation.
a2cf7d
    
a2cf7d
    Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
a2cf7d
    checked on a i686-gnu build.
a2cf7d
    
a2cf7d
            * nptl/Makefile (libpthread-routines): Remove pthread_clock_gettime and
a2cf7d
            pthread_clock_settime.
a2cf7d
            * nptl/pthreadP.h (__find_thread_by_id): Remove prototype.
a2cf7d
            * elf/dl-support.c [!HP_TIMING_NOAVAIL] (_dl_cpuclock_offset): Remove.
a2cf7d
            (_dl_non_dynamic_init): Remove _dl_cpuclock_offset setting.
a2cf7d
            * elf/rtld.c (_dl_start_final): Likewise.
a2cf7d
            * nptl/allocatestack.c (__find_thread_by_id): Remove function.
a2cf7d
            * sysdeps/generic/ldsodefs.h [!HP_TIMING_NOAVAIL] (_dl_cpuclock_offset):
a2cf7d
            Remove.
a2cf7d
            * sysdeps/mach/hurd/dl-sysdep.c [!HP_TIMING_NOAVAIL]
a2cf7d
            (_dl_cpuclock_offset): Remove.
a2cf7d
            * nptl/descr.h (struct pthread): Rename cpuclock_offset to
a2cf7d
            cpuclock_offset_ununsed.
a2cf7d
            * nptl/nptl-init.c (__pthread_initialize_minimal_internal): Remove
a2cf7d
            cpuclock_offset set.
a2cf7d
            * nptl/pthread_create.c (START_THREAD_DEFN): Likewise.
a2cf7d
            * sysdeps/nptl/fork.c (__libc_fork): Likewise.
a2cf7d
            * nptl/pthread_clock_gettime.c: Remove file.
a2cf7d
            * nptl/pthread_clock_settime.c: Likewise.
a2cf7d
            * sysdeps/unix/clock_gettime.c (hp_timing_gettime): Remove function.
a2cf7d
            [HP_TIMING_AVAIL] (realtime_gettime): Remove CLOCK_THREAD_CPUTIME_ID
a2cf7d
            and CLOCK_PROCESS_CPUTIME_ID support.
a2cf7d
            * sysdeps/unix/clock_settime.c (hp_timing_gettime): Likewise.
a2cf7d
            [HP_TIMING_AVAIL] (realtime_gettime): Likewise.
a2cf7d
            * sysdeps/posix/clock_getres.c (hp_timing_getres): Likewise.
a2cf7d
            [HP_TIMING_AVAIL] (__clock_getres): Likewise.
a2cf7d
            * sysdeps/unix/clock_nanosleep.c (CPUCLOCK_P, INVALID_CLOCK_P):
a2cf7d
            Likewise.
a2cf7d
            (__clock_nanosleep): Remove CPUCLOCK_P and INVALID_CLOCK_P usage.
a2cf7d
    
a2cf7d
    [1] http://man7.org/linux/man-pages/man2/clock_gettime.2.html
a2cf7d
a2cf7d
Conflicts:
a2cf7d
	nptl/pthread_clock_gettime.c
a2cf7d
	nptl/pthread_clock_settime.c
a2cf7d
	  (Removal after copyright year update upstream.)
a2cf7d
a2cf7d
diff --git a/elf/dl-support.c b/elf/dl-support.c
a2cf7d
index c8439fcc53d126f3..ef5455b91c17ca30 100644
a2cf7d
--- a/elf/dl-support.c
a2cf7d
+++ b/elf/dl-support.c
a2cf7d
@@ -127,11 +127,6 @@ void *_dl_random;
a2cf7d
 #include <dl-procruntime.c>
a2cf7d
 #include <dl-procinfo.c>
a2cf7d
 
a2cf7d
-/* Initial value of the CPU clock.  */
a2cf7d
-#ifndef HP_TIMING_NONAVAIL
a2cf7d
-hp_timing_t _dl_cpuclock_offset;
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls;
a2cf7d
 
a2cf7d
 size_t _dl_pagesize = EXEC_PAGESIZE;
a2cf7d
@@ -312,9 +307,6 @@ _dl_non_dynamic_init (void)
a2cf7d
   _dl_main_map.l_phdr = GL(dl_phdr);
a2cf7d
   _dl_main_map.l_phnum = GL(dl_phnum);
a2cf7d
 
a2cf7d
-  if (HP_SMALL_TIMING_AVAIL)
a2cf7d
-    HP_TIMING_NOW (_dl_cpuclock_offset);
a2cf7d
-
a2cf7d
   _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
a2cf7d
 
a2cf7d
   /* Set up the data structures for the system-supplied DSO early,
a2cf7d
diff --git a/elf/rtld.c b/elf/rtld.c
a2cf7d
index 0aa1a2a19f649e16..e107bd14f9478a90 100644
a2cf7d
--- a/elf/rtld.c
a2cf7d
+++ b/elf/rtld.c
a2cf7d
@@ -401,8 +401,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
a2cf7d
 # endif
a2cf7d
 #endif
a2cf7d
 
a2cf7d
-  HP_TIMING_NOW (GL(dl_cpuclock_offset));
a2cf7d
-
a2cf7d
   /* Initialize the stack end variable.  */
a2cf7d
   __libc_stack_end = __builtin_frame_address (0);
a2cf7d
 
a2cf7d
diff --git a/nptl/Makefile b/nptl/Makefile
a2cf7d
index 447dce0590295c9c..d6b37b6efd3b7d78 100644
a2cf7d
--- a/nptl/Makefile
a2cf7d
+++ b/nptl/Makefile
a2cf7d
@@ -109,7 +109,6 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
a2cf7d
 		      pthread_once \
a2cf7d
 		      old_pthread_atfork \
a2cf7d
 		      pthread_getcpuclockid \
a2cf7d
-		      pthread_clock_gettime pthread_clock_settime \
a2cf7d
 		      shm-directory \
a2cf7d
 		      sem_init sem_destroy \
a2cf7d
 		      sem_open sem_close sem_unlink \
a2cf7d
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
a2cf7d
index d0971a97fdbe098e..5fa45b19987717e1 100644
a2cf7d
--- a/nptl/allocatestack.c
a2cf7d
+++ b/nptl/allocatestack.c
a2cf7d
@@ -964,54 +964,6 @@ __reclaim_stacks (void)
a2cf7d
 }
a2cf7d
 
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-# undef __find_thread_by_id
a2cf7d
-/* Find a thread given the thread ID.  */
a2cf7d
-attribute_hidden
a2cf7d
-struct pthread *
a2cf7d
-__find_thread_by_id (pid_t tid)
a2cf7d
-{
a2cf7d
-  struct pthread *result = NULL;
a2cf7d
-
a2cf7d
-  lll_lock (stack_cache_lock, LLL_PRIVATE);
a2cf7d
-
a2cf7d
-  /* Iterate over the list with system-allocated threads first.  */
a2cf7d
-  list_t *runp;
a2cf7d
-  list_for_each (runp, &stack_used)
a2cf7d
-    {
a2cf7d
-      struct pthread *curp;
a2cf7d
-
a2cf7d
-      curp = list_entry (runp, struct pthread, list);
a2cf7d
-
a2cf7d
-      if (curp->tid == tid)
a2cf7d
-	{
a2cf7d
-	  result = curp;
a2cf7d
-	  goto out;
a2cf7d
-	}
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  /* Now the list with threads using user-allocated stacks.  */
a2cf7d
-  list_for_each (runp, &__stack_user)
a2cf7d
-    {
a2cf7d
-      struct pthread *curp;
a2cf7d
-
a2cf7d
-      curp = list_entry (runp, struct pthread, list);
a2cf7d
-
a2cf7d
-      if (curp->tid == tid)
a2cf7d
-	{
a2cf7d
-	  result = curp;
a2cf7d
-	  goto out;
a2cf7d
-	}
a2cf7d
-    }
a2cf7d
-
a2cf7d
- out:
a2cf7d
-  lll_unlock (stack_cache_lock, LLL_PRIVATE);
a2cf7d
-
a2cf7d
-  return result;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-
a2cf7d
 #ifdef SIGSETXID
a2cf7d
 static void
a2cf7d
 setxid_mark_thread (struct xid_command *cmdp, struct pthread *t)
a2cf7d
diff --git a/nptl/descr.h b/nptl/descr.h
a2cf7d
index 9c01e1b9863b178c..c3b81d8b27839502 100644
a2cf7d
--- a/nptl/descr.h
a2cf7d
+++ b/nptl/descr.h
a2cf7d
@@ -343,8 +343,7 @@ struct pthread
a2cf7d
   unsigned int setxid_futex;
a2cf7d
 
a2cf7d
 #if HP_TIMING_AVAIL
a2cf7d
-  /* Offset of the CPU clock at start thread start time.  */
a2cf7d
-  hp_timing_t cpuclock_offset;
a2cf7d
+  hp_timing_t cpuclock_offset_ununsed;
a2cf7d
 #endif
a2cf7d
 
a2cf7d
   /* If the thread waits to join another one the ID of the latter is
a2cf7d
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
a2cf7d
index 907411d5bca2af79..098bc059f4771ef2 100644
a2cf7d
--- a/nptl/nptl-init.c
a2cf7d
+++ b/nptl/nptl-init.c
a2cf7d
@@ -275,9 +275,6 @@ __pthread_initialize_minimal_internal (void)
a2cf7d
   THREAD_SETMEM (pd, user_stack, true);
a2cf7d
   if (LLL_LOCK_INITIALIZER != 0)
a2cf7d
     THREAD_SETMEM (pd, lock, LLL_LOCK_INITIALIZER);
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-  THREAD_SETMEM (pd, cpuclock_offset, GL(dl_cpuclock_offset));
a2cf7d
-#endif
a2cf7d
 
a2cf7d
   /* Initialize the robust mutex data.  */
a2cf7d
   {
a2cf7d
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
a2cf7d
index 19efe1e35feed5be..00be8f92793e8710 100644
a2cf7d
--- a/nptl/pthreadP.h
a2cf7d
+++ b/nptl/pthreadP.h
a2cf7d
@@ -406,16 +406,6 @@ extern int __pthread_multiple_threads attribute_hidden;
a2cf7d
 extern int *__libc_multiple_threads_ptr attribute_hidden;
a2cf7d
 #endif
a2cf7d
 
a2cf7d
-/* Find a thread given its TID.  */
a2cf7d
-extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
a2cf7d
-#ifdef SHARED
a2cf7d
-;
a2cf7d
-#else
a2cf7d
-weak_function;
a2cf7d
-#define __find_thread_by_id(tid) \
a2cf7d
-  (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
a2cf7d
 
a2cf7d
 extern size_t __pthread_get_minstack (const pthread_attr_t *attr);
a2cf7d
diff --git a/nptl/pthread_clock_gettime.c b/nptl/pthread_clock_gettime.c
a2cf7d
deleted file mode 100644
a2cf7d
index 6bc75cfe3f1ff856..0000000000000000
a2cf7d
--- a/nptl/pthread_clock_gettime.c
a2cf7d
+++ /dev/null
a2cf7d
@@ -1,67 +0,0 @@
a2cf7d
-/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
a2cf7d
-   This file is part of the GNU C Library.
a2cf7d
-
a2cf7d
-   The GNU C Library is free software; you can redistribute it and/or
a2cf7d
-   modify it under the terms of the GNU Lesser General Public License as
a2cf7d
-   published by the Free Software Foundation; either version 2.1 of the
a2cf7d
-   License, or (at your option) any later version.
a2cf7d
-
a2cf7d
-   The GNU C Library is distributed in the hope that it will be useful,
a2cf7d
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
a2cf7d
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a2cf7d
-   Lesser General Public License for more details.
a2cf7d
-
a2cf7d
-   You should have received a copy of the GNU Lesser General Public
a2cf7d
-   License along with the GNU C Library; see the file COPYING.LIB.  If
a2cf7d
-   not, see <http://www.gnu.org/licenses/>.  */
a2cf7d
-
a2cf7d
-#include <errno.h>
a2cf7d
-#include <stdlib.h>
a2cf7d
-#include <time.h>
a2cf7d
-#include "pthreadP.h"
a2cf7d
-
a2cf7d
-
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-int
a2cf7d
-__pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
a2cf7d
-			 struct timespec *tp)
a2cf7d
-{
a2cf7d
-  hp_timing_t tsc;
a2cf7d
-
a2cf7d
-  /* Get the current counter.  */
a2cf7d
-  HP_TIMING_NOW (tsc);
a2cf7d
-
a2cf7d
-  /* This is the ID of the thread we are looking for.  */
a2cf7d
-  pid_t tid = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE;
a2cf7d
-
a2cf7d
-  /* Compute the offset since the start time of the process.  */
a2cf7d
-  if (tid == 0 || tid == THREAD_GETMEM (THREAD_SELF, tid))
a2cf7d
-    /* Our own clock.  */
a2cf7d
-    tsc -= THREAD_GETMEM (THREAD_SELF, cpuclock_offset);
a2cf7d
-  else
a2cf7d
-    {
a2cf7d
-      /* This is more complicated.  We have to locate the thread based
a2cf7d
-	 on the ID.  This means walking the list of existing
a2cf7d
-	 threads.  */
a2cf7d
-      struct pthread *thread = __find_thread_by_id (tid);
a2cf7d
-      if (thread == NULL)
a2cf7d
-	{
a2cf7d
-	  __set_errno (EINVAL);
a2cf7d
-	  return -1;
a2cf7d
-	}
a2cf7d
-
a2cf7d
-      /* There is a race here.  The thread might terminate and the stack
a2cf7d
-	 become unusable.  But this is the user's problem.  */
a2cf7d
-      tsc -= thread->cpuclock_offset;
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  /* Compute the seconds.  */
a2cf7d
-  tp->tv_sec = tsc / freq;
a2cf7d
-
a2cf7d
-  /* And the nanoseconds.  This computation should be stable until
a2cf7d
-     we get machines with about 16GHz frequency.  */
a2cf7d
-  tp->tv_nsec = ((tsc % freq) * 1000000000ull) / freq;
a2cf7d
-
a2cf7d
-  return 0;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
diff --git a/nptl/pthread_clock_settime.c b/nptl/pthread_clock_settime.c
a2cf7d
deleted file mode 100644
a2cf7d
index 29d35c64cfa817a3..0000000000000000
a2cf7d
--- a/nptl/pthread_clock_settime.c
a2cf7d
+++ /dev/null
a2cf7d
@@ -1,54 +0,0 @@
a2cf7d
-/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
a2cf7d
-   This file is part of the GNU C Library.
a2cf7d
-
a2cf7d
-   The GNU C Library is free software; you can redistribute it and/or
a2cf7d
-   modify it under the terms of the GNU Lesser General Public License as
a2cf7d
-   published by the Free Software Foundation; either version 2.1 of the
a2cf7d
-   License, or (at your option) any later version.
a2cf7d
-
a2cf7d
-   The GNU C Library is distributed in the hope that it will be useful,
a2cf7d
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
a2cf7d
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a2cf7d
-   Lesser General Public License for more details.
a2cf7d
-
a2cf7d
-   You should have received a copy of the GNU Lesser General Public
a2cf7d
-   License along with the GNU C Library; see the file COPYING.LIB.  If
a2cf7d
-   not, see <http://www.gnu.org/licenses/>.  */
a2cf7d
-
a2cf7d
-#include <errno.h>
a2cf7d
-#include <stdlib.h>
a2cf7d
-#include <time.h>
a2cf7d
-#include "pthreadP.h"
a2cf7d
-
a2cf7d
-
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-int
a2cf7d
-__pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
a2cf7d
-{
a2cf7d
-  /* This is the ID of the thread we are looking for.  */
a2cf7d
-  pid_t tid = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE;
a2cf7d
-
a2cf7d
-  /* Compute the offset since the start time of the process.  */
a2cf7d
-  if (tid == 0 || tid == THREAD_GETMEM (THREAD_SELF, tid))
a2cf7d
-    /* Our own clock.  */
a2cf7d
-    THREAD_SETMEM (THREAD_SELF, cpuclock_offset, offset);
a2cf7d
-  else
a2cf7d
-    {
a2cf7d
-      /* This is more complicated.  We have to locate the thread based
a2cf7d
-	 on the ID.  This means walking the list of existing
a2cf7d
-	 threads.  */
a2cf7d
-      struct pthread *thread = __find_thread_by_id (tid);
a2cf7d
-      if (thread == NULL)
a2cf7d
-	{
a2cf7d
-	  __set_errno (EINVAL);
a2cf7d
-	  return -1;
a2cf7d
-	}
a2cf7d
-
a2cf7d
-      /* There is a race here.  The thread might terminate and the stack
a2cf7d
-	 become unusable.  But this is the user's problem.  */
a2cf7d
-      thread->cpuclock_offset = offset;
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  return 0;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
a2cf7d
index fe75d04113b8aa3f..f58a15cd1c7bbb6f 100644
a2cf7d
--- a/nptl/pthread_create.c
a2cf7d
+++ b/nptl/pthread_create.c
a2cf7d
@@ -379,13 +379,6 @@ START_THREAD_DEFN
a2cf7d
 {
a2cf7d
   struct pthread *pd = START_THREAD_SELF;
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-  /* Remember the time when the thread was started.  */
a2cf7d
-  hp_timing_t now;
a2cf7d
-  HP_TIMING_NOW (now);
a2cf7d
-  THREAD_SETMEM (pd, cpuclock_offset, now);
a2cf7d
-#endif
a2cf7d
-
a2cf7d
   /* Initialize resolver state pointer.  */
a2cf7d
   __resp = &pd->res;
a2cf7d
 
a2cf7d
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
a2cf7d
index c6b7e61badbfd513..f0185ce0d16c0f69 100644
a2cf7d
--- a/sysdeps/generic/ldsodefs.h
a2cf7d
+++ b/sysdeps/generic/ldsodefs.h
a2cf7d
@@ -359,11 +359,6 @@ struct rtld_global
a2cf7d
   /* The object to be initialized first.  */
a2cf7d
   EXTERN struct link_map *_dl_initfirst;
a2cf7d
 
a2cf7d
-#if HP_SMALL_TIMING_AVAIL
a2cf7d
-  /* Start time on CPU clock.  */
a2cf7d
-  EXTERN hp_timing_t _dl_cpuclock_offset;
a2cf7d
-#endif
a2cf7d
-
a2cf7d
   /* Map of shared object to be profiled.  */
a2cf7d
   EXTERN struct link_map *_dl_profile_map;
a2cf7d
 
a2cf7d
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
a2cf7d
index b72913d3baaed1d9..7bd1d70c96c229e0 100644
a2cf7d
--- a/sysdeps/mach/hurd/dl-sysdep.c
a2cf7d
+++ b/sysdeps/mach/hurd/dl-sysdep.c
a2cf7d
@@ -62,10 +62,6 @@ int __libc_multiple_libcs = 0;	/* Defining this here avoids the inclusion
a2cf7d
 void *__libc_stack_end = NULL;
a2cf7d
 rtld_hidden_data_def(__libc_stack_end)
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-hp_timing_t _dl_cpuclock_offset;
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 /* TODO: Initialize.  */
a2cf7d
 void *_dl_random attribute_relro = NULL;
a2cf7d
 
a2cf7d
@@ -246,10 +242,6 @@ unfmh();			/* XXX */
a2cf7d
   /* Initialize frequently used global variable.  */
a2cf7d
   GLRO(dl_pagesize) = __getpagesize ();
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-  HP_TIMING_NOW (_dl_cpuclock_offset);
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 fmh();				/* XXX */
a2cf7d
 
a2cf7d
   /* See hurd/hurdstartup.c; this deals with getting information
a2cf7d
diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
a2cf7d
index 1a9429b579cd346e..37db30f3d1e846b6 100644
a2cf7d
--- a/sysdeps/nptl/fork.c
a2cf7d
+++ b/sysdeps/nptl/fork.c
a2cf7d
@@ -83,14 +83,6 @@ __libc_fork (void)
a2cf7d
       if (__fork_generation_pointer != NULL)
a2cf7d
 	*__fork_generation_pointer += __PTHREAD_ONCE_FORK_GEN_INCR;
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-      /* The CPU clock of the thread and process have to be set to zero.  */
a2cf7d
-      hp_timing_t now;
a2cf7d
-      HP_TIMING_NOW (now);
a2cf7d
-      THREAD_SETMEM (self, cpuclock_offset, now);
a2cf7d
-      GL(dl_cpuclock_offset) = now;
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 #ifdef __NR_set_robust_list
a2cf7d
       /* Initialize the robust mutex list setting in the kernel which has
a2cf7d
 	 been reset during the fork.  We do not check for errors because if
a2cf7d
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
a2cf7d
index 43228c381e6a73f1..5b0d8eb8a1a0593e 100644
a2cf7d
--- a/sysdeps/posix/clock_getres.c
a2cf7d
+++ b/sysdeps/posix/clock_getres.c
a2cf7d
@@ -24,37 +24,6 @@
a2cf7d
 #include <libc-internal.h>
a2cf7d
 
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-static long int nsec;		/* Clock frequency of the processor.  */
a2cf7d
-
a2cf7d
-static int
a2cf7d
-hp_timing_getres (struct timespec *res)
a2cf7d
-{
a2cf7d
-  if (__glibc_unlikely (nsec == 0))
a2cf7d
-    {
a2cf7d
-      hp_timing_t freq;
a2cf7d
-
a2cf7d
-      /* This can only happen if we haven't initialized the `nsec'
a2cf7d
-	 variable yet.  Do this now.  We don't have to protect this
a2cf7d
-	 code against multiple execution since all of them should
a2cf7d
-	 lead to the same result.  */
a2cf7d
-      freq = __get_clockfreq ();
a2cf7d
-      if (__glibc_unlikely (freq == 0))
a2cf7d
-	/* Something went wrong.  */
a2cf7d
-	return -1;
a2cf7d
-
a2cf7d
-      nsec = MAX (UINT64_C (1000000000) / freq, 1);
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  /* Fill in the values.
a2cf7d
-     The seconds are always zero (unless we have a 1Hz machine).  */
a2cf7d
-  res->tv_sec = 0;
a2cf7d
-  res->tv_nsec = nsec;
a2cf7d
-
a2cf7d
-  return 0;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
-
a2cf7d
 static inline int
a2cf7d
 realtime_getres (struct timespec *res)
a2cf7d
 {
a2cf7d
@@ -87,21 +56,8 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
a2cf7d
       break;
a2cf7d
 
a2cf7d
     default:
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
a2cf7d
-	  == CLOCK_THREAD_CPUTIME_ID)
a2cf7d
-	retval = hp_timing_getres (res);
a2cf7d
-      else
a2cf7d
-#endif
a2cf7d
-	__set_errno (EINVAL);
a2cf7d
-      break;
a2cf7d
-
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-    case CLOCK_PROCESS_CPUTIME_ID:
a2cf7d
-    case CLOCK_THREAD_CPUTIME_ID:
a2cf7d
-      retval = hp_timing_getres (res);
a2cf7d
+      __set_errno (EINVAL);
a2cf7d
       break;
a2cf7d
-#endif
a2cf7d
     }
a2cf7d
 
a2cf7d
   return retval;
a2cf7d
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
a2cf7d
index f19fdf7e5f310973..f3ebbe15ccc2e95e 100644
a2cf7d
--- a/sysdeps/unix/clock_gettime.c
a2cf7d
+++ b/sysdeps/unix/clock_gettime.c
a2cf7d
@@ -24,57 +24,6 @@
a2cf7d
 #include <ldsodefs.h>
a2cf7d
 
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-/* Clock frequency of the processor.  We make it a 64-bit variable
a2cf7d
-   because some jokers are already playing with processors with more
a2cf7d
-   than 4GHz.  */
a2cf7d
-static hp_timing_t freq;
a2cf7d
-
a2cf7d
-
a2cf7d
-/* This function is defined in the thread library.  */
a2cf7d
-extern int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
a2cf7d
-				    struct timespec *tp)
a2cf7d
-     __attribute__ ((__weak__));
a2cf7d
-
a2cf7d
-static int
a2cf7d
-hp_timing_gettime (clockid_t clock_id, struct timespec *tp)
a2cf7d
-{
a2cf7d
-  hp_timing_t tsc;
a2cf7d
-
a2cf7d
-  if (__glibc_unlikely (freq == 0))
a2cf7d
-    {
a2cf7d
-      /* This can only happen if we haven't initialized the `freq'
a2cf7d
-	 variable yet.  Do this now. We don't have to protect this
a2cf7d
-	 code against multiple execution since all of them should
a2cf7d
-	 lead to the same result.  */
a2cf7d
-      freq = __get_clockfreq ();
a2cf7d
-      if (__glibc_unlikely (freq == 0))
a2cf7d
-	/* Something went wrong.  */
a2cf7d
-	return -1;
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  if (clock_id != CLOCK_PROCESS_CPUTIME_ID
a2cf7d
-      && __pthread_clock_gettime != NULL)
a2cf7d
-    return __pthread_clock_gettime (clock_id, freq, tp);
a2cf7d
-
a2cf7d
-  /* Get the current counter.  */
a2cf7d
-  HP_TIMING_NOW (tsc);
a2cf7d
-
a2cf7d
-  /* Compute the offset since the start time of the process.  */
a2cf7d
-  tsc -= GL(dl_cpuclock_offset);
a2cf7d
-
a2cf7d
-  /* Compute the seconds.  */
a2cf7d
-  tp->tv_sec = tsc / freq;
a2cf7d
-
a2cf7d
-  /* And the nanoseconds.  This computation should be stable until
a2cf7d
-     we get machines with about 16GHz frequency.  */
a2cf7d
-  tp->tv_nsec = ((tsc % freq) * UINT64_C (1000000000)) / freq;
a2cf7d
-
a2cf7d
-  return 0;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-
a2cf7d
 static inline int
a2cf7d
 realtime_gettime (struct timespec *tp)
a2cf7d
 {
a2cf7d
@@ -105,20 +54,8 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
a2cf7d
       break;
a2cf7d
 
a2cf7d
     default:
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
a2cf7d
-	  == CLOCK_THREAD_CPUTIME_ID)
a2cf7d
-	retval = hp_timing_gettime (clock_id, tp);
a2cf7d
-      else
a2cf7d
-#endif
a2cf7d
-	__set_errno (EINVAL);
a2cf7d
-      break;
a2cf7d
-
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-    case CLOCK_PROCESS_CPUTIME_ID:
a2cf7d
-      retval = hp_timing_gettime (clock_id, tp);
a2cf7d
+      __set_errno (EINVAL);
a2cf7d
       break;
a2cf7d
-#endif
a2cf7d
     }
a2cf7d
 
a2cf7d
   return retval;
a2cf7d
diff --git a/sysdeps/unix/clock_nanosleep.c b/sysdeps/unix/clock_nanosleep.c
a2cf7d
index 97b3d6b6ab9e4581..13dd0f4b905ec631 100644
a2cf7d
--- a/sysdeps/unix/clock_nanosleep.c
a2cf7d
+++ b/sysdeps/unix/clock_nanosleep.c
a2cf7d
@@ -19,23 +19,8 @@
a2cf7d
 #include <assert.h>
a2cf7d
 #include <errno.h>
a2cf7d
 #include <time.h>
a2cf7d
-#include <hp-timing.h>
a2cf7d
 #include <sysdep-cancel.h>
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-# define CPUCLOCK_P(clock) \
a2cf7d
-  ((clock) == CLOCK_PROCESS_CPUTIME_ID					      \
a2cf7d
-   || ((clock) & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID)
a2cf7d
-#else
a2cf7d
-# define CPUCLOCK_P(clock) 0
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-#ifndef INVALID_CLOCK_P
a2cf7d
-# define INVALID_CLOCK_P(cl) \
a2cf7d
-  ((cl) < CLOCK_REALTIME || (cl) > CLOCK_THREAD_CPUTIME_ID)
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-
a2cf7d
 /* This implementation assumes that these is only a `nanosleep' system
a2cf7d
    call.  So we have to remap all other activities.  */
a2cf7d
 int
a2cf7d
@@ -51,14 +36,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
a2cf7d
   if (clock_id == CLOCK_THREAD_CPUTIME_ID)
a2cf7d
     return EINVAL;		/* POSIX specifies EINVAL for this case.  */
a2cf7d
 
a2cf7d
-#ifdef SYSDEP_NANOSLEEP
a2cf7d
-  SYSDEP_NANOSLEEP;
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-  if (CPUCLOCK_P (clock_id))
a2cf7d
-    return ENOTSUP;
a2cf7d
-
a2cf7d
-  if (INVALID_CLOCK_P (clock_id))
a2cf7d
+  if (clock_id < CLOCK_REALTIME || clock_id > CLOCK_THREAD_CPUTIME_ID)
a2cf7d
     return EINVAL;
a2cf7d
 
a2cf7d
   /* If we got an absolute time, remap it.  */
a2cf7d
@@ -71,7 +49,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
a2cf7d
       assert (sizeof (sec) >= sizeof (now.tv_sec));
a2cf7d
 
a2cf7d
       /* Get the current time for this clock.  */
a2cf7d
-      if (__builtin_expect (__clock_gettime (clock_id, &now), 0) != 0)
a2cf7d
+      if (__clock_gettime (clock_id, &now) != 0)
a2cf7d
 	return errno;
a2cf7d
 
a2cf7d
       /* Compute the difference.  */
a2cf7d
@@ -90,12 +68,12 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
a2cf7d
       /* Make sure we are not modifying the struct pointed to by REM.  */
a2cf7d
       rem = NULL;
a2cf7d
     }
a2cf7d
-  else if (__builtin_expect (flags, 0) != 0)
a2cf7d
+  else if (flags != 0)
a2cf7d
     return EINVAL;
a2cf7d
   else if (clock_id != CLOCK_REALTIME)
a2cf7d
     /* Not supported.  */
a2cf7d
     return ENOTSUP;
a2cf7d
 
a2cf7d
-  return __builtin_expect (__nanosleep (req, rem), 0) ? errno : 0;
a2cf7d
+  return __nanosleep (req, rem), 0 ? errno : 0;
a2cf7d
 }
a2cf7d
 weak_alias (__clock_nanosleep, clock_nanosleep)
a2cf7d
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
a2cf7d
index 9d5857e61b966b44..4f5640f67047cef6 100644
a2cf7d
--- a/sysdeps/unix/clock_settime.c
a2cf7d
+++ b/sysdeps/unix/clock_settime.c
a2cf7d
@@ -21,59 +21,11 @@
a2cf7d
 #include <ldsodefs.h>
a2cf7d
 
a2cf7d
 
a2cf7d
-#if HP_TIMING_AVAIL
a2cf7d
-/* Clock frequency of the processor.  We make it a 64-bit variable
a2cf7d
-   because some jokers are already playing with processors with more
a2cf7d
-   than 4GHz.  */
a2cf7d
-static hp_timing_t freq;
a2cf7d
-
a2cf7d
-
a2cf7d
-/* This function is defined in the thread library.  */
a2cf7d
-extern void __pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
a2cf7d
-     __attribute__ ((__weak__));
a2cf7d
-
a2cf7d
-
a2cf7d
-static int
a2cf7d
-hp_timing_settime (clockid_t clock_id, const struct timespec *tp)
a2cf7d
-{
a2cf7d
-  hp_timing_t tsc;
a2cf7d
-  hp_timing_t usertime;
a2cf7d
-
a2cf7d
-  /* First thing is to get the current time.  */
a2cf7d
-  HP_TIMING_NOW (tsc);
a2cf7d
-
a2cf7d
-  if (__glibc_unlikely (freq == 0))
a2cf7d
-    {
a2cf7d
-      /* This can only happen if we haven't initialized the `freq'
a2cf7d
-	 variable yet.  Do this now. We don't have to protect this
a2cf7d
-	 code against multiple execution since all of them should lead
a2cf7d
-	 to the same result.  */
a2cf7d
-      freq = __get_clockfreq ();
a2cf7d
-      if (__glibc_unlikely (freq == 0))
a2cf7d
-	/* Something went wrong.  */
a2cf7d
-	return -1;
a2cf7d
-    }
a2cf7d
-
a2cf7d
-  /* Convert the user-provided time into CPU ticks.  */
a2cf7d
-  usertime = tp->tv_sec * freq + (tp->tv_nsec * freq) / 1000000000ull;
a2cf7d
-
a2cf7d
-  /* Determine the offset and use it as the new base value.  */
a2cf7d
-  if (clock_id == CLOCK_PROCESS_CPUTIME_ID
a2cf7d
-      || __pthread_clock_settime == NULL)
a2cf7d
-    GL(dl_cpuclock_offset) = tsc - usertime;
a2cf7d
-  else
a2cf7d
-    __pthread_clock_settime (clock_id, tsc - usertime);
a2cf7d
-
a2cf7d
-  return 0;
a2cf7d
-}
a2cf7d
-#endif
a2cf7d
-
a2cf7d
-
a2cf7d
 /* Set CLOCK to value TP.  */
a2cf7d
 int
a2cf7d
 __clock_settime (clockid_t clock_id, const struct timespec *tp)
a2cf7d
 {
a2cf7d
-  int retval;
a2cf7d
+  int retval = -1;
a2cf7d
 
a2cf7d
   /* Make sure the time cvalue is OK.  */
a2cf7d
   if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
a2cf7d
@@ -93,16 +45,7 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp)
a2cf7d
       break;
a2cf7d
 
a2cf7d
     default:
a2cf7d
-# if HP_TIMING_AVAIL
a2cf7d
-      if (CPUCLOCK_WHICH (clock_id) == CLOCK_PROCESS_CPUTIME_ID
a2cf7d
-	  || CPUCLOCK_WHICH (clock_id) == CLOCK_THREAD_CPUTIME_ID)
a2cf7d
-	retval = hp_timing_settime (clock_id, tp);
a2cf7d
-      else
a2cf7d
-# endif
a2cf7d
-	{
a2cf7d
-	  __set_errno (EINVAL);
a2cf7d
-	  retval = -1;
a2cf7d
-	}
a2cf7d
+      __set_errno (EINVAL);
a2cf7d
       break;
a2cf7d
     }
a2cf7d