2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
30 * Purpose: Clock facility header definitions. These
31 * definitons are needed by both kernel and
32 * user-level software.
36 * N.B. This interface has been deprecated and the contents
37 * of this file should be considered obsolete.
40 #ifndef _MACH_CLOCK_TYPES_H_
41 #define _MACH_CLOCK_TYPES_H_
43 #include <mach/time_value.h>
44 #include <sys/appleapiopts.h>
49 typedef int alarm_type_t
; /* alarm time type */
50 typedef int sleep_type_t
; /* sleep time type */
51 typedef int clock_id_t
; /* clock identification type */
52 typedef int clock_flavor_t
; /* clock flavor type */
53 typedef int *clock_attr_t
; /* clock attribute type */
54 typedef int clock_res_t
; /* clock resolution type */
57 * Normal time specification used by the kernel clock facility.
59 struct mach_timespec
{
60 unsigned int tv_sec
; /* seconds */
61 clock_res_t tv_nsec
; /* nanoseconds */
63 typedef struct mach_timespec mach_timespec_t
;
65 #ifdef __APPLE_API_UNSTABLE
68 * Reserved clock id values for default clocks.
70 #define SYSTEM_CLOCK 0 /* advances monotonically and
71 * uniformly; set to zero at boot */
72 #define CALENDAR_CLOCK 1 /* 'wall' clock; effectively
73 * synchronized to UTC */
75 #define REALTIME_CLOCK 0 /* obsolete; use SYSTEM or CALENDAR
76 * clock depending on particular
82 #define CLOCK_GET_TIME_RES 1 /* get_time call resolution */
83 /* 2 * was map_time call resolution */
84 #define CLOCK_ALARM_CURRES 3 /* current alarm resolution */
85 #define CLOCK_ALARM_MINRES 4 /* minimum alarm resolution */
86 #define CLOCK_ALARM_MAXRES 5 /* maximum alarm resolution */
88 #define NSEC_PER_USEC 1000 /* nanoseconds per microsecond */
89 #define USEC_PER_SEC 1000000 /* microseconds per second */
90 #define NSEC_PER_SEC 1000000000 /* nanoseconds per second */
92 #define BAD_MACH_TIMESPEC(t) \
93 ((t)->tv_nsec < 0 || (t)->tv_nsec >= NSEC_PER_SEC)
95 /* t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec */
96 #define CMP_MACH_TIMESPEC(t1, t2) \
97 ((t1)->tv_sec > (t2)->tv_sec ? +NSEC_PER_SEC : \
98 ((t1)->tv_sec < (t2)->tv_sec ? -NSEC_PER_SEC : \
99 (t1)->tv_nsec - (t2)->tv_nsec))
102 #define ADD_MACH_TIMESPEC(t1, t2) \
104 if (((t1)->tv_nsec += (t2)->tv_nsec) >= NSEC_PER_SEC) { \
105 (t1)->tv_nsec -= NSEC_PER_SEC; \
108 (t1)->tv_sec += (t2)->tv_sec; \
112 #define SUB_MACH_TIMESPEC(t1, t2) \
114 if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) { \
115 (t1)->tv_nsec += NSEC_PER_SEC; \
118 (t1)->tv_sec -= (t2)->tv_sec; \
122 * Alarm parameter defines.
124 #define ALRMTYPE 0xff /* type (8-bit field) */
125 #define TIME_ABSOLUTE 0x00 /* absolute time */
126 #define TIME_RELATIVE 0x01 /* relative time */
128 #define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0)
130 #endif /* __APPLE_API_UNSTABLE */
132 #endif /* _MACH_CLOCK_TYPES_H_ */