#include <mach/clock_types.h> also included by <mach/mach.h>

mach/clock_types.h

File: clock_types.h Purpose: Clock facility header definitions. These definitons are needed by both kernel and user-level software.
19 macros · 7 typedefs · 1 struct

typedefalarm_type_t

Type definitions.
typedef int alarm_type_t
alarm time type
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defined values:
TIME_RELATIVEInterpret the alarm time as relative to the current time.
TIME_ABSOLUTEInterpret the alarm time as an absolute time.

typedefsleep_type_t

typedef int sleep_type_t
sleep time type
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defined values:
TIME_RELATIVEInterpret the sleep time as relative to the current time.
TIME_ABSOLUTEInterpret the sleep time as an absolute time.

typedefclock_id_t

typedef int clock_id_t
clock identification type
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defined values:
REALTIME_CLOCKA moderate resolution clock service that (typically) tracks time since the system last boot.
BATTERY_CLOCKA (typically) low resolution clock (to the second) that survives power failures or service outages.
HIGHRES_CLOCKA high resolution clock.

typedefclock_flavor_t

typedef int clock_flavor_t
clock flavor type
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defined values:
CLOCK_GET_TIME_RESThe resolution, in nanoseconds, with which the value returned by clock_get_time is updated.
CLOCK_MAP_TIME_RESThe resolution, in nanoseconds, with which the value visible via clock_map_time is updated.
CLOCK_ALARM_CURRESThe resolution, in nanoseconds, at which clock alarm and sleep timers are currently serviced.
CLOCK_ALARM_MINRESThe minimum resolution, in nanoseconds, at which clock alarm and sleep timers can be serviced.
CLOCK_ALARM_MAXRESThe maximum resolution, in nanoseconds, at which clock alarm and sleep timers can be serviced.

typedefclock_attr_t

typedef int *clock_attr_t
clock attribute type

typedefclock_res_t

typedef int clock_res_t
clock resolution type

structmach_timespec

Normal time specification used by the kernel clock facility.
size 8, align 4
unsigned inttv_secseconds
clock_res_ttv_nsecnanoseconds

typedefmach_timespec_t

typedef struct mach_timespec mach_timespec_t

macroSYSTEM_CLOCK

Reserved clock id values for default clocks.
#define SYSTEM_CLOCK 0

macroCALENDAR_CLOCK

#define CALENDAR_CLOCK 1

macroREALTIME_CLOCK

#define REALTIME_CLOCK 0
CMU/MIT Mach reference · manual page · © Carnegie Mellon
A moderate resolution clock service that (typically) tracks time since the system last boot.
a value of clock_id_t

macroCLOCK_GET_TIME_RES

Attribute names.
#define CLOCK_GET_TIME_RES 1
get_time call resolution
CMU/MIT Mach reference · manual page · © Carnegie Mellon
The resolution, in nanoseconds, with which the value returned by clock_get_time is updated.
a value of clock_flavor_t

macroCLOCK_ALARM_CURRES

2 * was map_time call resolution
#define CLOCK_ALARM_CURRES 3
current alarm resolution
CMU/MIT Mach reference · manual page · © Carnegie Mellon
The resolution, in nanoseconds, at which clock alarm and sleep timers are currently serviced.
a value of clock_flavor_t

macroCLOCK_ALARM_MINRES

#define CLOCK_ALARM_MINRES 4
minimum alarm resolution
CMU/MIT Mach reference · manual page · © Carnegie Mellon
The minimum resolution, in nanoseconds, at which clock alarm and sleep timers can be serviced.
a value of clock_flavor_t

macroCLOCK_ALARM_MAXRES

#define CLOCK_ALARM_MAXRES 5
maximum alarm resolution
CMU/MIT Mach reference · manual page · © Carnegie Mellon
The maximum resolution, in nanoseconds, at which clock alarm and sleep timers can be serviced.
a value of clock_flavor_t

macroNSEC_PER_USEC

#define NSEC_PER_USEC 1000ull
nanoseconds per microsecond

macroUSEC_PER_SEC

#define USEC_PER_SEC 1000000ull
microseconds per second

macroNSEC_PER_SEC

#define NSEC_PER_SEC 1000000000ull
nanoseconds per second

macroNSEC_PER_MSEC

#define NSEC_PER_MSEC 1000000ull
nanoseconds per millisecond

macroBAD_MACH_TIMESPEC

#define BAD_MACH_TIMESPEC(t) ((t)->tv_nsec < 0 || (t)->tv_nsec >= (long)NSEC_PER_SEC)

macroCMP_MACH_TIMESPEC

t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec
#define CMP_MACH_TIMESPEC(t1, t2) ((t1)->tv_sec > (t2)->tv_sec ? (long) +NSEC_PER_SEC :
	((t1)->tv_sec < (t2)->tv_sec ? (long) -NSEC_PER_SEC :
	                (t1)->tv_nsec - (t2)->tv_nsec))

macroADD_MACH_TIMESPEC

t1 += t2
#define ADD_MACH_TIMESPEC(t1, t2) do {
	if (((t1)->tv_nsec += (t2)->tv_nsec) >= (long) NSEC_PER_SEC) {
	        (t1)->tv_nsec -= (long) NSEC_PER_SEC;
	        (t1)->tv_sec  += 1;
	}
	(t1)->tv_sec += (t2)->tv_sec;
  } while (0)

macroSUB_MACH_TIMESPEC

t1 -= t2
#define SUB_MACH_TIMESPEC(t1, t2) do {
	if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) {
	        (t1)->tv_nsec += (long) NSEC_PER_SEC;
	        (t1)->tv_sec  -= 1;
	}
	(t1)->tv_sec -= (t2)->tv_sec;
  } while (0)

macroALRMTYPE

Alarm parameter defines.
#define ALRMTYPE 0xff
type (8-bit field)

macroTIME_ABSOLUTE

#define TIME_ABSOLUTE 0x00
absolute time
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Interpret the alarm time as an absolute time.
a value of alarm_type_t

macroTIME_RELATIVE

#define TIME_RELATIVE 0x01
relative time
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Interpret the alarm time as relative to the current time.
a value of alarm_type_t

macroBAD_ALRMTYPE

#define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0)