getclock

Gets the current value of the system-wide clock.

Format

#include  <timers.h>

int getclock  (int clktyp, struct timespec *tp);

Arguments

clktyp
The type of system-wide clock.
tp
Pointer to a timespec structure space where the current value of the system-wide clock is stored.

Description

This function sets the current value of the clock specified by clktyp into the location pointed to by tp.

The clktyp argument is given as a symbolic constant name, as defined in the <timers.h> header file. Only the TIMEOFDAY symbolic constant, which specifies the normal time-of-day clock to access for system-wide time, is supported.

For the clock specified by TIMEOFDAY, the value returned by this function is the elapsed time since the Epoch. The Epoch is referenced to 00:00:00 UTC (Coordinated Universal Time) 1 Jan 1970.

The getclock function returns a timespec structure, which is defined in the <timers.h> header file as follows:

 struct  timespec {

   unsigned long  tv_sec   /* Elapsed time in seconds since the Epoch*/
   long           tv_nsec  /* Elapsed time as a fraction of a second */
                           /* since the Epoch (expressed in nanoseconds */

 };

Return Values
Indicates success. 
-1  Indicates an error; errno is set to one of the following values:

  • EINVAL - The clktyp argument does not specify a known system-wide clock.

  • EIO - An error occurred when the system-wide clock specified by the clktyp argument was accessed.
 


Previous Page | Next Page | Table of Contents | Index