time.h 2.4 KB

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