/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#ifndef _KERN_CLOCK_H_
#define _KERN_CLOCK_H_
-#include <mach/message.h>
+#include <stdint.h>
+#include <mach/mach_types.h>
#include <mach/clock_types.h>
+#include <mach/message.h>
#include <mach/mach_time.h>
-#include <sys/appleapiopts.h>
+#include <kern/kern_types.h>
-#ifdef __APPLE_API_PRIVATE
+#include <sys/cdefs.h>
#ifdef MACH_KERNEL_PRIVATE
-#include <ipc/ipc_port.h>
-
/*
* Actual clock alarm structure. Used for user clock_sleep() and
* clock_alarm() calls. Alarms are allocated from the alarm free
extern void clock_set_timer_deadline(
uint64_t deadline);
-extern void mk_timebase_info(
- uint32_t *delta,
- uint32_t *abs_to_ns_numer,
- uint32_t *abs_to_ns_denom,
- uint32_t *proc_to_abs_numer,
- uint32_t *proc_to_abs_denom);
-
extern uint32_t clock_set_calendar_adjtime(
int32_t *secs,
int32_t *microsecs);
extern uint32_t clock_adjust_calendar(void);
-#endif /* MACH_KERNEL_PRIVATE */
+extern void machine_delay_until(
+ uint64_t deadline);
-extern void clock_get_calendar_microtime(
- uint32_t *secs,
- uint32_t *microsecs);
+#include <stat_time.h>
-extern void clock_get_calendar_nanotime(
- uint32_t *secs,
- uint32_t *nanosecs);
+extern void hertz_tick(
+#if STAT_TIME
+ natural_t ticks,
+#endif /* STAT_TIME */
+ boolean_t usermode, /* executing user code */
+ natural_t pc);
-extern void clock_set_calendar_microtime(
- uint32_t secs,
- uint32_t microsecs);
+extern void absolutetime_to_microtime(
+ uint64_t abstime,
+ uint32_t *secs,
+ uint32_t *microsecs);
-extern void clock_get_system_microtime(
- uint32_t *secs,
- uint32_t *microsecs);
+#endif /* MACH_KERNEL_PRIVATE */
-extern void clock_get_system_nanotime(
- uint32_t *secs,
- uint32_t *nanosecs);
+__BEGIN_DECLS
+
+#ifdef XNU_KERNEL_PRIVATE
extern void clock_adjtime(
int32_t *secs,
uint32_t *secs,
uint32_t *microsecs);
-#endif /* __APPLE_API_PRIVATE */
+extern void clock_set_calendar_microtime(
+ uint32_t secs,
+ uint32_t microsecs);
-#ifdef __APPLE_API_UNSTABLE
+extern void clock_get_boottime_nanotime(
+ uint32_t *secs,
+ uint32_t *nanosecs);
-#define MACH_TIMESPEC_SEC_MAX (0 - 1)
-#define MACH_TIMESPEC_NSEC_MAX (NSEC_PER_SEC - 1)
+extern void clock_deadline_for_periodic_event(
+ uint64_t interval,
+ uint64_t abstime,
+ uint64_t *deadline);
-#define MACH_TIMESPEC_MAX ((mach_timespec_t) { \
- MACH_TIMESPEC_SEC_MAX, \
- MACH_TIMESPEC_NSEC_MAX } )
-#define MACH_TIMESPEC_ZERO ((mach_timespec_t) { 0, 0 } )
+#endif /* XNU_KERNEL_PRIVATE */
-#define ADD_MACH_TIMESPEC_NSEC(t1, nsec) \
- do { \
- (t1)->tv_nsec += (clock_res_t)(nsec); \
- if ((clock_res_t)(nsec) > 0 && \
- (t1)->tv_nsec >= NSEC_PER_SEC) { \
- (t1)->tv_nsec -= NSEC_PER_SEC; \
- (t1)->tv_sec += 1; \
- } \
- else if ((clock_res_t)(nsec) < 0 && \
- (t1)->tv_nsec < 0) { \
- (t1)->tv_nsec += NSEC_PER_SEC; \
- (t1)->tv_sec -= 1; \
- } \
- } while (0)
-#endif /* __APPLE_API_UNSTABLE */
+extern void clock_get_calendar_microtime(
+ uint32_t *secs,
+ uint32_t *microsecs);
-extern mach_timespec_t clock_get_system_value(void);
+extern void clock_get_calendar_nanotime(
+ uint32_t *secs,
+ uint32_t *nanosecs);
-extern mach_timespec_t clock_get_calendar_value(void);
+extern void clock_get_system_microtime(
+ uint32_t *secs,
+ uint32_t *microsecs);
+
+extern void clock_get_system_nanotime(
+ uint32_t *secs,
+ uint32_t *nanosecs);
extern void clock_timebase_info(
mach_timebase_info_t info);
uint64_t abstime,
uint64_t *result);
-extern void clock_deadline_for_periodic_event(
- uint64_t interval,
- uint64_t abstime,
- uint64_t *deadline);
-
-extern void clock_delay_for_interval(
- uint32_t interval,
- uint32_t scale_factor);
-
extern void clock_delay_until(
uint64_t deadline);
uint64_t nanoseconds,
uint64_t *result);
-#if !defined(MACH_KERNEL_PRIVATE) && !defined(ABSOLUTETIME_SCALAR_TYPE)
+#ifdef KERNEL_PRIVATE
-#include <libkern/OSBase.h>
+/*
+ * Obsolete interfaces.
+ */
+
+#define MACH_TIMESPEC_SEC_MAX (0 - 1)
+#define MACH_TIMESPEC_NSEC_MAX (NSEC_PER_SEC - 1)
+
+#define MACH_TIMESPEC_MAX ((mach_timespec_t) { \
+ MACH_TIMESPEC_SEC_MAX, \
+ MACH_TIMESPEC_NSEC_MAX } )
+#define MACH_TIMESPEC_ZERO ((mach_timespec_t) { 0, 0 } )
+
+#define ADD_MACH_TIMESPEC_NSEC(t1, nsec) \
+ do { \
+ (t1)->tv_nsec += (clock_res_t)(nsec); \
+ if ((clock_res_t)(nsec) > 0 && \
+ (t1)->tv_nsec >= NSEC_PER_SEC) { \
+ (t1)->tv_nsec -= NSEC_PER_SEC; \
+ (t1)->tv_sec += 1; \
+ } \
+ else if ((clock_res_t)(nsec) < 0 && \
+ (t1)->tv_nsec < 0) { \
+ (t1)->tv_nsec += NSEC_PER_SEC; \
+ (t1)->tv_sec -= 1; \
+ } \
+ } while (0)
+
+
+extern mach_timespec_t clock_get_system_value(void);
+
+extern mach_timespec_t clock_get_calendar_value(void);
+
+extern void delay_for_interval(
+ uint32_t interval,
+ uint32_t scale_factor);
+#ifndef MACH_KERNEL_PRIVATE
+
+#ifndef ABSOLUTETIME_SCALAR_TYPE
#define clock_get_uptime(a) \
clock_get_uptime(__OSAbsoluteTimePtr(a))
#define nanoseconds_to_absolutetime(a, b) \
nanoseconds_to_absolutetime((a), __OSAbsoluteTimePtr(b))
-#define AbsoluteTime_to_scalar(x) (*(uint64_t *)(x))
-
-/* t1 < = > t2 */
-#define CMP_ABSOLUTETIME(t1, t2) \
- (AbsoluteTime_to_scalar(t1) > \
- AbsoluteTime_to_scalar(t2)? (int)+1 : \
- (AbsoluteTime_to_scalar(t1) < \
- AbsoluteTime_to_scalar(t2)? (int)-1 : 0))
-
-/* t1 += t2 */
-#define ADD_ABSOLUTETIME(t1, t2) \
- (AbsoluteTime_to_scalar(t1) += \
- AbsoluteTime_to_scalar(t2))
+#endif /* ABSOLUTETIME_SCALAR_TYPE */
-/* t1 -= t2 */
-#define SUB_ABSOLUTETIME(t1, t2) \
- (AbsoluteTime_to_scalar(t1) -= \
- AbsoluteTime_to_scalar(t2))
+#endif /* !MACH_KERNEL_PRIVATE */
-#define ADD_ABSOLUTETIME_TICKS(t1, ticks) \
- (AbsoluteTime_to_scalar(t1) += \
- (int32_t)(ticks))
+#endif /* KERNEL_PRIVATE */
-#endif
+__END_DECLS
#endif /* _KERN_CLOCK_H_ */