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