NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | CAVEAT | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO
#include <sys/time.h>int gettimeofday(struct timeval * tp, struct timezone * tzp);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The current Greenwich mean time and the current time zone on the system are obtained using the gettimeofday() call, and set with the settimeofday() call. The time is expressed as the number of seconds and microseconds since midnight (0 hours), January 1, 1970. The resolution of the system clock is hardware-dependent, and the time may be updated continuously or in ``ticks''. If tp or tzp is NULL, the associated time information will not be returned or set.
The structures pointed to by tp and tzp are defined in sys/time.h as:
struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; struct timezone { int tz_minuteswest; /* of Greenwich */ int tz_dsttime; /* type of dst correction to apply */ }; |
The timezone structure indicates the local time zone (measured in minutes of time westward from Greenwich), and a flag that, if non zero, indicates that Daylight Saving time applies locally during the appropriate part of the year.
Only the super-user may set the time of day or time zone.
gettimeofday() returns a time always strictly greater than the "last time" it returned. This behaviour can create a time inconsistency if POSIX APIs and microkernel APIs are used interchangeably. The problem occurs when a time is set in the past using univTimeSet() . The next time gettimeofday() is called, it will not return the current time, as just set by univTimeSet() , but the time it had stored previously (assuming it is still greater than the current time).
If successful, gettimeofday() returns 0, otherwise it returns -1, and sets errno to indicate one of the following error conditions.
The address of an argument referenced invalid memory.
A user other than the super-user attempted to set the time.
The structure pointed to by tp specifies an invalid time. The value of tv_sec is not within a valid range (0 to 999999). The value of tv_usec is not within valid range (-999999 to 999999).
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | CAVEAT | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO