time.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // time.hpp --------------------------------------------------------------//
  2. // Copyright 2010 Vicente J. Botet Escriba
  3. // Copyright (c) Microsoft Corporation 2014
  4. // Copyright 2015 Andrey Semashev
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See http://www.boost.org/LICENSE_1_0.txt
  7. #ifndef BOOST_DETAIL_WINAPI_TIME_HPP
  8. #define BOOST_DETAIL_WINAPI_TIME_HPP
  9. #include <boost/detail/winapi/basic_types.hpp>
  10. #include <boost/predef/platform.h>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. #pragma once
  13. #endif
  14. #if !defined( BOOST_USE_WINDOWS_H )
  15. extern "C" {
  16. struct _FILETIME;
  17. struct _SYSTEMTIME;
  18. BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI
  19. GetSystemTime(::_SYSTEMTIME* lpSystemTime);
  20. #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime
  21. BOOST_SYMBOL_IMPORT boost::detail::winapi::VOID_ WINAPI
  22. GetSystemTimeAsFileTime(::_FILETIME* lpSystemTimeAsFileTime);
  23. #endif
  24. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  25. SystemTimeToFileTime(
  26. const ::_SYSTEMTIME* lpSystemTime,
  27. ::_FILETIME* lpFileTime);
  28. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  29. FileTimeToSystemTime(
  30. const ::_FILETIME* lpFileTime,
  31. ::_SYSTEMTIME* lpSystemTime);
  32. #if BOOST_PLAT_WINDOWS_DESKTOP
  33. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  34. FileTimeToLocalFileTime(
  35. const ::_FILETIME* lpFileTime,
  36. ::_FILETIME* lpLocalFileTime);
  37. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  38. LocalFileTimeToFileTime(
  39. const ::_FILETIME* lpLocalFileTime,
  40. ::_FILETIME* lpFileTime);
  41. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
  42. GetTickCount(BOOST_DETAIL_WINAPI_VOID);
  43. #endif
  44. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  45. BOOST_SYMBOL_IMPORT boost::detail::winapi::ULONGLONG_ WINAPI
  46. GetTickCount64(BOOST_DETAIL_WINAPI_VOID);
  47. #endif
  48. }
  49. #endif
  50. namespace boost {
  51. namespace detail {
  52. namespace winapi {
  53. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _FILETIME {
  54. DWORD_ dwLowDateTime;
  55. DWORD_ dwHighDateTime;
  56. } FILETIME_, *PFILETIME_, *LPFILETIME_;
  57. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _SYSTEMTIME {
  58. WORD_ wYear;
  59. WORD_ wMonth;
  60. WORD_ wDayOfWeek;
  61. WORD_ wDay;
  62. WORD_ wHour;
  63. WORD_ wMinute;
  64. WORD_ wSecond;
  65. WORD_ wMilliseconds;
  66. } SYSTEMTIME_, *PSYSTEMTIME_, *LPSYSTEMTIME_;
  67. #if BOOST_PLAT_WINDOWS_DESKTOP
  68. using ::GetTickCount;
  69. #endif
  70. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  71. using ::GetTickCount64;
  72. #endif
  73. BOOST_FORCEINLINE VOID_ GetSystemTime(LPSYSTEMTIME_ lpSystemTime)
  74. {
  75. ::GetSystemTime(reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
  76. }
  77. #if defined( BOOST_HAS_GETSYSTEMTIMEASFILETIME )
  78. BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(LPFILETIME_ lpSystemTimeAsFileTime)
  79. {
  80. ::GetSystemTimeAsFileTime(reinterpret_cast< ::_FILETIME* >(lpSystemTimeAsFileTime));
  81. }
  82. #else
  83. // Windows CE does not define GetSystemTimeAsFileTime
  84. BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(FILETIME_* lpFileTime)
  85. {
  86. boost::detail::winapi::SYSTEMTIME_ st;
  87. boost::detail::winapi::GetSystemTime(&st);
  88. boost::detail::winapi::SystemTimeToFileTime(&st, lpFileTime);
  89. }
  90. #endif
  91. BOOST_FORCEINLINE BOOL_ SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, FILETIME_* lpFileTime)
  92. {
  93. return ::SystemTimeToFileTime(reinterpret_cast< const ::_SYSTEMTIME* >(lpSystemTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
  94. }
  95. BOOST_FORCEINLINE BOOL_ FileTimeToSystemTime(const FILETIME_* lpFileTime, SYSTEMTIME_* lpSystemTime)
  96. {
  97. return ::FileTimeToSystemTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
  98. }
  99. #if BOOST_PLAT_WINDOWS_DESKTOP
  100. BOOST_FORCEINLINE BOOL_ FileTimeToLocalFileTime(const FILETIME_* lpFileTime, FILETIME_* lpLocalFileTime)
  101. {
  102. return ::FileTimeToLocalFileTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_FILETIME* >(lpLocalFileTime));
  103. }
  104. BOOST_FORCEINLINE BOOL_ LocalFileTimeToFileTime(const FILETIME_* lpLocalFileTime, FILETIME_* lpFileTime)
  105. {
  106. return ::LocalFileTimeToFileTime(reinterpret_cast< const ::_FILETIME* >(lpLocalFileTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
  107. }
  108. #endif
  109. }
  110. }
  111. }
  112. #endif // BOOST_DETAIL_WINAPI_TIME_HPP