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