time.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with the GNU C Library; see the file COPYING.LIB. If
  13. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  14. Cambridge, MA 02139, USA. */
  15. /*
  16. * ANSI Standard: 4.12 DATE and TIME <time.h>
  17. */
  18. #ifndef _TIME_H
  19. #define _TIME_H
  20. #include <features.h>
  21. #include <sys/time.h>
  22. #ifndef _TIME_T
  23. #define _TIME_T
  24. typedef long time_t;
  25. #endif
  26. #ifndef _CLOCK_T
  27. #define _CLOCK_T
  28. typedef long clock_t;
  29. #endif
  30. #ifndef _SIZE_T
  31. #define _SIZE_T
  32. typedef unsigned int size_t;
  33. #endif
  34. #ifndef NULL
  35. #ifdef __cplusplus
  36. #define NULL 0
  37. #else
  38. #define NULL ((void *) 0)
  39. #endif
  40. #endif
  41. #define CLOCKS_PER_SEC 100
  42. #define CLK_TCK 100 /* That must be the same as HZ ???? */
  43. struct tm {
  44. int tm_sec;
  45. int tm_min;
  46. int tm_hour;
  47. int tm_mday;
  48. int tm_mon;
  49. int tm_year;
  50. int tm_wday;
  51. int tm_yday;
  52. int tm_isdst;
  53. /* Those are for future use. */
  54. long int __tm_gmtoff__;
  55. __const char *__tm_zone__;
  56. };
  57. #define __isleap(year) \
  58. ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
  59. extern char *tzname[2];
  60. extern int daylight;
  61. extern long int timezone;
  62. __BEGIN_DECLS
  63. extern int stime __P ((time_t* __tptr));
  64. extern clock_t clock __P ((void));
  65. extern time_t time __P ((time_t * __tp));
  66. extern __CONSTVALUE double difftime __P ((time_t __time2,
  67. time_t __time1)) __CONSTVALUE2;
  68. extern time_t mktime __P ((struct tm * __tp));
  69. extern char * asctime __P ((__const struct tm * __tp));
  70. extern char * ctime __P ((__const time_t * __tp));
  71. extern size_t strftime __P ((char * __s, size_t __smax,
  72. __const char * __fmt, __const struct tm * __tp));
  73. extern char * strptime __P ((__const char * __s, __const char * __fmt,
  74. struct tm * __tm));
  75. extern void tzset __P ((void));
  76. extern struct tm* gmtime __P ((__const time_t *__tp));
  77. extern struct tm* localtime __P ((__const time_t * __tp));
  78. #ifdef __USE_MISC
  79. /* Miscellaneous functions many Unices inherited from the public domain
  80. localtime package. These are included only for compatibility. */
  81. /* Like `mktime', but for TP represents Universal Time, not local time. */
  82. extern time_t timegm __P ((struct tm *__tp));
  83. /* Another name for `mktime'. */
  84. extern time_t timelocal __P ((struct tm *__tp));
  85. #endif
  86. extern char * asctime_r __P((__const struct tm *, char *));
  87. extern char * ctime_r __P((__const time_t *, char *));
  88. extern struct tm* gmtime_r __P((__const time_t *, struct tm *));
  89. extern struct tm* localtime_r __P((__const time_t *, struct tm *));
  90. struct timespec;
  91. /* IEEE Std 1003.1b-1993. */
  92. extern int nanosleep __P((__const struct timespec *__rqtp,
  93. struct timespec *__rmtp));
  94. __END_DECLS
  95. #endif