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 |
|
---|
10 | #ifndef BOOST_WINAPI_TIME_HPP_INCLUDED_
|
---|
11 | #define BOOST_WINAPI_TIME_HPP_INCLUDED_
|
---|
12 |
|
---|
13 | #include <boost/winapi/basic_types.hpp>
|
---|
14 |
|
---|
15 | #ifdef BOOST_HAS_PRAGMA_ONCE
|
---|
16 | #pragma once
|
---|
17 | #endif
|
---|
18 | # ifndef _WINDOWS_
|
---|
19 | # include<windows.h>
|
---|
20 | # endif
|
---|
21 | #if !defined( BOOST_USE_WINDOWS_H )
|
---|
22 | extern "C" {
|
---|
23 | struct _FILETIME;
|
---|
24 | struct _SYSTEMTIME;
|
---|
25 |
|
---|
26 | BOOST_SYMBOL_IMPORT boost::winapi::VOID_ WINAPI GetSystemTime( _Out_::_SYSTEMTIME* lpSystemTime);
|
---|
27 | #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime
|
---|
28 | BOOST_SYMBOL_IMPORT boost::winapi::VOID_ WINAPI GetSystemTimeAsFileTime(_Out_::_FILETIME* lpSystemTimeAsFileTime);
|
---|
29 | #endif
|
---|
30 | BOOST_SYMBOL_IMPORT _Success_(return!=FALSE)BOOL
|
---|
31 | WINAPI SystemTimeToFileTime( _In_ const::_SYSTEMTIME*lpSystemTime,_Out_::_FILETIME *lpFileTime);
|
---|
32 | BOOST_SYMBOL_IMPORT _Success_(return!=FALSE)BOOL
|
---|
33 | WINAPI FileTimeToSystemTime( _In_ const::_FILETIME *lpFileTime,_Out_::_SYSTEMTIME*lpSystemTime);
|
---|
34 | #if BOOST_WINAPI_PARTITION_APP_SYSTEM
|
---|
35 | BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI FileTimeToLocalFileTime(_In_ const::_FILETIME *lpFileTime ,_Out_::_FILETIME*lpLocalFileTime);
|
---|
36 | BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ WINAPI LocalFileTimeToFileTime(_In_ const::_FILETIME*lpLocalFileTime,_Out_::_FILETIME *lpFileTime);
|
---|
37 |
|
---|
38 | #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
|
---|
39 |
|
---|
40 | #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
|
---|
41 | __drv_preferredFunction("GetTickCount64", "GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem")
|
---|
42 | BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ WINAPI GetTickCount(BOOST_WINAPI_DETAIL_VOID);
|
---|
43 | #endif // BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
|
---|
44 |
|
---|
45 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
---|
46 | BOOST_SYMBOL_IMPORT boost::winapi::ULONGLONG_ WINAPI
|
---|
47 | GetTickCount64(BOOST_WINAPI_DETAIL_VOID);
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | } // extern "C"
|
---|
51 | #endif // !defined( BOOST_USE_WINDOWS_H )
|
---|
52 |
|
---|
53 | namespace boost {
|
---|
54 | namespace winapi {
|
---|
55 |
|
---|
56 | typedef struct BOOST_MAY_ALIAS _FILETIME {
|
---|
57 | DWORD_ dwLowDateTime;
|
---|
58 | DWORD_ dwHighDateTime;
|
---|
59 | } FILETIME_, *PFILETIME_, *LPFILETIME_;
|
---|
60 |
|
---|
61 | typedef struct BOOST_MAY_ALIAS _SYSTEMTIME {
|
---|
62 | WORD_ wYear;
|
---|
63 | WORD_ wMonth;
|
---|
64 | WORD_ wDayOfWeek;
|
---|
65 | WORD_ wDay;
|
---|
66 | WORD_ wHour;
|
---|
67 | WORD_ wMinute;
|
---|
68 | WORD_ wSecond;
|
---|
69 | WORD_ wMilliseconds;
|
---|
70 | } SYSTEMTIME_, *PSYSTEMTIME_, *LPSYSTEMTIME_;
|
---|
71 |
|
---|
72 | #if BOOST_WINAPI_PARTITION_DESKTOP_SYSTEM
|
---|
73 | using ::GetTickCount;
|
---|
74 | #endif
|
---|
75 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
---|
76 | using ::GetTickCount64;
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | BOOST_FORCEINLINE VOID_ GetSystemTime(LPSYSTEMTIME_ lpSystemTime)
|
---|
80 | {
|
---|
81 | ::GetSystemTime(reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
|
---|
82 | }
|
---|
83 |
|
---|
84 | BOOST_FORCEINLINE BOOL_ SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, FILETIME_* lpFileTime)
|
---|
85 | {
|
---|
86 | return ::SystemTimeToFileTime(reinterpret_cast< const ::_SYSTEMTIME* >(lpSystemTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
|
---|
87 | }
|
---|
88 |
|
---|
89 | BOOST_FORCEINLINE BOOL_ FileTimeToSystemTime(const FILETIME_* lpFileTime, SYSTEMTIME_* lpSystemTime)
|
---|
90 | {
|
---|
91 | return ::FileTimeToSystemTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_SYSTEMTIME* >(lpSystemTime));
|
---|
92 | }
|
---|
93 |
|
---|
94 | #if BOOST_WINAPI_PARTITION_APP_SYSTEM
|
---|
95 | BOOST_FORCEINLINE BOOL_ FileTimeToLocalFileTime(const FILETIME_* lpFileTime, FILETIME_* lpLocalFileTime)
|
---|
96 | {
|
---|
97 | return ::FileTimeToLocalFileTime(reinterpret_cast< const ::_FILETIME* >(lpFileTime), reinterpret_cast< ::_FILETIME* >(lpLocalFileTime));
|
---|
98 | }
|
---|
99 |
|
---|
100 | BOOST_FORCEINLINE BOOL_ LocalFileTimeToFileTime(const FILETIME_* lpLocalFileTime, FILETIME_* lpFileTime)
|
---|
101 | {
|
---|
102 | return ::LocalFileTimeToFileTime(reinterpret_cast< const ::_FILETIME* >(lpLocalFileTime), reinterpret_cast< ::_FILETIME* >(lpFileTime));
|
---|
103 | }
|
---|
104 | #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
|
---|
105 |
|
---|
106 | #if defined( BOOST_HAS_GETSYSTEMTIMEASFILETIME )
|
---|
107 | BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(LPFILETIME_ lpSystemTimeAsFileTime)
|
---|
108 | {
|
---|
109 | ::GetSystemTimeAsFileTime(reinterpret_cast< ::_FILETIME* >(lpSystemTimeAsFileTime));
|
---|
110 | }
|
---|
111 | #else
|
---|
112 | // Windows CE does not define GetSystemTimeAsFileTime
|
---|
113 | BOOST_FORCEINLINE VOID_ GetSystemTimeAsFileTime(FILETIME_* lpFileTime)
|
---|
114 | {
|
---|
115 | boost::winapi::SYSTEMTIME_ st;
|
---|
116 | boost::winapi::GetSystemTime(&st);
|
---|
117 | boost::winapi::SystemTimeToFileTime(&st, lpFileTime);
|
---|
118 | }
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | #endif // BOOST_WINAPI_TIME_HPP_INCLUDED_
|
---|