Back to index

glibc  2.9
Functions
prof-freq.c File Reference
#include <sys/types.h>
#include <sys/time.h>
#include <libc-internal.h>

Go to the source code of this file.

Functions

int __profile_frequency (void)

Function Documentation

Definition at line 37 of file prof-freq.c.

{
  /*
   * Discover the tick frequency of the machine if something goes wrong,
   * we return 0, an impossible hertz.
   */
  struct itimerval tim;

  tim.it_interval.tv_sec = 0;
  tim.it_interval.tv_usec = 1;
  tim.it_value.tv_sec = 0;
  tim.it_value.tv_usec = 0;
  __setitimer(ITIMER_REAL, &tim, 0);
  __setitimer(ITIMER_REAL, 0, &tim);
  if (tim.it_interval.tv_usec < 2)
    return 0;
  return (1000000 / tim.it_interval.tv_usec);
}