home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.18 / usr / include / sys / time.h / time.h
Encoding:
C/C++ Source or Header  |  1998-08-18  |  5.3 KB  |  209 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. #ifndef _SVC_TIME_H    /* wrapper symbol for kernel use */
  12. #define _SVC_TIME_H    /* subject to change without notice */
  13.  
  14. #ident    "@(#)kern:svc/time.h    1.19.2.1"
  15. #ident    "$Header: $"
  16.  
  17. #if defined(__cplusplus)
  18. extern "C" {
  19. #endif
  20.  
  21. /*
  22.  *    Copyright (c) 1982, 1986, 1988
  23.  *    The Regents of the University of California
  24.  *    All Rights Reserved.
  25.  *    Portions of this document are derived from
  26.  *    software developed by the University of
  27.  *    California, Berkeley, and its contributors.
  28.  */
  29.  
  30. /*
  31.  * Structure returned by gettimeofday(2) system call,
  32.  * and used in other calls.
  33.  */
  34.  
  35. #ifdef _KERNEL_HEADERS
  36.  
  37. #include <util/types.h>    /* REQUIRED */
  38.  
  39. #elif defined(_KERNEL) || defined(_KMEMUSER)
  40.  
  41. #include <sys/types.h>    /* REQUIRED */
  42.  
  43. #else
  44.  
  45. #include <sys/types.h> 
  46.  
  47. #endif /* _KERNEL_HEADERS */
  48.  
  49. #if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 >= 1) \
  50.  || ( !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
  51.  && !defined(_XOPEN_SOURCE))
  52.  
  53. #ifndef _TIMEVAL_STR
  54. #define _TIMEVAL_STR
  55. struct timeval {
  56.     long    tv_sec;        /* seconds */
  57.     long    tv_usec;    /* and microseconds */
  58. };
  59. #endif
  60.  
  61. #endif
  62.  
  63. #if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
  64. struct timezone {
  65.     int    tz_minuteswest;    /* minutes west of Greenwich */
  66.     int    tz_dsttime;    /* type of dst correction */
  67. };
  68. #define    DST_NONE    0    /* not on dst */
  69. #define    DST_USA        1    /* USA style dst */
  70. #define    DST_AUST    2    /* Australian style dst */
  71. #define    DST_WET        3    /* Western European dst */
  72. #define    DST_MET        4    /* Middle European dst */
  73. #define    DST_EET        5    /* Eastern European dst */
  74. #define    DST_CAN        6    /* Canada */
  75. #define    DST_GB        7    /* Great Britain and Eire */
  76. #define    DST_RUM        8    /* Rumania */
  77. #define    DST_TUR        9    /* Turkey */
  78. #define    DST_AUSTALT    10    /* Australian style with shift in 1986 */
  79.  
  80. /*
  81.  * Operations on timevals.
  82.  *
  83.  * NB: timercmp does not work for >= or <=.
  84.  */
  85. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  86. #define    timercmp(tvp, uvp, cmp)    \
  87.     ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  88.      (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  89. #define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  90.  
  91. #endif /* !defined(_POSIX_SOURCE) ... && !defined(_XOPEN_SOURCE) */ 
  92.  
  93. #if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 >= 1) \
  94.  || ( !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
  95.  && !defined(_XOPEN_SOURCE))
  96. /*
  97.  * Names of the interval timers, and structure
  98.  * defining a timer setting.
  99.  */
  100. #define    ITIMER_REAL    0
  101. #define    ITIMER_VIRTUAL    1
  102. #define    ITIMER_PROF    2
  103.  
  104. struct    itimerval {
  105.     struct    timeval it_interval;    /* timer interval */
  106.     struct    timeval it_value;    /* current value */
  107. };
  108.  
  109. #endif 
  110.  
  111. /*
  112.  * Time expressed in seconds and nanoseconds
  113.  */
  114.  
  115. #ifndef _TIMESTRUC_T
  116. #define _TIMESTRUC_T
  117.  
  118. typedef struct
  119. #if defined(_POSIX_TIMERS) || _POSIX_C_SOURCE - 0 >= 199309 \
  120.     || (!defined(_XOPEN_SOURCE) && !defined(_POSIX_SOURCE) \
  121.     && !defined(_POSIX_C_SOURCE))
  122. #ifndef _TIMESPEC
  123. #define _TIMESPEC
  124.         timespec
  125. #endif
  126. #endif
  127. {
  128. #ifdef    tv_sec
  129.     time_t         __tv_sec;        /* seconds */
  130. #else
  131.     time_t         tv_sec;        /* seconds */
  132. #endif
  133. #ifdef tv_nsec
  134.     long        __tv_nsec;    /* and nanoseconds */
  135. #else
  136.     long        tv_nsec;    /* and nanoseconds */
  137. #endif
  138. } timestruc_t;
  139. #endif
  140.  
  141. #if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 >= 1)
  142.  
  143.  /* XPG4 V2 definitions */
  144.  
  145. /*
  146.  * Select uses bit masks of file descriptors in longs.
  147.  * These macros manipulate such bit fields.
  148.  * FD_SETSIZE may be defined by the user, but the default here
  149.  * should be >= NOFILE (param.h).
  150.  */
  151. #ifndef    FD_SETSIZE
  152. #define    FD_SETSIZE    4096
  153. #endif
  154.  
  155. #ifndef FD_NBBY        /* number of bits per byte */
  156. #define FD_NBBY 8
  157. #endif
  158.  
  159. typedef    long    fds_mask;
  160. #define    FD_NFDBITS    (sizeof(fds_mask) * FD_NBBY)    /* bits per mask */
  161. #ifndef    FD_HOWMANY
  162. #define    FD_HOWMANY(x, y)    (((x)+((y)-1))/(y))
  163. #endif
  164.  
  165. typedef    struct {
  166.     fds_mask    fds_bits[FD_HOWMANY(FD_SETSIZE, FD_NFDBITS)];
  167. } fd_set;
  168.  
  169. /* If macros defined don't define the function */
  170.  
  171. #ifndef FD_CLR
  172. void FD_CLR(int, fd_set *);
  173. void FD_SET(int, fd_set *);
  174. int FD_ISSET(int, fd_set *);
  175. #endif
  176.  
  177. #define    FD_ZERO(p)    memset((char *)(p), 0, sizeof(*(p)))
  178.  
  179.  
  180. int getitimer(int, struct itimerval *);
  181. int setitimer(int, const struct itimerval *, struct itimerval *);
  182. int gettimeofday(struct timeval *, void *);
  183. int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
  184. int utimes(const char *, const struct timeval * );
  185.  
  186. #else
  187.  
  188. #if !defined(_KERNEL) && !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
  189.  && !defined(_XOPEN_SOURCE)
  190.  
  191. #if defined(__STDC__)
  192. int adjtime(struct timeval *, struct timeval *);
  193. int getitimer(int, struct itimerval *);
  194. int setitimer(int, struct itimerval *, struct itimerval *);
  195. int gettimeofday(struct timeval *, void *);
  196. int settimeofday(struct timeval *, struct timezone *);
  197. #endif /* __STDC__ */
  198.  
  199. #include <time.h>
  200.  
  201. #endif /* !defined(_KERNEL) ... && !defined(_XOPEN_SOURCE) */
  202.  
  203.  
  204. #endif /* non XPG4 V2  section */
  205. #if defined(__cplusplus)
  206.         }
  207. #endif
  208. #endif /* _SVC_TIME_H */
  209.