time.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef _TIME_H
  2. #define _TIME_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #ifdef __cplusplus
  8. #define NULL 0L
  9. #else
  10. #define NULL ((void*)0)
  11. #endif
  12. #define __NEED_size_t
  13. #define __NEED_time_t
  14. #define __NEED_clock_t
  15. #define __NEED_struct_timespec
  16. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  17. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  18. || defined(_BSD_SOURCE)
  19. #define __NEED_clockid_t
  20. #define __NEED_timer_t
  21. #define __NEED_pid_t
  22. #define __NEED_locale_t
  23. #endif
  24. #include <bits/alltypes.h>
  25. #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  26. #define __tm_gmtoff tm_gmtoff
  27. #define __tm_zone tm_zone
  28. #endif
  29. struct tm {
  30. int tm_sec;
  31. int tm_min;
  32. int tm_hour;
  33. int tm_mday;
  34. int tm_mon;
  35. int tm_year;
  36. int tm_wday;
  37. int tm_yday;
  38. int tm_isdst;
  39. long __tm_gmtoff;
  40. const char *__tm_zone;
  41. };
  42. clock_t clock (void);
  43. time_t time (time_t *);
  44. double difftime (time_t, time_t);
  45. time_t mktime (struct tm *);
  46. size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
  47. struct tm *gmtime (const time_t *);
  48. struct tm *localtime (const time_t *);
  49. char *asctime (const struct tm *);
  50. char *ctime (const time_t *);
  51. int timespec_get(struct timespec *, int);
  52. #define CLOCKS_PER_SEC 1000000L
  53. #define TIME_UTC 1
  54. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  55. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  56. || defined(_BSD_SOURCE)
  57. size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t);
  58. struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
  59. struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
  60. char *asctime_r (const struct tm *__restrict, char *__restrict);
  61. char *ctime_r (const time_t *, char *);
  62. void tzset (void);
  63. struct itimerspec {
  64. struct timespec it_interval;
  65. struct timespec it_value;
  66. };
  67. #define CLOCK_REALTIME 0
  68. #define CLOCK_MONOTONIC 1
  69. #define CLOCK_PROCESS_CPUTIME_ID 2
  70. #define CLOCK_THREAD_CPUTIME_ID 3
  71. #define CLOCK_MONOTONIC_RAW 4
  72. #define CLOCK_REALTIME_COARSE 5
  73. #define CLOCK_MONOTONIC_COARSE 6
  74. #define CLOCK_BOOTTIME 7
  75. #define CLOCK_REALTIME_ALARM 8
  76. #define CLOCK_BOOTTIME_ALARM 9
  77. #define CLOCK_SGI_CYCLE 10
  78. #define CLOCK_TAI 11
  79. #define TIMER_ABSTIME 1
  80. int nanosleep (const struct timespec *, struct timespec *);
  81. int clock_getres (clockid_t, struct timespec *);
  82. int clock_gettime (clockid_t, struct timespec *);
  83. int clock_settime (clockid_t, const struct timespec *);
  84. int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
  85. int clock_getcpuclockid (pid_t, clockid_t *);
  86. struct sigevent;
  87. int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
  88. int timer_delete (timer_t);
  89. int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
  90. int timer_gettime (timer_t, struct itimerspec *);
  91. int timer_getoverrun (timer_t);
  92. #endif
  93. #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  94. char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
  95. extern int daylight;
  96. extern long timezone;
  97. extern char *tzname[2];
  98. extern int getdate_err;
  99. struct tm *getdate (const char *);
  100. #endif
  101. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  102. int stime(const time_t *);
  103. time_t timegm(struct tm *);
  104. #endif
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif