about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-06-25 00:00:50 +0000
committerUlrich Drepper <drepper@redhat.com>2003-06-25 00:00:50 +0000
commit4165d44d7026bb2572d4cdfe27f8fec348b4089a (patch)
tree911aa068d7d9c4205ad6a4965ce156c937fed219 /sysdeps
parent51d1ca00fd1ddc2ed77b615b7a23ecdf3e8a55a9 (diff)
downloadglibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.gz
glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.xz
glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.zip
Update.
	* include/time.h: Define CLOCK_IDFIELD_SIZE.
	* sysdeps/posix/clock_getres.c: Recognize thread CPU clock IDs.
	* sysdeps/unix/clock_gettime.c: Likewise.
	* sysdeps/unix/clock_settime.c: Likewise.
	* sysdeps/unix/clock_nanosleep.c (CPUCLOCK_P): Adjust for new
	clock id for thread CPU clocks.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/posix/clock_getres.c16
-rw-r--r--sysdeps/unix/clock_gettime.c23
-rw-r--r--sysdeps/unix/clock_nanosleep.c2
-rw-r--r--sysdeps/unix/clock_settime.c24
4 files changed, 42 insertions, 23 deletions
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
index 91c57629ca..a2d466607e 100644
--- a/sysdeps/posix/clock_getres.c
+++ b/sysdeps/posix/clock_getres.c
@@ -64,9 +64,19 @@ clock_getres (clockid_t clock_id, struct timespec *res)
       break;
 #endif	/* handled REALTIME */
 
+    default:
+#if HP_TIMING_AVAIL
+      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
+	  != CLOCK_THREAD_CPUTIME_ID)
+#endif
+	{
+	  __set_errno (EINVAL);
+	  break;
+	}
+
 #if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
+      /* FALLTHROUGH.  */
     case CLOCK_PROCESS_CPUTIME_ID:
-    case CLOCK_THREAD_CPUTIME_ID:
       {
 	if (__builtin_expect (nsec == 0, 0))
 	  {
@@ -93,10 +103,6 @@ clock_getres (clockid_t clock_id, struct timespec *res)
       }
       break;
 #endif
-
-    default:
-      __set_errno (EINVAL);
-      break;
     }
 
   return retval;
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index b8b2b74e2f..7a3db29744 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -32,7 +32,8 @@ static hp_timing_t freq;
 
 
 /* This function is defined in the thread library.  */
-extern int __pthread_clock_gettime (hp_timing_t freq, struct timespec *tp)
+extern int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
+				    struct timespec *tp)
      __attribute__ ((__weak__));
 #endif
 
@@ -64,9 +65,19 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
       break;
 #endif
 
+    default:
+#if HP_TIMING_AVAIL
+      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
+	  != CLOCK_THREAD_CPUTIME_ID)
+#endif
+	{
+	  __set_errno (EINVAL);
+	  break;
+	}
+
 #if HP_TIMING_AVAIL
+      /* FALLTHROUGH.  */
     case CLOCK_PROCESS_CPUTIME_ID:
-    case CLOCK_THREAD_CPUTIME_ID:
       {
 	hp_timing_t tsc;
 
@@ -82,10 +93,10 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
 	      break;
 	  }
 
-	if (clock_id == CLOCK_THREAD_CPUTIME_ID
+	if (clock_id != CLOCK_PROCESS_CPUTIME_ID
 	    && __pthread_clock_gettime != NULL)
 	  {
-	    retval = __pthread_clock_gettime (freq, tp);
+	    retval = __pthread_clock_gettime (clock_id, freq, tp);
 	    break;
 	  }
 
@@ -106,10 +117,6 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
       }
     break;
 #endif
-
-    default:
-      __set_errno (EINVAL);
-      break;
     }
 
   return retval;
diff --git a/sysdeps/unix/clock_nanosleep.c b/sysdeps/unix/clock_nanosleep.c
index 7662d1704e..6b170fd702 100644
--- a/sysdeps/unix/clock_nanosleep.c
+++ b/sysdeps/unix/clock_nanosleep.c
@@ -26,7 +26,7 @@
 #if HP_TIMING_AVAIL
 # define CPUCLOCK_P(clock) \
   ((clock) == CLOCK_PROCESS_CPUTIME_ID					      \
-   || (clock) == CLOCK_THREAD_CPUTIME_ID)
+   || ((clock) & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID)
 #else
 # define CPUCLOCK_P(clock) 0
 #endif
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
index 069336a69e..6e1f487171 100644
--- a/sysdeps/unix/clock_settime.c
+++ b/sysdeps/unix/clock_settime.c
@@ -31,7 +31,7 @@ static hp_timing_t freq;
 
 
 /* This function is defined in the thread library.  */
-extern void __pthread_clock_settime (hp_timing_t offset)
+extern void __pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
      __attribute__ ((__weak__));
 #endif
 
@@ -69,9 +69,20 @@ clock_settime (clockid_t clock_id, const struct timespec *tp)
       break;
 #endif
 
+    default:
+#if HP_TIMING_AVAIL
+      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
+	  != CLOCK_THREAD_CPUTIME_ID)
+#endif
+	{
+	  __set_errno (EINVAL);
+	  retval = -1;
+	  break;
+	}
+
 #if HP_TIMING_AVAIL
+      /* FALLTHROUGH.  */
     case CLOCK_PROCESS_CPUTIME_ID:
-    case CLOCK_THREAD_CPUTIME_ID:
       {
 	hp_timing_t tsc;
 	hp_timing_t usertime;
@@ -98,21 +109,16 @@ clock_settime (clockid_t clock_id, const struct timespec *tp)
 	usertime = tp->tv_sec * freq + (tp->tv_nsec * freq) / 1000000000ull;
 
 	/* Determine the offset and use it as the new base value.  */
-	if (clock_id != CLOCK_THREAD_CPUTIME_ID
+	if (clock_id == CLOCK_PROCESS_CPUTIME_ID
 	    || __pthread_clock_settime == NULL)
 	  GL(dl_cpuclock_offset) = tsc - usertime;
 	else
-	  __pthread_clock_settime (tsc - usertime);
+	  __pthread_clock_settime (clock_id, tsc - usertime);
 
 	retval = 0;
       }
       break;
 #endif
-
-    default:
-      __set_errno (EINVAL);
-      retval = -1;
-      break;
     }
 
   return retval;