4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1997-1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
29 /* All Rights Reserved */
31 #ifndef _SYS_HRTCNTL_H
32 #define _SYS_HRTCNTL_H
34 #pragma ident "%Z%%M% %I% %E% SMI"
41 * The following are the possible commands for the hrtcntl,
42 * hrtalarm, and hrtsleep system calls.
45 typedef enum hrtcmds
{
47 /* hrtcntl commands */
48 HRT_GETRES
, /* Get the resolution of a clock. */
49 HRT_TOFD
, /* Get the value of time since */
50 /* 00:00:00 GMT, January 1, 1970 */
51 HRT_STARTIT
, /* Start timing an activity */
52 HRT_GETIT
, /* Return the interval time elapsed */
53 /* since the corresponding HRT_STARTIT */
54 /* command has been issued. */
55 /* hrtalarm commands */
56 HRT_ALARM
, /* Start a timer and post an alarm */
57 /* event after the time interval has */
59 HRT_RALARM
, /* Post an alarm repeatedly after */
60 /* every time interval. */
61 HRT_TODALARM
, /* Similar to HRT_ALARM except that */
62 /* the time at which the alarm is to */
63 /* posted is specified by an absolute */
65 HRT_INT_RPT
, /* Start a repeating alarm some time */
67 HRT_TOD_RPT
, /* Similar to HRT_INT_RPT except that */
68 /* the time of day when the alarm */
69 /* should begin is specified. */
70 HRT_PENDING
, /* Determine the time remaining until */
71 /* a pending alarm fires. */
72 /* hrtsleep commands */
73 HRT_INTSLP
, /* Put the process to sleep for an */
75 HRT_TODSLP
, /* Put the process to sleep until */
76 /* a specified time of day. */
78 * The following fields will be used
79 * to implement BSD timers
89 * Definitions for specifying rounding mode.
92 #define HRT_TRUNC 0 /* Round results down. */
93 #define HRT_RND 1 /* Round results (rnd up if fractional */
94 /* part >= .5 otherwise round down). */
95 #define HRT_RNDUP 2 /* Always round results up. */
98 * Definition for the type of internal buffer used with the
99 * HRT_STARTIT and HRT_GETIT commands.
102 typedef struct interval
{
103 unsigned long i_word1
;
104 unsigned long i_word2
;
109 * Structure used to represent a high-resolution time-of-day
113 typedef struct hrtime
{
114 ulong_t hrt_secs
; /* Seconds. */
115 long hrt_rem
; /* A value less than a second. */
116 ulong_t hrt_res
; /* The resolution of hrt_rem. */
121 * The structure used for the hrtalarm and hrtsleep system calls.
124 typedef struct hrtcmd
{
125 int hrtc_cmd
; /* A timer command. */
126 int hrtc_clk
; /* Which clock to use. */
127 hrtimes_t hrtc_int
; /* A time interval. */
128 hrtimes_t hrtc_tod
; /* A time of day. */
129 int hrtc_flags
; /* Various flags. */
130 int hrtc_error
; /* An error code */
131 /* (see eys/errno.h). */
133 ecb_t hrtc_ecb
; /* An event control block. */
138 * Flags for the hrtc_flags field.
141 #define HRTF_DONE 0x0001 /* The requested alarm has been set. */
142 #define HRTF_ERROR 0x0002 /* An error has been encountered. */
148 #define CLK_STD 0x0001 /* The standard real-time clock. */
149 #define CLK_USERVIRT 0x0002 /* A clock measuring user process */
151 #define CLK_PROCVIRT 0x0004 /* A clock measuring a process' virtual */
155 * Function Prototypes
156 * ===================
158 * The following are prototypes for the library functions which
162 #if defined(__STDC__) && !defined(_KERNEL)
163 int hrtcntl(int, int, interval_t
*, hrtimes_t
*);
164 int hrtalarm(hrtcmd_t
*, int);
165 int hrtsleep(hrtcmd_t
*);
166 int hrtcancel(const long *, int);
173 #endif /* _SYS_HRTCNTL_H */