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