Add support for target specific command line switches to old-style simualtors.
[deliverable/binutils-gdb.git] / gprof / hertz.c
index 9dbc89ffc61ce3f07053c70083d2f96fb8b7a61b..7e16511c26abcd882b4bd70ef0b8a25b1d3c0bbe 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#include <sys/time.h>
+#include "gprof.h"
 #include "hertz.h"
 
 
-#ifdef __MSDOS__
-#define HERTZ 18
-#endif
-
 int
 hertz ()
 {
 #ifdef HERTZ
   return HERTZ;
-#else
+#else /* ! defined (HERTZ) */
+#ifdef HAVE_SETITIMER
   struct itimerval tim;
 
   tim.it_interval.tv_sec = 0;
@@ -38,10 +35,19 @@ hertz ()
   tim.it_value.tv_usec = 0;
   setitimer (ITIMER_REAL, &tim, 0);
   setitimer (ITIMER_REAL, 0, &tim);
-  if (tim.it_interval.tv_usec < 2)
+  if (tim.it_interval.tv_usec >= 2)
     {
-      return HZ_WRONG;
+      return 1000000 / tim.it_interval.tv_usec;
     }
-  return 1000000 / tim.it_interval.tv_usec;
-#endif
+#endif /* ! defined (HAVE_SETITIMER) */
+#if defined (HAVE_SYSCONF) && defined (_SC_CLK_TCK)
+  return sysconf (_SC_CLK_TCK);
+#else /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
+#ifdef __MSDOS__
+  return 18;
+#else  /* ! defined (__MSDOS__) */
+  return HZ_WRONG;
+#endif /* ! defined (__MSDOS__) */
+#endif /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
+#endif /* ! defined (HERTZ) */
 }
This page took 0.027132 seconds and 4 git commands to generate.