Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
5.7 KiB

  1. /* $OpenBSD: time.h,v 1.31 2018/10/30 16:28:42 guenther Exp $ */
  2. /* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
  3. /*
  4. * Copyright (c) 1989 The Regents of the University of California.
  5. * All rights reserved.
  6. *
  7. * (c) UNIX System Laboratories, Inc.
  8. * All or some portions of this file are derived from material licensed
  9. * to the University of California by American Telephone and Telegraph
  10. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  11. * the permission of UNIX System Laboratories, Inc.
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. * 1. Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright
  19. * notice, this list of conditions and the following disclaimer in the
  20. * documentation and/or other materials provided with the distribution.
  21. * 3. Neither the name of the University nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35. * SUCH DAMAGE.
  36. *
  37. * @(#)time.h 5.12 (Berkeley) 3/9/91
  38. */
  39. #ifndef _TIME_H_
  40. #define _TIME_H_
  41. #include <sys/cdefs.h>
  42. #include <sys/_null.h>
  43. #include <sys/_types.h>
  44. #ifndef _CLOCK_T_DEFINED_
  45. #define _CLOCK_T_DEFINED_
  46. typedef __clock_t clock_t;
  47. #endif
  48. #ifndef _TIME_T_DEFINED_
  49. #define _TIME_T_DEFINED_
  50. typedef __time_t time_t;
  51. #endif
  52. #ifndef _SIZE_T_DEFINED_
  53. #define _SIZE_T_DEFINED_
  54. typedef __size_t size_t;
  55. #endif
  56. #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
  57. /*
  58. * Frequency of the clock ticks reported by times(). Deprecated - use
  59. * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
  60. */
  61. #define CLK_TCK 100
  62. #endif
  63. #define CLOCKS_PER_SEC 100 /* frequency of ticks reported by clock(). */
  64. #if __POSIX_VISIBLE >= 199309 || __ISO_C_VISIBLE >= 2011
  65. #ifndef _TIMESPEC_DECLARED
  66. #define _TIMESPEC_DECLARED
  67. struct timespec {
  68. time_t tv_sec; /* seconds */
  69. long tv_nsec; /* and nanoseconds */
  70. };
  71. #endif
  72. #endif
  73. #if __POSIX_VISIBLE >= 199309
  74. #include <sys/_time.h>
  75. #ifndef _CLOCKID_T_DEFINED_
  76. #define _CLOCKID_T_DEFINED_
  77. typedef __clockid_t clockid_t;
  78. #endif
  79. #ifndef _TIMER_T_DEFINED_
  80. #define _TIMER_T_DEFINED_
  81. typedef __timer_t timer_t;
  82. #endif
  83. #endif
  84. #if __POSIX_VISIBLE >= 200112
  85. #ifndef _PID_T_DEFINED_
  86. #define _PID_T_DEFINED_
  87. typedef __pid_t pid_t;
  88. #endif
  89. #endif
  90. #if __POSIX_VISIBLE >= 200809
  91. #ifndef _LOCALE_T_DEFINED_
  92. #define _LOCALE_T_DEFINED_
  93. typedef void *locale_t;
  94. #endif
  95. #endif
  96. struct tm {
  97. int tm_sec; /* seconds after the minute [0-60] */
  98. int tm_min; /* minutes after the hour [0-59] */
  99. int tm_hour; /* hours since midnight [0-23] */
  100. int tm_mday; /* day of the month [1-31] */
  101. int tm_mon; /* months since January [0-11] */
  102. int tm_year; /* years since 1900 */
  103. int tm_wday; /* days since Sunday [0-6] */
  104. int tm_yday; /* days since January 1 [0-365] */
  105. int tm_isdst; /* Daylight Saving Time flag */
  106. long tm_gmtoff; /* offset from UTC in seconds */
  107. char *tm_zone; /* timezone abbreviation */
  108. };
  109. __BEGIN_DECLS
  110. char *asctime(const struct tm *);
  111. clock_t clock(void);
  112. char *ctime(const time_t *);
  113. double difftime(time_t, time_t);
  114. struct tm *gmtime(const time_t *);
  115. struct tm *localtime(const time_t *);
  116. time_t mktime(struct tm *);
  117. size_t strftime(char *__restrict, size_t, const char *__restrict,
  118. const struct tm *__restrict)
  119. __attribute__ ((__bounded__(__string__,1,2)));
  120. time_t time(time_t *);
  121. #if __XPG_VISIBLE >= 300
  122. extern int daylight;
  123. extern long timezone;
  124. #endif
  125. #if __XPG_VISIBLE >= 400
  126. char *strptime(const char *__restrict, const char *__restrict,
  127. struct tm *__restrict);
  128. #endif
  129. #if __POSIX_VISIBLE >= 199506
  130. char *asctime_r(const struct tm *__restrict, char *__restrict)
  131. __attribute__ ((__bounded__(__minbytes__,2,26)));
  132. char *ctime_r(const time_t *, char *)
  133. __attribute__ ((__bounded__(__minbytes__,2,26)));
  134. struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict);
  135. struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict);
  136. #endif
  137. #if __POSIX_VISIBLE
  138. extern char *tzname[2];
  139. void tzset(void);
  140. #endif
  141. #if __POSIX_VISIBLE >= 199309
  142. int clock_getres(clockid_t, struct timespec *);
  143. int clock_gettime(clockid_t, struct timespec *);
  144. int clock_settime(clockid_t, const struct timespec *);
  145. int nanosleep(const struct timespec *, struct timespec *);
  146. #endif
  147. #if __POSIX_VISIBLE >= 200112
  148. int clock_getcpuclockid(pid_t, clockid_t *);
  149. #endif
  150. #if __POSIX_VISIBLE >= 200809
  151. size_t strftime_l(char *__restrict, size_t, const char *__restrict,
  152. const struct tm *__restrict, locale_t)
  153. __attribute__ ((__bounded__(__string__,1,2)));
  154. #endif
  155. #if __ISO_C_VISIBLE >= 2011
  156. #define TIME_UTC 1 /* time elapsed since epoch */
  157. int timespec_get(struct timespec *_ts, int _base);
  158. #endif
  159. #if __BSD_VISIBLE
  160. void tzsetwall(void);
  161. time_t timelocal(struct tm *);
  162. time_t timegm(struct tm *);
  163. time_t timeoff(struct tm *, const long);
  164. #endif
  165. __END_DECLS
  166. #endif /* !_TIME_H_ */