home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / hrtcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  4.5 KB  |  168 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_HRTCNTL_H
  11. #define _SYS_HRTCNTL_H
  12.  
  13. #ident    "@(#)/usr/include/sys/hrtcntl.h.sl 1.1 4.0 12/08/90 27504 AT&T-USL"
  14.  
  15. /* 
  16.  * The following are the possible commands for the hrtcntl,
  17.  * hrtalarm, and hrtsleep system calls.
  18.  */
  19.  
  20. typedef    enum    hrtcmds {
  21.  
  22.         /*   hrtcntl    commands   */
  23.     HRT_GETRES,        /* Get the resolution of a clock.      */
  24.     HRT_TOFD,        /* Get the value of time since           */
  25.                 /* 00:00:00 GMT, January 1, 1970       */
  26.     HRT_STARTIT,        /* Start timing an activity */
  27.     HRT_GETIT,        /* Return the interval time elapsed    */
  28.                 /* since the corresponding HRT_STARTIT **
  29.                 ** command has been issued.           */
  30.         /*   hrtalarm   commands   */
  31.     HRT_ALARM,        /* Start a timer and post an alarm     **
  32.                 ** event after the time interval has   **
  33.                 ** elapsed.                   */
  34.     HRT_RALARM,        /* Post an alarm repeatedly after      **
  35.                 ** every time interval.            */
  36.     HRT_TODALARM,            /* Similar to HRT_ALARM except that    **
  37.                 ** the time at which the alarm is to   **
  38.                 ** posted is specified by an absolute  **
  39.                 ** time.                   */
  40.     HRT_INT_RPT,        /* Start a repeating alarm some time   **
  41.                 ** in the future.                */
  42.     HRT_TOD_RPT,        /* Similar to HRT_INT_RPT except that  **
  43.                 ** the time of day when the alarm      **
  44.                 ** should begin is specified.          */
  45.     HRT_PENDING,        /* Determine the time remaining until  **
  46.                 ** a pending alarm fires.           */
  47.         /*   hrtsleep   commands  */
  48.     HRT_INTSLP,        /* Put the process to sleep for an     **
  49.                 ** interval.                   */
  50.     HRT_TODSLP,        /* Put the process to sleep until      **
  51.                 ** a specified time of day.            */
  52.         /*   The following fields will be used
  53.          *   to implement BSD timers
  54.          */
  55.     HRT_BSD,
  56.     HRT_BSD_PEND,
  57.     HRT_RBSD,
  58.     HRT_BSD_REP,
  59.     HRT_BSD_CANCEL
  60. } hrtcmds_t;
  61.  
  62. /*
  63.  *    Definitions for commonly used resolutions.
  64.  */
  65.  
  66. #define    SEC        1
  67. #define    MILLISEC    1000
  68. #define MICROSEC    1000000
  69. #define NANOSEC        1000000000
  70.  
  71. /*
  72.  * Scaling factor used to save
  73.  * fractional remainder.
  74.  */
  75. #define SCALE        1000000
  76.  
  77. /*
  78.  *    Definitions for specifying rounding mode.
  79.  */
  80.  
  81. #define HRT_TRUNC    0    /* Round results down.    */
  82. #define HRT_RND        1    /* Round results (rnd up if fractional    */
  83.                 /*   part >= .5 otherwise round down).    */
  84. #define    HRT_RNDUP    2    /* Always round results up.    */
  85.  
  86. /*
  87.  *    Definition for the type of internal buffer used with the
  88.  *    HRT_STARTIT and HRT_GETIT commands.
  89.  */
  90.  
  91. typedef    struct interval {
  92.     unsigned long    i_word1;
  93.     unsigned long    i_word2;
  94.     int        i_clock;
  95. } interval_t;
  96.  
  97. /*
  98.  *    Structure used to represent a high-resolution time-of-day
  99.  *    or interval.
  100.  */
  101.  
  102. typedef struct hrtime {
  103.     ulong    hrt_secs;    /* Seconds.                */
  104.     long    hrt_rem;    /* A value less than a second.        */
  105.     ulong    hrt_res;    /* The resolution of hrt_rem.        */
  106. } hrtime_t;
  107.  
  108. /*
  109.  * Data returned by hrtcancel if the ECBF_POSTCAN flag is set.
  110.  */
  111.  
  112. typedef    struct evd_hrt {
  113.     hrtime_t  hrte_time;    /* The time when the alarm        */
  114.                 /* would next have fired. A        */
  115.                 /* time-of-day or an interval depending */
  116.                 /* on the type of the alarm.        */
  117. } evd_hrt_t;
  118.  
  119.  
  120.  
  121. /*
  122.  *    The structure used for the hrtalarm and hrtsleep system calls.
  123.  */
  124.  
  125. typedef struct hrtcmd {
  126.     int        hrtc_cmd;    /* A timer command.        */
  127.     int        hrtc_clk;    /* Which clock to use.        */    
  128.     hrtime_t    hrtc_int;    /* A time interval.        */
  129.     hrtime_t    hrtc_tod;    /* A time of day.        */
  130.     int        hrtc_flags;    /* Various flags.         */
  131.     int        hrtc_error;    /* An error code        */
  132.                     /* (see eys/errno.h).        */
  133.     ecb_t        hrtc_ecb;    /* An event control block.    */
  134. } hrtcmd_t;
  135.  
  136. /*
  137.  * Flags for the hrtc_flags field.
  138.  */
  139.  
  140. #define    HRTF_DONE    0x0001    /* The requested alarm has been set.    */
  141. #define    HRTF_ERROR    0x0002    /* An error has been encountered.    */
  142.  
  143. /*
  144.  * Multiple clocks
  145.  */
  146.  
  147. #define CLK_STD        0x0001    /* The standard real-time clock.    */
  148. #define CLK_USERVIRT    0x0002    /* A clock measuring user process    */
  149.                 /* virtual time.            */
  150. #define CLK_PROCVIRT    0x0004    /* A clock measuring a process' virtual */
  151.                 /* time.                */
  152.  
  153. /*            Function Prototypes
  154. **            ===================
  155. **
  156. **    The following are prototypes for the library functions which
  157. **    users call. 
  158. */
  159.  
  160. #if defined(__STDC__) && !defined(_KERNEL)
  161. int   hrtcntl(int, int, interval_t *, hrtime_t *);
  162. int   hrtalarm(hrtcmd_t *, int);
  163. int   hrtsleep(hrtcmd_t *);
  164. int   hrtcancel(const long *, int);
  165. #endif
  166.  
  167. #endif    /* _SYS_HRTCNTL_H */
  168.