1
0

time.h 2.9 KB

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