1 // time.hpp --------------------------------------------------------------// 2 3 // Copyright 2010 Vicente J. Botet Escriba 4 // Copyright (c) Microsoft Corporation 2014 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_DETAIL_WINAPI_TIME_HPP 11 #define BOOST_DETAIL_WINAPI_TIME_HPP 12 13 #include <boost/detail/winapi/basic_types.hpp> 14 #include <boost/predef.h> 15 16 #ifdef BOOST_HAS_PRAGMA_ONCE 17 #pragma once 18 #endif 19 20 namespace boost { 21 namespace detail { 22 namespace winapi { 23 24 #if defined( BOOST_USE_WINDOWS_H ) 25 26 typedef FILETIME FILETIME_; 27 typedef PFILETIME PFILETIME_; 28 typedef LPFILETIME LPFILETIME_; 29 30 typedef SYSTEMTIME SYSTEMTIME_; 31 typedef SYSTEMTIME* PSYSTEMTIME_; 32 33 #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime 34 using ::GetSystemTimeAsFileTime; 35 #endif 36 #if BOOST_PLAT_WINDOWS_DESKTOP 37 using ::FileTimeToLocalFileTime; 38 #endif 39 using ::GetSystemTime; 40 using ::SystemTimeToFileTime; 41 42 #if BOOST_PLAT_WINDOWS_DESKTOP 43 using ::GetTickCount; 44 #endif 45 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 46 using ::GetTickCount64; 47 #endif 48 49 #else 50 51 extern "C" { 52 typedef struct _FILETIME { 53 DWORD_ dwLowDateTime; 54 DWORD_ dwHighDateTime; 55 } FILETIME_, *PFILETIME_, *LPFILETIME_; 56 57 typedef struct _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_; 67 68 #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime 69 __declspec(dllimport) void WINAPI 70 GetSystemTimeAsFileTime(FILETIME_* lpFileTime); 71 #endif 72 __declspec(dllimport) int WINAPI 73 FileTimeToLocalFileTime(const FILETIME_* lpFileTime, 74 FILETIME_* lpLocalFileTime); 75 __declspec(dllimport) void WINAPI 76 GetSystemTime(SYSTEMTIME_* lpSystemTime); 77 __declspec(dllimport) int WINAPI 78 SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime, 79 FILETIME_* lpFileTime); 80 #if BOOST_PLAT_WINDOWS_DESKTOP 81 __declspec(dllimport) DWORD_ WINAPI 82 GetTickCount(); 83 #endif 84 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 85 __declspec(dllimport) ULONGLONG_ WINAPI 86 GetTickCount64(); 87 #endif 88 } 89 90 #endif 91 92 #ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME GetSystemTimeAsFileTime(FILETIME_ * lpFileTime)93inline void WINAPI GetSystemTimeAsFileTime(FILETIME_* lpFileTime) 94 { 95 SYSTEMTIME_ st; 96 GetSystemTime(&st); 97 SystemTimeToFileTime(&st, lpFileTime); 98 } 99 #endif 100 101 } 102 } 103 } 104 105 #endif // BOOST_DETAIL_WINAPI_TIME_HPP 106