This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Deadcode path clean in sysdeps/unix/clock_gettime.c


On Mon, 2013-01-14 at 12:18 -0800, Roland McGrath wrote:
> hp-timing is only ever a fallback for CPU clocks when no real
> implementation is available.  Its semantics are unreliable.

Thanks!

With that in mind, does this seem like a more reasonable patch?

Ryan

diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index c9a91e3..b133e4a 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -23,8 +23,7 @@
 #include <libc-internal.h>
 #include <ldsodefs.h>
 
-
-#if HP_TIMING_AVAIL
+#if defined(HP_TIMING_AVAIL) && !defined(SYSDEP_GETTIME_CPU)
 /* Clock frequency of the processor.  We make it a 64-bit variable
    because some jokers are already playing with processors with more
    than 4GHz.  */
@@ -110,23 +109,24 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
       break;
 #endif
 
+#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
+    case CLOCK_PROCESS_CPUTIME_ID:
+      retval = hp_timing_gettime (clock_id, tp);
+      break;
+#endif
+
     default:
 #ifdef SYSDEP_GETTIME_CPU
       SYSDEP_GETTIME_CPU (clock_id, tp);
-#endif
-#if HP_TIMING_AVAIL
+#else
+# if HP_TIMING_AVAIL
       if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
          == CLOCK_THREAD_CPUTIME_ID)
        retval = hp_timing_gettime (clock_id, tp);
       else
-#endif
+# endif
        __set_errno (EINVAL);
       break;
-
-#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
-    case CLOCK_PROCESS_CPUTIME_ID:
-      retval = hp_timing_gettime (clock_id, tp);
-      break;
 #endif
     }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]