--- a/include/mach/time_value.h +++ b/include/mach/time_value.h @@ -63,6 +63,39 @@ } /* + * Extended time specification. + */ + +struct time_spec { + integer_t seconds; + integer_t nanoseconds; +}; +typedef struct time_spec time_spec_t; + +/* + * Macros to manipulate time specs. Assume that time values + * are normalized (nanoseconds <= 999999999). + */ +#define TIME_NANOS_MAX (1000000000) + +#define time_spec_add_nsec(val, nanos) { \ + if (((val)->nanoseconds += (nanos)) \ + >= TIME_NANOS_MAX) { \ + (val)->nanoseconds -= TIME_NANOS_MAX; \ + (val)->seconds++; \ + } \ +} + +#define time_spec_add(result, addend) { \ + (result)->nanoseconds += (addend)->nanoseconds; \ + (result)->seconds += (addend)->seconds; \ + if ((result)->nanoseconds >= TIME_NANOS_MAX) { \ + (result)->nanoseconds -= TIME_NANOS_MAX; \ + (result)->seconds++; \ + } \ +} + +/* * Time value available through the mapped-time interface. * Read this mapped value with * do { @@ -77,4 +110,14 @@ integer_t check_seconds; } mapped_time_value_t; +typedef struct mapped_time_value_extended { + integer_t seconds; + integer_t microseconds; + integer_t check_seconds; + integer_t version; + /* new in version >= 1 */ + time_spec_t clock_rt; /* realtime clock */ + time_spec_t clock_mt; /* monotonic clock */ +} mapped_time_value_extended_t; + #endif /* _MACH_TIME_VALUE_H_ */