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]

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


When looking through macro expanded C code I noticed that
sysdeps/unix/clock_gettime.c has some deadcode in a switch statement.

<snip>
    default:
#ifdef SYSDEP_GETTIME_CPU
      SYSDEP_GETTIME_CPU (clock_id, tp);
# endif
# 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
        __set_errno (EINVAL);
      break;
</snip>

The HP_TIMING_AVAIL path (and errno) is deadcode if SYSDEP_GETTIME_CPU
is available since the definition of SYSDEP_GETTIME_CPU in
sysdeps/unix/sysv/linux/clock_gettime.c includes a break statement.

This is an RFC because I'm not sure what has higher performance
precedence, HP_TIMING_AVAIL or the SYSDEP_GETTIME_CPU methodology.

I'm thinking that the following methodology might be preferred because
without it the HP_TIMING mechanism is likely never to be used at all.

I haven't run the numbers to determine whether the HP TIMING mechanism
is better performing than vDSO get_clocktime (which would happen through
SYSDEP_GETTIME_CPU).

Thoughts?

Ryan S. Arnold
IBM Linux Technology Center

diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index c9a91e3..3efeda1 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -22,6 +22,7 @@
 #include <sys/time.h>
 #include <libc-internal.h>
 #include <ldsodefs.h>
+#include <hp-timing.h>
 
 
 #if HP_TIMING_AVAIL
@@ -111,17 +112,18 @@ clock_gettime (clockid_t clock_id, struct timespec
*tp)
 #endif
 
     default:
-#ifdef SYSDEP_GETTIME_CPU
+#if !defined(HP_TIMING_AVAIL) && defined(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;
+#endif
 
 #if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
     case CLOCK_PROCESS_CPUTIME_ID:


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