9
3

time.hpp 4.2 KB

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