1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1997-1999 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 28*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 29*0Sstevel@tonic-gate /* All Rights Reserved */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #ifndef _SYS_HRTCNTL_H 32*0Sstevel@tonic-gate #define _SYS_HRTCNTL_H 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * The following are the possible commands for the hrtcntl, 42*0Sstevel@tonic-gate * hrtalarm, and hrtsleep system calls. 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate typedef enum hrtcmds { 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate /* hrtcntl commands */ 48*0Sstevel@tonic-gate HRT_GETRES, /* Get the resolution of a clock. */ 49*0Sstevel@tonic-gate HRT_TOFD, /* Get the value of time since */ 50*0Sstevel@tonic-gate /* 00:00:00 GMT, January 1, 1970 */ 51*0Sstevel@tonic-gate HRT_STARTIT, /* Start timing an activity */ 52*0Sstevel@tonic-gate HRT_GETIT, /* Return the interval time elapsed */ 53*0Sstevel@tonic-gate /* since the corresponding HRT_STARTIT */ 54*0Sstevel@tonic-gate /* command has been issued. */ 55*0Sstevel@tonic-gate /* hrtalarm commands */ 56*0Sstevel@tonic-gate HRT_ALARM, /* Start a timer and post an alarm */ 57*0Sstevel@tonic-gate /* event after the time interval has */ 58*0Sstevel@tonic-gate /* elapsed. */ 59*0Sstevel@tonic-gate HRT_RALARM, /* Post an alarm repeatedly after */ 60*0Sstevel@tonic-gate /* every time interval. */ 61*0Sstevel@tonic-gate HRT_TODALARM, /* Similar to HRT_ALARM except that */ 62*0Sstevel@tonic-gate /* the time at which the alarm is to */ 63*0Sstevel@tonic-gate /* posted is specified by an absolute */ 64*0Sstevel@tonic-gate /* time. */ 65*0Sstevel@tonic-gate HRT_INT_RPT, /* Start a repeating alarm some time */ 66*0Sstevel@tonic-gate /* in the future. */ 67*0Sstevel@tonic-gate HRT_TOD_RPT, /* Similar to HRT_INT_RPT except that */ 68*0Sstevel@tonic-gate /* the time of day when the alarm */ 69*0Sstevel@tonic-gate /* should begin is specified. */ 70*0Sstevel@tonic-gate HRT_PENDING, /* Determine the time remaining until */ 71*0Sstevel@tonic-gate /* a pending alarm fires. */ 72*0Sstevel@tonic-gate /* hrtsleep commands */ 73*0Sstevel@tonic-gate HRT_INTSLP, /* Put the process to sleep for an */ 74*0Sstevel@tonic-gate /* interval. */ 75*0Sstevel@tonic-gate HRT_TODSLP, /* Put the process to sleep until */ 76*0Sstevel@tonic-gate /* a specified time of day. */ 77*0Sstevel@tonic-gate /* 78*0Sstevel@tonic-gate * The following fields will be used 79*0Sstevel@tonic-gate * to implement BSD timers 80*0Sstevel@tonic-gate */ 81*0Sstevel@tonic-gate HRT_BSD, 82*0Sstevel@tonic-gate HRT_BSD_PEND, 83*0Sstevel@tonic-gate HRT_RBSD, 84*0Sstevel@tonic-gate HRT_BSD_REP, 85*0Sstevel@tonic-gate HRT_BSD_CANCEL 86*0Sstevel@tonic-gate } hrtcmds_t; 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate /* 89*0Sstevel@tonic-gate * Definitions for specifying rounding mode. 90*0Sstevel@tonic-gate */ 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate #define HRT_TRUNC 0 /* Round results down. */ 93*0Sstevel@tonic-gate #define HRT_RND 1 /* Round results (rnd up if fractional */ 94*0Sstevel@tonic-gate /* part >= .5 otherwise round down). */ 95*0Sstevel@tonic-gate #define HRT_RNDUP 2 /* Always round results up. */ 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate /* 98*0Sstevel@tonic-gate * Definition for the type of internal buffer used with the 99*0Sstevel@tonic-gate * HRT_STARTIT and HRT_GETIT commands. 100*0Sstevel@tonic-gate */ 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate typedef struct interval { 103*0Sstevel@tonic-gate unsigned long i_word1; 104*0Sstevel@tonic-gate unsigned long i_word2; 105*0Sstevel@tonic-gate int i_clock; 106*0Sstevel@tonic-gate } interval_t; 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* 109*0Sstevel@tonic-gate * Structure used to represent a high-resolution time-of-day 110*0Sstevel@tonic-gate * or interval. 111*0Sstevel@tonic-gate */ 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate typedef struct hrtime { 114*0Sstevel@tonic-gate ulong_t hrt_secs; /* Seconds. */ 115*0Sstevel@tonic-gate long hrt_rem; /* A value less than a second. */ 116*0Sstevel@tonic-gate ulong_t hrt_res; /* The resolution of hrt_rem. */ 117*0Sstevel@tonic-gate } hrtimes_t; 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * The structure used for the hrtalarm and hrtsleep system calls. 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate typedef struct hrtcmd { 125*0Sstevel@tonic-gate int hrtc_cmd; /* A timer command. */ 126*0Sstevel@tonic-gate int hrtc_clk; /* Which clock to use. */ 127*0Sstevel@tonic-gate hrtimes_t hrtc_int; /* A time interval. */ 128*0Sstevel@tonic-gate hrtimes_t hrtc_tod; /* A time of day. */ 129*0Sstevel@tonic-gate int hrtc_flags; /* Various flags. */ 130*0Sstevel@tonic-gate int hrtc_error; /* An error code */ 131*0Sstevel@tonic-gate /* (see eys/errno.h). */ 132*0Sstevel@tonic-gate #ifdef notdef 133*0Sstevel@tonic-gate ecb_t hrtc_ecb; /* An event control block. */ 134*0Sstevel@tonic-gate #endif 135*0Sstevel@tonic-gate } hrtcmd_t; 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate /* 138*0Sstevel@tonic-gate * Flags for the hrtc_flags field. 139*0Sstevel@tonic-gate */ 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate #define HRTF_DONE 0x0001 /* The requested alarm has been set. */ 142*0Sstevel@tonic-gate #define HRTF_ERROR 0x0002 /* An error has been encountered. */ 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* 145*0Sstevel@tonic-gate * Multiple clocks 146*0Sstevel@tonic-gate */ 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate #define CLK_STD 0x0001 /* The standard real-time clock. */ 149*0Sstevel@tonic-gate #define CLK_USERVIRT 0x0002 /* A clock measuring user process */ 150*0Sstevel@tonic-gate /* virtual time. */ 151*0Sstevel@tonic-gate #define CLK_PROCVIRT 0x0004 /* A clock measuring a process' virtual */ 152*0Sstevel@tonic-gate /* time. */ 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate /* 155*0Sstevel@tonic-gate * Function Prototypes 156*0Sstevel@tonic-gate * =================== 157*0Sstevel@tonic-gate * 158*0Sstevel@tonic-gate * The following are prototypes for the library functions which 159*0Sstevel@tonic-gate * users call. 160*0Sstevel@tonic-gate */ 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate #if defined(__STDC__) && !defined(_KERNEL) 163*0Sstevel@tonic-gate int hrtcntl(int, int, interval_t *, hrtimes_t *); 164*0Sstevel@tonic-gate int hrtalarm(hrtcmd_t *, int); 165*0Sstevel@tonic-gate int hrtsleep(hrtcmd_t *); 166*0Sstevel@tonic-gate int hrtcancel(const long *, int); 167*0Sstevel@tonic-gate #endif 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate #ifdef __cplusplus 170*0Sstevel@tonic-gate } 171*0Sstevel@tonic-gate #endif 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate #endif /* _SYS_HRTCNTL_H */ 174