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.

3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /*
  2. * time.h
  3. *
  4. * Struct and function declarations for dealing with time.
  5. */
  6. #ifndef _TIME_H_
  7. #define _TIME_H_
  8. #include "_ansi.h"
  9. #include <sys/cdefs.h>
  10. #include <sys/reent.h>
  11. #define __need_size_t
  12. #define __need_NULL
  13. #include <stddef.h>
  14. /* Get _CLOCKS_PER_SEC_ */
  15. #include <machine/time.h>
  16. #ifndef _CLOCKS_PER_SEC_
  17. #define _CLOCKS_PER_SEC_ 1000
  18. #endif
  19. #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
  20. #define CLK_TCK CLOCKS_PER_SEC
  21. #include <sys/types.h>
  22. #include <sys/timespec.h>
  23. #if __POSIX_VISIBLE >= 200809
  24. #include <sys/_locale.h>
  25. #endif
  26. _BEGIN_STD_C
  27. struct tm
  28. {
  29. int tm_sec;
  30. int tm_min;
  31. int tm_hour;
  32. int tm_mday;
  33. int tm_mon;
  34. int tm_year;
  35. int tm_wday;
  36. int tm_yday;
  37. int tm_isdst;
  38. #ifdef __TM_GMTOFF
  39. long __TM_GMTOFF;
  40. #endif
  41. #ifdef __TM_ZONE
  42. const char *__TM_ZONE;
  43. #endif
  44. };
  45. clock_t clock (void);
  46. double difftime (time_t _time2, time_t _time1);
  47. time_t mktime (struct tm *_timeptr);
  48. time_t time (time_t *_timer);
  49. #ifndef _REENT_ONLY
  50. char *asctime (const struct tm *_tblock);
  51. char *ctime (const time_t *_time);
  52. struct tm *gmtime (const time_t *_timer);
  53. struct tm *localtime (const time_t *_timer);
  54. #endif
  55. size_t strftime (char *__restrict _s,
  56. size_t _maxsize, const char *__restrict _fmt,
  57. const struct tm *__restrict _t);
  58. #if __POSIX_VISIBLE >= 200809
  59. extern size_t strftime_l (char *__restrict _s, size_t _maxsize,
  60. const char *__restrict _fmt,
  61. const struct tm *__restrict _t, locale_t _l);
  62. #endif
  63. char *asctime_r (const struct tm *__restrict,
  64. char *__restrict);
  65. char *ctime_r (const time_t *, char *);
  66. struct tm *gmtime_r (const time_t *__restrict,
  67. struct tm *__restrict);
  68. struct tm *localtime_r (const time_t *__restrict,
  69. struct tm *__restrict);
  70. _END_STD_C
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. #if __XSI_VISIBLE
  75. char *strptime (const char *__restrict,
  76. const char *__restrict,
  77. struct tm *__restrict);
  78. #endif
  79. #if __GNU_VISIBLE
  80. char *strptime_l (const char *__restrict, const char *__restrict,
  81. struct tm *__restrict, locale_t);
  82. #endif
  83. #if __POSIX_VISIBLE
  84. void tzset (void);
  85. #endif
  86. void _tzset_r (struct _reent *);
  87. typedef struct __tzrule_struct
  88. {
  89. char ch;
  90. int m;
  91. int n;
  92. int d;
  93. int s;
  94. time_t change;
  95. long offset; /* Match type of _timezone. */
  96. } __tzrule_type;
  97. typedef struct __tzinfo_struct
  98. {
  99. int __tznorth;
  100. int __tzyear;
  101. __tzrule_type __tzrule[2];
  102. } __tzinfo_type;
  103. __tzinfo_type *__gettzinfo (void);
  104. /* getdate functions */
  105. #ifdef HAVE_GETDATE
  106. #if __XSI_VISIBLE >= 4
  107. #ifndef _REENT_ONLY
  108. #define getdate_err (*__getdate_err())
  109. int *__getdate_err (void);
  110. struct tm * getdate (const char *);
  111. /* getdate_err is set to one of the following values to indicate the error.
  112. 1 the DATEMSK environment variable is null or undefined,
  113. 2 the template file cannot be opened for reading,
  114. 3 failed to get file status information,
  115. 4 the template file is not a regular file,
  116. 5 an error is encountered while reading the template file,
  117. 6 memory allication failed (not enough memory available),
  118. 7 there is no line in the template that matches the input,
  119. 8 invalid input specification */
  120. #endif /* !_REENT_ONLY */
  121. #endif /* __XSI_VISIBLE >= 4 */
  122. #if __GNU_VISIBLE
  123. /* getdate_r returns the error code as above */
  124. int getdate_r (const char *, struct tm *);
  125. #endif /* __GNU_VISIBLE */
  126. #endif /* HAVE_GETDATE */
  127. /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
  128. #if __SVID_VISIBLE || __XSI_VISIBLE
  129. extern __IMPORT long _timezone;
  130. extern __IMPORT int _daylight;
  131. #endif
  132. #if __POSIX_VISIBLE
  133. extern __IMPORT char *_tzname[2];
  134. /* POSIX defines the external tzname being defined in time.h */
  135. #ifndef tzname
  136. #define tzname _tzname
  137. #endif
  138. #endif /* __POSIX_VISIBLE */
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #include <sys/features.h>
  143. #ifdef __CYGWIN__
  144. #include <cygwin/time.h>
  145. #endif /*__CYGWIN__*/
  146. #if defined(_POSIX_TIMERS)
  147. #include <signal.h>
  148. #ifdef __cplusplus
  149. extern "C" {
  150. #endif
  151. /* Clocks, P1003.1b-1993, p. 263 */
  152. int clock_settime (clockid_t clock_id, const struct timespec *tp);
  153. int clock_gettime (clockid_t clock_id, struct timespec *tp);
  154. int clock_getres (clockid_t clock_id, struct timespec *res);
  155. /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
  156. int timer_create (clockid_t clock_id,
  157. struct sigevent *__restrict evp,
  158. timer_t *__restrict timerid);
  159. /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
  160. int timer_delete (timer_t timerid);
  161. /* Per-Process Timers, P1003.1b-1993, p. 267 */
  162. int timer_settime (timer_t timerid, int flags,
  163. const struct itimerspec *__restrict value,
  164. struct itimerspec *__restrict ovalue);
  165. int timer_gettime (timer_t timerid, struct itimerspec *value);
  166. int timer_getoverrun (timer_t timerid);
  167. /* High Resolution Sleep, P1003.1b-1993, p. 269 */
  168. int nanosleep (const struct timespec *rqtp, struct timespec *rmtp);
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* _POSIX_TIMERS */
  173. #if defined(_POSIX_CLOCK_SELECTION)
  174. #ifdef __cplusplus
  175. extern "C" {
  176. #endif
  177. int clock_nanosleep (clockid_t clock_id, int flags,
  178. const struct timespec *rqtp, struct timespec *rmtp);
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182. #endif /* _POSIX_CLOCK_SELECTION */
  183. #ifdef __cplusplus
  184. extern "C" {
  185. #endif
  186. /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
  187. /* values for the clock enable attribute */
  188. #define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
  189. #define CLOCK_DISABLED 0 /* clock is disabled */
  190. /* values for the pthread cputime_clock_allowed attribute */
  191. #define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
  192. /* CPU-time clock attached to that thread */
  193. /* shall be accessible. */
  194. #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
  195. /* thread shall not have a CPU-time clock */
  196. /* accessible. */
  197. /* Flag indicating time is "absolute" with respect to the clock
  198. associated with a time. Value 4 is historic. */
  199. #define TIMER_ABSTIME 4
  200. /* Manifest Constants, P1003.1b-1993, p. 262 */
  201. #if __GNU_VISIBLE
  202. #define CLOCK_REALTIME_COARSE ((clockid_t) 0)
  203. #endif
  204. #define CLOCK_REALTIME ((clockid_t) 1)
  205. /* Manifest Constants, P1003.4b/D8, p. 55 */
  206. #if defined(_POSIX_CPUTIME)
  207. /* When used in a clock or timer function call, this is interpreted as
  208. the identifier of the CPU_time clock associated with the PROCESS
  209. making the function call. */
  210. #define CLOCK_PROCESS_CPUTIME_ID ((clockid_t) 2)
  211. #endif
  212. #if defined(_POSIX_THREAD_CPUTIME)
  213. /* When used in a clock or timer function call, this is interpreted as
  214. the identifier of the CPU_time clock associated with the THREAD
  215. making the function call. */
  216. #define CLOCK_THREAD_CPUTIME_ID ((clockid_t) 3)
  217. #endif
  218. #if defined(_POSIX_MONOTONIC_CLOCK)
  219. /* The identifier for the system-wide monotonic clock, which is defined
  220. * as a clock whose value cannot be set via clock_settime() and which
  221. * cannot have backward clock jumps. */
  222. #define CLOCK_MONOTONIC ((clockid_t) 4)
  223. #endif
  224. #if __GNU_VISIBLE
  225. #define CLOCK_MONOTONIC_RAW ((clockid_t) 5)
  226. #define CLOCK_MONOTONIC_COARSE ((clockid_t) 6)
  227. #define CLOCK_BOOTTIME ((clockid_t) 7)
  228. #define CLOCK_REALTIME_ALARM ((clockid_t) 8)
  229. #define CLOCK_BOOTTIME_ALARM ((clockid_t) 9)
  230. #endif
  231. #if defined(_POSIX_CPUTIME)
  232. /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
  233. int clock_getcpuclockid (pid_t pid, clockid_t *clock_id);
  234. #endif /* _POSIX_CPUTIME */
  235. #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
  236. /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
  237. int clock_setenable_attr (clockid_t clock_id, int attr);
  238. int clock_getenable_attr (clockid_t clock_id, int *attr);
  239. #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243. #endif /* _TIME_H_ */