1
0

time.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef _TIME_H
  2. #define _TIME_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #if __STDC_VERSION__ >= 199901L
  7. #define __restrict restrict
  8. #elif !defined(__GNUC__)
  9. #define __restrict
  10. #endif
  11. #undef NULL
  12. #ifdef __cplusplus
  13. #define NULL 0
  14. #else
  15. #define NULL ((void*)0)
  16. #endif
  17. #define __NEED_size_t
  18. #define __NEED_time_t
  19. #define __NEED_clock_t
  20. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  21. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  22. || defined(_BSD_SOURCE)
  23. #define __NEED_struct_timespec
  24. #define __NEED_clockid_t
  25. #define __NEED_timer_t
  26. #define __NEED_pid_t
  27. #define __NEED_locale_t
  28. #endif
  29. #include <bits/alltypes.h>
  30. struct tm
  31. {
  32. int tm_sec;
  33. int tm_min;
  34. int tm_hour;
  35. int tm_mday;
  36. int tm_mon;
  37. int tm_year;
  38. int tm_wday;
  39. int tm_yday;
  40. int tm_isdst;
  41. long __tm_gmtoff;
  42. const char *__tm_zone;
  43. };
  44. clock_t clock (void);
  45. time_t time (time_t *);
  46. double difftime (time_t, time_t);
  47. time_t mktime (struct tm *);
  48. size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
  49. struct tm *gmtime (const time_t *);
  50. struct tm *localtime (const time_t *);
  51. char *asctime (const struct tm *);
  52. char *ctime (const time_t *);
  53. #define CLOCKS_PER_SEC 1000000UL
  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. {
  65. struct timespec it_interval;
  66. struct timespec it_value;
  67. };
  68. #define CLOCK_REALTIME 0
  69. #define CLOCK_MONOTONIC 1
  70. #define CLOCK_PROCESS_CPUTIME_ID 2
  71. #define CLOCK_THREAD_CPUTIME_ID 3
  72. #define TIMER_ABSTIME 1
  73. int nanosleep (const struct timespec *, struct timespec *);
  74. int clock_getres (clockid_t, struct timespec *);
  75. int clock_gettime (clockid_t, struct timespec *);
  76. int clock_settime (clockid_t, const struct timespec *);
  77. int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
  78. int clock_getcpuclockid (pid_t, clockid_t *);
  79. struct sigevent;
  80. int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
  81. int timer_delete (timer_t);
  82. int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
  83. int timer_gettime (timer_t, struct itimerspec *);
  84. int timer_getoverrun (timer_t);
  85. #endif
  86. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
  87. char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
  88. extern int daylight;
  89. extern long timezone;
  90. extern char *tzname[2];
  91. extern int getdate_err;
  92. struct tm *getdate (const char *);
  93. #endif
  94. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  95. int stime(time_t *);
  96. time_t timegm(struct tm *);
  97. #endif
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif