PageRenderTime 68ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/include/time.h

https://gitlab.com/mbalamat/minix
C Header | 234 lines | 163 code | 27 blank | 44 comment | 10 complexity | e27212212b24eb45be20dab4231c9a8b MD5 | raw file
  1. /* $NetBSD: time.h,v 1.40 2010/12/16 18:36:47 christos Exp $ */
  2. /*
  3. * Copyright (c) 1989, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. * (c) UNIX System Laboratories, Inc.
  6. * All or some portions of this file are derived from material licensed
  7. * to the University of California by American Telephone and Telegraph
  8. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  9. * the permission of UNIX System Laboratories, Inc.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the University nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * @(#)time.h 8.3 (Berkeley) 1/21/94
  36. */
  37. #ifndef _TIME_H_
  38. #define _TIME_H_
  39. #include <sys/cdefs.h>
  40. #include <sys/featuretest.h>
  41. #include <machine/ansi.h>
  42. #include <sys/null.h>
  43. #ifdef _BSD_CLOCK_T_
  44. typedef _BSD_CLOCK_T_ clock_t;
  45. #undef _BSD_CLOCK_T_
  46. #endif
  47. #ifdef _BSD_TIME_T_
  48. typedef _BSD_TIME_T_ time_t;
  49. #undef _BSD_TIME_T_
  50. #endif
  51. #ifdef _BSD_SIZE_T_
  52. typedef _BSD_SIZE_T_ size_t;
  53. #undef _BSD_SIZE_T_
  54. #endif
  55. #ifdef _BSD_CLOCKID_T_
  56. typedef _BSD_CLOCKID_T_ clockid_t;
  57. #undef _BSD_CLOCKID_T_
  58. #endif
  59. #ifndef __minix
  60. #ifdef _BSD_TIMER_T_
  61. typedef _BSD_TIMER_T_ timer_t;
  62. #undef _BSD_TIMER_T_
  63. #endif
  64. #endif /* !__minix */
  65. #ifdef __minix
  66. #define CLOCKS_PER_SEC 60
  67. #else
  68. #define CLOCKS_PER_SEC 100
  69. #endif
  70. struct tm {
  71. int tm_sec; /* seconds after the minute [0-61] */
  72. int tm_min; /* minutes after the hour [0-59] */
  73. int tm_hour; /* hours since midnight [0-23] */
  74. int tm_mday; /* day of the month [1-31] */
  75. int tm_mon; /* months since January [0-11] */
  76. int tm_year; /* years since 1900 */
  77. int tm_wday; /* days since Sunday [0-6] */
  78. int tm_yday; /* days since January 1 [0-365] */
  79. int tm_isdst; /* Daylight Savings Time flag */
  80. long tm_gmtoff; /* offset from UTC in seconds */
  81. __aconst char *tm_zone; /* timezone abbreviation */
  82. };
  83. __BEGIN_DECLS
  84. char *asctime(const struct tm *);
  85. clock_t clock(void);
  86. #ifndef __LIBC12_SOURCE__
  87. char *ctime(const time_t *) __RENAME(__ctime50);
  88. double difftime(time_t, time_t) __RENAME(__difftime50);
  89. struct tm *gmtime(const time_t *) __RENAME(__gmtime50);
  90. #ifndef __MINIX
  91. struct tm *localtime(const time_t *) __RENAME(__locatime50);
  92. #else
  93. struct tm *localtime(const time_t *) __RENAME(__localtime50);
  94. #endif
  95. time_t time(time_t *) __RENAME(__time50);
  96. time_t mktime(struct tm *) __RENAME(__mktime50);
  97. #endif
  98. size_t strftime(char * __restrict, size_t, const char * __restrict,
  99. const struct tm * __restrict)
  100. __attribute__((__format__(__strftime__, 3, 0)));
  101. #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
  102. defined(_NETBSD_SOURCE)
  103. #ifndef __LIBC12_SOURCE__
  104. /*
  105. * CLK_TCK uses libc's internal __sysconf() to retrieve the machine's
  106. * HZ. The value of _SC_CLK_TCK is 39 -- we hard code it so we do not
  107. * need to include unistd.h
  108. */
  109. long __sysconf(int);
  110. #ifdef __minix
  111. #define CLK_TCK (__sysconf(3))
  112. #else
  113. #define CLK_TCK (__sysconf(39))
  114. #endif /* !__minix */
  115. #endif
  116. #endif
  117. extern __aconst char *tzname[2];
  118. #ifndef __LIBC12_SOURCE__
  119. void tzset(void) __RENAME(__tzset50);
  120. #endif
  121. /*
  122. * X/Open Portability Guide >= Issue 4
  123. */
  124. #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
  125. extern int daylight;
  126. #ifndef __LIBC12_SOURCE__
  127. extern long int timezone __RENAME(__timezone13);
  128. #endif
  129. char *strptime(const char * __restrict, const char * __restrict,
  130. struct tm * __restrict);
  131. #endif
  132. #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
  133. defined(_NETBSD_SOURCE)
  134. struct tm *getdate(const char *);
  135. extern int getdate_err;
  136. #endif
  137. #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
  138. defined(_NETBSD_SOURCE)
  139. #include <sys/time.h> /* XXX for struct timespec */
  140. struct sigevent;
  141. struct itimerspec;
  142. #ifndef __LIBC12_SOURCE__
  143. #ifndef __minix
  144. int clock_getres(clockid_t, struct timespec *)
  145. __RENAME(__clock_getres50);
  146. int clock_gettime(clockid_t, struct timespec *)
  147. __RENAME(__clock_gettime50);
  148. int clock_settime(clockid_t, const struct timespec *)
  149. __RENAME(__clock_settime50);
  150. #endif /* !__minix */
  151. int nanosleep(const struct timespec *, struct timespec *)
  152. __RENAME(__nanosleep50);
  153. #ifndef __minix
  154. int timer_gettime(timer_t, struct itimerspec *) __RENAME(__timer_gettime50);
  155. int timer_settime(timer_t, int, const struct itimerspec * __restrict,
  156. struct itimerspec * __restrict) __RENAME(__timer_settime50);
  157. #endif /* !__minix */
  158. #endif
  159. #ifndef __minix
  160. int timer_create(clockid_t, struct sigevent * __restrict,
  161. timer_t * __restrict);
  162. int timer_delete(timer_t);
  163. int timer_getoverrun(timer_t);
  164. #endif /* __minix */
  165. #endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */
  166. #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
  167. defined(_REENTRANT) || defined(_NETBSD_SOURCE)
  168. char *asctime_r(const struct tm * __restrict, char * __restrict);
  169. #ifndef __LIBC12_SOURCE__
  170. char *ctime_r(const time_t *, char *) __RENAME(__ctime_r50);
  171. struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict)
  172. __RENAME(__gmtime_r50);
  173. struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict)
  174. __RENAME(__localtime_r50);
  175. #endif
  176. #endif
  177. #if defined(_NETBSD_SOURCE)
  178. typedef struct __state *timezone_t;
  179. #ifndef __LIBC12_SOURCE__
  180. time_t time2posix(time_t) __RENAME(__time2posix50);
  181. time_t posix2time(time_t) __RENAME(__posix2time50);
  182. time_t timegm(struct tm *) __RENAME(__timegm50);
  183. time_t timeoff(struct tm *, long) __RENAME(__timeoff50);
  184. time_t timelocal(struct tm *) __RENAME(__timelocal50);
  185. struct tm *offtime(const time_t *, long) __RENAME(__offtime50);
  186. void tzsetwall(void) __RENAME(__tzsetwall50);
  187. struct tm *offtime_r(const time_t *, long, struct tm *) __RENAME(__offtime_r50);
  188. struct tm *localtime_rz(const timezone_t, const time_t * __restrict,
  189. struct tm * __restrict) __RENAME(__localtime_rz50);
  190. char *ctime_rz(const timezone_t, const time_t *, char *) __RENAME(__ctime_rz50);
  191. time_t mktime_z(const timezone_t, struct tm *) __RENAME(__mktime_z50);
  192. time_t timelocal_z(const timezone_t, struct tm *) __RENAME(__timelocal_z50);
  193. time_t time2posix_z(const timezone_t, time_t) __RENAME(__time2posix_z50);
  194. time_t posix2time_z(const timezone_t, time_t) __RENAME(__posix2time_z50);
  195. timezone_t tzalloc(const char *) __RENAME(__tzalloc50);
  196. void tzfree(const timezone_t) __RENAME(__tzfree50);
  197. const char *tzgetname(const timezone_t, int) __RENAME(__tzgetname50);
  198. #endif
  199. size_t strftime_z(const timezone_t, char * __restrict, size_t,
  200. const char * __restrict, const struct tm * __restrict)
  201. __attribute__((__format__(__strftime__, 4, 0)));
  202. #endif /* _NETBSD_SOURCE */
  203. #ifdef _MINIX
  204. int stime(time_t *_top);
  205. #endif /* _MINIX */
  206. __END_DECLS
  207. #endif /* !_TIME_H_ */