Back to index

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

Go to the source code of this file.

Functions

static int realtime_gettime (struct timespec *tp)
int clock_gettime (clockid_t clock_id, struct timespec *tp)

Function Documentation

int clock_gettime ( clockid_t  clock_id,
struct timespec tp 
)

Definition at line 93 of file clock_gettime.c.

{
  int retval = -1;

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

#ifndef HANDLED_REALTIME
    case CLOCK_REALTIME:
      {
       struct timeval tv;
       retval = gettimeofday (&tv, NULL);
       if (retval == 0)
         TIMEVAL_TO_TIMESPEC (&tv, tp);
      }
      break;
#endif

    default:
#ifdef SYSDEP_GETTIME_CPU
      SYSDEP_GETTIME_CPU;
#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;

#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
    case CLOCK_PROCESS_CPUTIME_ID:
      retval = hp_timing_gettime (clock_id, tp);
      break;
#endif
    }

  return retval;
}

Here is the call graph for this function:

static int realtime_gettime ( struct timespec tp) [inline, static]

Definition at line 80 of file clock_gettime.c.

{
  struct timeval tv;
  int retval = gettimeofday (&tv, NULL);
  if (retval == 0)
    /* Convert into `timespec'.  */
    TIMEVAL_TO_TIMESPEC (&tv, tp);
  return retval;
}

Here is the call graph for this function: