Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(1)

clock_getres(3)

clock_gettimedrift(3)

clock_settimedrift(3)

ctime(3)

timer_gettime(3)

clock_gettime(3)  —  Subroutines

Digital

NAME

clock_gettime, clock_settime − get or set the time for the specified clock (P1003.4/D10)

SYNOPSIS

#include <timers.h>

int clock_gettime (
int clock_id ,
struct timespec ∗tp) ;

int clock_settime (
int clock_id ,
const struct timespec ∗tp) ;

PARAMETERS

clock_id The clock type used to obtain the time or the clock that is set. The CLOCK_REALTIME clock is supported and represents the time-of-day clock for the system. 

tp A pointer to a timespec data structure. 

DESCRIPTION

The clock_gettime function returns the current time (in seconds and nanoseconds) for the specified clock.  The clock_settime function sets the specified clock. The CLOCK_REALTIME clock measures the amount of time elapsed since 00:00:00:00 January 1, 1970 Greenwich Mean Time (GMT), otherwise known as the Epoch. 

You must have superuser privileges to use the use the clock_settime function. 

RETURN VALUES

On a successful call, a value of 0 is returned. 

On an unsuccessful call, a value of −1 is returned and errno is set to indicate that an error occurred. 

ERRORS

The clock_gettime, and clock_settime, functions fail under the following conditions:

[EINVAL] The clock_id argument does not specify a known clock.  The tp agrument to clock_settime is outside the range for the given clock type.  Or, the tp argument specified a nanosecond value less than zero or greater than or equal to 1000 million. 

[EPERM] The requesting process does not have the appropriate privilege to set the specified clock. 

RELATED INFORMATION

time(1), clock_getres(3), clock_gettimedrift(3), clock_settimedrift(3), ctime(3), timer_gettime(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026