A clone of btpd with my configuration changes.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

164 Zeilen
5.3 KiB

  1. /* $OpenBSD: time.h,v 1.11 2000/10/10 13:36:48 itojun Exp $ */
  2. /* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */
  3. /*
  4. * Copyright (c) 1982, 1986, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * @(#)time.h 8.2 (Berkeley) 7/10/94
  32. */
  33. #ifndef _SYS_TIME_H_
  34. #define _SYS_TIME_H_
  35. #include <sys/types.h>
  36. /*
  37. * Structure returned by gettimeofday(2) system call,
  38. * and used in other calls.
  39. */
  40. struct timeval {
  41. long tv_sec; /* seconds */
  42. long tv_usec; /* and microseconds */
  43. };
  44. /*
  45. * Structure defined by POSIX.1b to be like a timeval.
  46. */
  47. struct timespec {
  48. time_t tv_sec; /* seconds */
  49. long tv_nsec; /* and nanoseconds */
  50. };
  51. #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
  52. (ts)->tv_sec = (tv)->tv_sec; \
  53. (ts)->tv_nsec = (tv)->tv_usec * 1000; \
  54. }
  55. #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
  56. (tv)->tv_sec = (ts)->tv_sec; \
  57. (tv)->tv_usec = (ts)->tv_nsec / 1000; \
  58. }
  59. struct timezone {
  60. int tz_minuteswest; /* minutes west of Greenwich */
  61. int tz_dsttime; /* type of dst correction */
  62. };
  63. #define DST_NONE 0 /* not on dst */
  64. #define DST_USA 1 /* USA style dst */
  65. #define DST_AUST 2 /* Australian style dst */
  66. #define DST_WET 3 /* Western European dst */
  67. #define DST_MET 4 /* Middle European dst */
  68. #define DST_EET 5 /* Eastern European dst */
  69. #define DST_CAN 6 /* Canada */
  70. /* Operations on timevals. */
  71. #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  72. #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  73. #define timercmp(tvp, uvp, cmp) \
  74. (((tvp)->tv_sec == (uvp)->tv_sec) ? \
  75. ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
  76. ((tvp)->tv_sec cmp (uvp)->tv_sec))
  77. #define timeradd(tvp, uvp, vvp) \
  78. do { \
  79. (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
  80. (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
  81. if ((vvp)->tv_usec >= 1000000) { \
  82. (vvp)->tv_sec++; \
  83. (vvp)->tv_usec -= 1000000; \
  84. } \
  85. } while (0)
  86. #define timersub(tvp, uvp, vvp) \
  87. do { \
  88. (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
  89. (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
  90. if ((vvp)->tv_usec < 0) { \
  91. (vvp)->tv_sec--; \
  92. (vvp)->tv_usec += 1000000; \
  93. } \
  94. } while (0)
  95. /* Operations on timespecs. */
  96. #define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
  97. #define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
  98. #define timespeccmp(tsp, usp, cmp) \
  99. (((tsp)->tv_sec == (usp)->tv_sec) ? \
  100. ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
  101. ((tsp)->tv_sec cmp (usp)->tv_sec))
  102. #define timespecadd(tsp, usp, vsp) \
  103. do { \
  104. (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
  105. (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
  106. if ((vsp)->tv_nsec >= 1000000000L) { \
  107. (vsp)->tv_sec++; \
  108. (vsp)->tv_nsec -= 1000000000L; \
  109. } \
  110. } while (0)
  111. #define timespecsub(tsp, usp, vsp) \
  112. do { \
  113. (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
  114. (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
  115. if ((vsp)->tv_nsec < 0) { \
  116. (vsp)->tv_sec--; \
  117. (vsp)->tv_nsec += 1000000000L; \
  118. } \
  119. } while (0)
  120. /*
  121. * Names of the interval timers, and structure
  122. * defining a timer setting.
  123. */
  124. #define ITIMER_REAL 0
  125. #define ITIMER_VIRTUAL 1
  126. #define ITIMER_PROF 2
  127. struct itimerval {
  128. struct timeval it_interval; /* timer interval */
  129. struct timeval it_value; /* current value */
  130. };
  131. /*
  132. * Getkerninfo clock information structure
  133. */
  134. struct clockinfo {
  135. int hz; /* clock frequency */
  136. int tick; /* micro-seconds per hz tick */
  137. int tickadj; /* clock skew rate for adjtime() */
  138. int stathz; /* statistics clock frequency */
  139. int profhz; /* profiling clock frequency */
  140. };
  141. #define CLOCK_REALTIME 0
  142. #define CLOCK_VIRTUAL 1
  143. #define CLOCK_PROF 2
  144. #define TIMER_RELTIME 0x0 /* relative timer */
  145. #define TIMER_ABSTIME 0x1 /* absolute timer */
  146. /* --- stuff got cut here - niels --- */
  147. #endif /* !_SYS_TIME_H_ */