Chameleon

Chameleon Svn Source Tree

Root/tags/2.3/i386/include/mach/clock_types.h

Source at commit 2862 created 7 years 25 days ago.
By ifabio, Tag 2.3 release, bump svn to 2.4
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 *File:clock_types.h
33 *Purpose:Clock facility header definitions. These
34 *definitons are needed by both kernel and
35 *user-level software.
36 */
37
38/*
39 *All interfaces defined here are obsolete.
40 */
41
42#ifndef_MACH_CLOCK_TYPES_H_
43#define_MACH_CLOCK_TYPES_H_
44
45#include <stdint.h>
46#include <mach/time_value.h>
47
48/*
49 * Type definitions.
50 */
51typedefintalarm_type_t;/* alarm time type */
52typedef intsleep_type_t;/* sleep time type */
53typedefintclock_id_t;/* clock identification type */
54typedef intclock_flavor_t;/* clock flavor type */
55typedef int*clock_attr_t;/* clock attribute type */
56typedef intclock_res_t;/* clock resolution type */
57
58/*
59 * Normal time specification used by the kernel clock facility.
60 */
61struct mach_timespec {
62unsigned inttv_sec;/* seconds */
63clock_res_ttv_nsec;/* nanoseconds */
64};
65typedef struct mach_timespecmach_timespec_t;
66
67/*
68 * Reserved clock id values for default clocks.
69 */
70#define SYSTEM_CLOCK0
71#define CALENDAR_CLOCK1
72
73#define REALTIME_CLOCK0
74
75/*
76 * Attribute names.
77 */
78#defineCLOCK_GET_TIME_RES1/* get_time call resolution */
79/*2 * was map_time call resolution */
80#define CLOCK_ALARM_CURRES3/* current alarm resolution */
81#define CLOCK_ALARM_MINRES4/* minimum alarm resolution */
82#define CLOCK_ALARM_MAXRES5/* maximum alarm resolution */
83
84#define NSEC_PER_USEC1000/* nanoseconds per microsecond */
85#define USEC_PER_SEC1000000/* microseconds per second */
86#define NSEC_PER_SEC1000000000/* nanoseconds per second */
87
88#define BAD_MACH_TIMESPEC(t)\
89((t)->tv_nsec < 0 || (t)->tv_nsec >= NSEC_PER_SEC)
90
91/* t1 <=> t2, also (t1 - t2) in nsec with max of +- 1 sec */
92#define CMP_MACH_TIMESPEC(t1, t2)\
93((t1)->tv_sec > (t2)->tv_sec ? +NSEC_PER_SEC :\
94((t1)->tv_sec < (t2)->tv_sec ? -NSEC_PER_SEC :\
95(t1)->tv_nsec - (t2)->tv_nsec))
96
97/* t1 += t2 */
98#define ADD_MACH_TIMESPEC(t1, t2)\
99 do {\
100if (((t1)->tv_nsec += (t2)->tv_nsec) >= NSEC_PER_SEC) {\
101(t1)->tv_nsec -= NSEC_PER_SEC;\
102(t1)->tv_sec += 1;\
103}\
104(t1)->tv_sec += (t2)->tv_sec;\
105 } while (0)
106
107/* t1 -= t2 */
108#define SUB_MACH_TIMESPEC(t1, t2)\
109 do {\
110if (((t1)->tv_nsec -= (t2)->tv_nsec) < 0) {\
111(t1)->tv_nsec += NSEC_PER_SEC;\
112(t1)->tv_sec -= 1;\
113}\
114(t1)->tv_sec -= (t2)->tv_sec;\
115 } while (0)
116
117/*
118 * Alarm parameter defines.
119 */
120#define ALRMTYPE0xff/* type (8-bit field)*/
121#define TIME_ABSOLUTE0x00/* absolute time */
122#defineTIME_RELATIVE0x01/* relative time */
123
124#define BAD_ALRMTYPE(t)(((t) &~ TIME_RELATIVE) != 0)
125
126#endif /* _MACH_CLOCK_TYPES_H_ */
127

Archive Download this file

Revision: 2862