Back to index

glibc  2.9
Functions
clock_getres.c File Reference
#include <errno.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <sys/param.h>
#include <libc-internal.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int realtime_getres (struct timespec *res)
int clock_getres (clockid_t clock_id, struct timespec *res)

Function Documentation

int clock_getres ( clockid_t  clock_id,
struct timespec res 
)

Definition at line 80 of file clock_getres.c.

{
  int retval = -1;

  switch (clock_id)
    {
#ifdef SYSDEP_GETRES
      SYSDEP_GETRES;
#endif

#ifndef HANDLED_REALTIME
    case CLOCK_REALTIME:
      retval = realtime_getres (res);
      break;
#endif /* handled REALTIME */

    default:
#ifdef SYSDEP_GETRES_CPU
      SYSDEP_GETRES_CPU;
#endif
#if HP_TIMING_AVAIL
      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
         == CLOCK_THREAD_CPUTIME_ID)
       retval = hp_timing_getres (res);
      else
#endif
       __set_errno (EINVAL);
      break;

#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
    case CLOCK_PROCESS_CPUTIME_ID:
    case CLOCK_THREAD_CPUTIME_ID:
      retval = hp_timing_getres (res);
      break;
#endif
    }

  return retval;
}

Here is the call graph for this function:

static int realtime_getres ( struct timespec res) [inline, static]

Definition at line 60 of file clock_getres.c.

{
  long int clk_tck = sysconf (_SC_CLK_TCK);

  if (__builtin_expect (clk_tck != -1, 1))
    {
      /* This implementation assumes that the realtime clock has a
        resolution higher than 1 second.  This is the case for any
        reasonable implementation.  */
      res->tv_sec = 0;
      res->tv_nsec = 1000000000 / clk_tck;
      return 0;
    }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function: