gettimeofday.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef __GETTIMEOFDAY_H__
  2. #define __GETTIMEOFDAY_H__
  3. #pragma once
  4. #include "config.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #if defined(_MSC_VER) || defined(__BORLANDC__)
  9. #define EPOCHFILETIME (116444736000000000i64)
  10. #else
  11. #define EPOCHFILETIME (116444736000000000LL)
  12. #endif
  13. /* Epoch base year */
  14. #define EPOCH_YEAR 1970
  15. /* tm struct members conversion units */
  16. #define TM_YEAR_BASE 1900 /* tm_year base year */
  17. #define TM_MONTH_MIN 0 /* tm_mon = 0 - January */
  18. #define TM_MONTH_MAX 11 /* tm_mon = 11 - December */
  19. #define MIN_SEC 60 /* seconds in a minute */
  20. #define HOUR_SEC 3600 /* seconds in an hour */
  21. #define DAY_SEC 86400 /* seconds in a day */
  22. #define YEAR_SEC (365 * DAY_SEC) /* seconds in a year */
  23. #define FOUR_YEAR_SEC (4 * YEAR_SEC + 1) /* seconds in a 4-year period */
  24. /*
  25. In every, 400 year period (greg) is an interval of the same
  26. number of days: 365 x 400 + 97 = 146097
  27. Also, there are 97 leap days in every such 400 years interval
  28. */
  29. #define LEAP_DAYS_IN_GREG 97
  30. #define GREG_YEARS 400
  31. #define GREG_DAYS (365 * GREG_YEARS + LEAP_DAYS_IN_GREG)
  32. #define GREG_SECS (GREG_DAYS * DAY_SEC)
  33. /* Checks if given year is a leap year. */
  34. #define IS_LEAP_YEAR(year) \
  35. (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0))
  36. #ifndef _TIMEZONE_DEFINED
  37. struct timezone
  38. {
  39. int tz_minuteswest; /* minutes W of Greenwich */
  40. int tz_dsttime; /* type of dst correction */
  41. };
  42. #define _TIMEZONE_DEFINED
  43. #endif /* _TIMEZONE_DEFINED */
  44. TOOLKIT_API int gettimeofday(struct timeval *tp, struct timezone *tzp);
  45. #ifdef __cplusplus
  46. } // extern "C" {
  47. #endif
  48. #endif //__GETTIMEOFDAY_H__