#include <sys/time.h>

sys/time.h

18 macros · 8 functions · 3 structs

structitimerval

Structure used as a parameter by getitimer(2) and setitimer(2) system calls.
size 32, align 8
struct timevalit_intervaltimer interval
struct timevalit_valuecurrent value

macroITIMER_REAL

Names of the interval timers, and structure defining a timer setting.
#define ITIMER_REAL 0

macroITIMER_VIRTUAL

#define ITIMER_VIRTUAL 1

macroITIMER_PROF

#define ITIMER_PROF 2

macroTIMEVAL_TO_TIMESPEC

#define TIMEVAL_TO_TIMESPEC(tv, ts) {
	(ts)->tv_sec = (tv)->tv_sec;
	(ts)->tv_nsec = (tv)->tv_usec * 1000;
}

macroTIMESPEC_TO_TIMEVAL

#define TIMESPEC_TO_TIMEVAL(tv, ts) {
	(tv)->tv_sec = (ts)->tv_sec;
	(tv)->tv_usec = (__darwin_suseconds_t)((ts)->tv_nsec / 1000);
}

structtimezone

size 8, align 4
inttz_minuteswestminutes west of Greenwich
inttz_dsttimetype of dst correction

macroDST_NONE

#define DST_NONE 0
not on dst

macroDST_USA

#define DST_USA 1
USA style dst

macroDST_AUST

#define DST_AUST 2
Australian style dst

macroDST_WET

#define DST_WET 3
Western European dst

macroDST_MET

#define DST_MET 4
Middle European dst

macroDST_EET

#define DST_EET 5
Eastern European dst

macroDST_CAN

#define DST_CAN 6
Canada

macrotimerclear

Operations on timevals.
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0

macrotimerisset

#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)

macrotimercmp

#define timercmp(tvp, uvp, cmp) (((tvp)->tv_sec == (uvp)->tv_sec) ?
	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :
	    ((tvp)->tv_sec cmp (uvp)->tv_sec))

macrotimeradd

#define timeradd(tvp, uvp, vvp) do {
	        (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;
	        (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;
	        if ((vvp)->tv_usec >= 1000000) {
	                (vvp)->tv_sec++;
	                (vvp)->tv_usec -= 1000000;
	        }
	} while (0)

macrotimersub

#define timersub(tvp, uvp, vvp) do {
	        (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;
	        (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;
	        if ((vvp)->tv_usec < 0) {
	                (vvp)->tv_sec--;
	                (vvp)->tv_usec += 1000000;
	        }
	} while (0)

macrotimevalcmp

#define timevalcmp(l, r, cmp) timercmp(l, r, cmp)
freebsd

structclockinfo

Getkerninfo clock information structure
size 20, align 4
inthzclock frequency
inttickmicro-seconds per hz tick
inttickadjclock skew rate for adjtime()
intstathzstatistics clock frequency
intprofhzprofiling clock frequency

functionadjtime

int adjtime(const struct timeval *, struct timeval *)
man page · June 4, 1993
adjtime(2) — "correct the time to allow synchronization of the system clock"

functionfutimes

int futimes(int, const struct timeval *)
man page · June 4, 1993
futimes(2) — set file access and modification times

functionlutimes

__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int lutimes(const char *, const struct timeval *)
man page · Aug 13, 2006
lutimes(3) — set file access and modification times of symlink

functionsettimeofday

int settimeofday(const struct timeval *, const struct timezone *)
man page · August 5, 2008
settimeofday(2) — get/set date and time

functiongetitimer

int getitimer(int, struct itimerval *)
man page · December 11, 1993
getitimer(2) — get/set value of interval timer

functiongettimeofday

int gettimeofday(struct timeval * __restrict, void * __restrict)
man page · August 5, 2008
gettimeofday(2) — get/set date and time

functionsetitimer

int setitimer(int, const struct itimerval * __restrict, struct itimerval * __restrict)
man page · December 11, 1993
setitimer(2) — get/set value of interval timer

functionutimes

int utimes(const char *, const struct timeval *)
man page · June 4, 1993
utimes(2) — set file access and modification times