Ticket #5218: boost-chrono-windowsce.patch
File boost-chrono-windowsce.patch, 11.2 KB (added by , 12 years ago) |
---|
-
boost/chrono/detail/inlined/win/chrono.hpp
95 95 system_clock::time_point system_clock::now() 96 96 { 97 97 boost::detail::win32::FILETIME_ ft; 98 boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails 98 #if defined(UNDER_CE) 99 // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps. 100 boost::detail::win32::SYSTEMTIME_ st; 101 boost::detail::win32::GetSystemTime( &st ); 102 boost::detail::win32::SystemTimeToFileTime( &st, &ft ); 103 #else 104 boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails 105 #endif 99 106 return system_clock::time_point(system_clock::duration( 100 107 (static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime)); 101 108 } … … 104 111 system_clock::time_point system_clock::now( system::error_code & ec ) 105 112 { 106 113 boost::detail::win32::FILETIME_ ft; 107 boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails 114 #if defined(UNDER_CE) 115 // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps. 116 boost::detail::win32::SYSTEMTIME_ st; 117 boost::detail::win32::GetSystemTime( &st ); 118 boost::detail::win32::SystemTimeToFileTime( &st, &ft ); 119 #else 120 boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails 121 #endif 108 122 if (!BOOST_CHRONO_IS_THROWS(ec)) 109 123 { 110 124 ec.clear(); -
boost/chrono/detail/inlined/win/process_clock.hpp
34 34 35 35 times_.real = duration( steady_clock::now().time_since_epoch().count() ); 36 36 37 #ifdef UNDER_CE 38 // Windows CE does not support GetProcessTimes 39 assert( 0 && "GetProcessTimes not supported under Windows CE" ); 40 times_.real = times_.system = times_.user = nanoseconds(-1); 41 #else 37 42 if ( boost::detail::win32::GetProcessTimes( 38 43 boost::detail::win32::GetCurrentProcess(), &creation, &exit, 39 44 &system_time, &user_time ) ) … … 67 72 times_.real = times_.system = times_.user = nanoseconds(-1); 68 73 } 69 74 } 70 75 #endif 71 76 } 72 77 } // namespace chrono 73 78 } // namespace boost -
boost/chrono/detail/inlined/win/process_cpu_clocks.hpp
33 33 // note that Windows uses 100 nanosecond ticks for FILETIME 34 34 boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; 35 35 36 #ifdef UNDER_CE 37 // Windows CE does not support GetProcessTimes 38 assert( 0 && "GetProcessTimes not supported under Windows CE" ); 39 return time_point(); 40 #else 36 41 if ( boost::detail::win32::GetProcessTimes( 37 42 boost::detail::win32::GetCurrentProcess(), &creation, &exit, 38 43 &system_time, &user_time ) ) … … 60 65 return time_point(); 61 66 } 62 67 } 68 #endif 63 69 64 70 } 65 71 process_user_cpu_clock::time_point process_user_cpu_clock::now( … … 69 75 // note that Windows uses 100 nanosecond ticks for FILETIME 70 76 boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; 71 77 78 #ifdef UNDER_CE 79 // Windows CE does not support GetProcessTimes 80 assert( 0 && "GetProcessTimes not supported under Windows CE" ); 81 return time_point(); 82 #else 72 83 if ( boost::detail::win32::GetProcessTimes( 73 84 boost::detail::win32::GetCurrentProcess(), &creation, &exit, 74 85 &system_time, &user_time ) ) … … 99 110 return time_point(); 100 111 } 101 112 } 113 #endif 102 114 103 115 } 104 116 process_system_cpu_clock::time_point process_system_cpu_clock::now( … … 108 120 // note that Windows uses 100 nanosecond ticks for FILETIME 109 121 boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; 110 122 123 #ifdef UNDER_CE 124 // Windows CE does not support GetProcessTimes 125 assert( 0 && "GetProcessTimes not supported under Windows CE" ); 126 return time_point(); 127 #else 111 128 if ( boost::detail::win32::GetProcessTimes( 112 129 boost::detail::win32::GetCurrentProcess(), &creation, &exit, 113 130 &system_time, &user_time ) ) … … 138 155 return time_point(); 139 156 } 140 157 } 141 158 #endif 159 142 160 } 143 161 process_cpu_clock::time_point process_cpu_clock::now( 144 162 system::error_code & ec ) … … 147 165 // note that Windows uses 100 nanosecond ticks for FILETIME 148 166 boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; 149 167 168 #ifdef UNDER_CE 169 // Windows CE does not support GetProcessTimes 170 assert( 0 && "GetProcessTimes not supported under Windows CE" ); 171 return time_point(); 172 #else 150 173 if ( boost::detail::win32::GetProcessTimes( 151 174 boost::detail::win32::GetCurrentProcess(), &creation, &exit, 152 175 &system_time, &user_time ) ) … … 183 206 return time_point(); 184 207 } 185 208 } 209 #endif 186 210 187 211 } 188 212 } // namespace chrono -
boost/detail/win/GetCurrentThread.hpp
14 14 namespace boost { 15 15 namespace detail { 16 16 namespace win32 { 17 #if defined( UNDER_CE ) 18 // Windows CE define GetCurrentThread as an inline function in kfuncs.h 19 inline HANDLE_ GetCurrentThread() 20 { 21 return ::GetCurrentThread(); 22 } 23 #else 17 24 #if defined( BOOST_USE_WINDOWS_H ) 18 25 using ::GetCurrentThread; 19 26 #else 20 27 extern "C" __declspec(dllimport) HANDLE_ WINAPI GetCurrentThread(); 21 28 #endif 29 #endif 22 30 } 23 31 } 24 32 } -
boost/detail/win/GetProcessTimes.hpp
14 14 namespace boost { 15 15 namespace detail { 16 16 namespace win32 { 17 #if !defined(UNDER_CE) // Windows CE does not define GetProcessTimes 17 18 #if defined( BOOST_USE_WINDOWS_H ) 18 19 using ::GetProcessTimes; 19 20 #else … … 26 27 LPFILETIME_ lpUserTime 27 28 ); 28 29 #endif 30 #endif 29 31 } 30 32 } 31 33 } -
boost/detail/win/time.hpp
23 23 typedef SYSTEMTIME SYSTEMTIME_; 24 24 typedef SYSTEMTIME* PSYSTEMTIME_; 25 25 26 #ifndef UNDER_CE // Windows CE does not define GetSystemTimeAsFileTime 26 27 using ::GetSystemTimeAsFileTime; 28 #endif 27 29 using ::FileTimeToLocalFileTime; 28 30 using ::GetSystemTime; 29 31 using ::SystemTimeToFileTime; … … 47 49 WORD_ wMilliseconds; 48 50 } SYSTEMTIME_, *PSYSTEMTIME_; 49 51 52 #ifndef UNDER_CE // Windows CE does not define GetSystemTimeAsFileTime 50 53 __declspec(dllimport) void WINAPI 51 54 GetSystemTimeAsFileTime(FILETIME_* lpFileTime); 55 #endif 52 56 __declspec(dllimport) int WINAPI 53 57 FileTimeToLocalFileTime(const FILETIME_* lpFileTime, 54 58 FILETIME_* lpLocalFileTime); -
libs/chrono/example/chrono_unit_test.cpp
23 23 std::time_t sys_time 24 24 = boost::chrono::system_clock::to_time_t(boost::chrono::system_clock::now()); 25 25 26 #ifdef UNDER_CE 27 // Windows CE does not define asctime() 28 struct tm * t = std::gmtime(&sys_time); 26 29 std::cout 27 30 << "system_clock::to_time_t(system_clock::now()) is " 31 << t->tm_mon << "/" << t->tm_mday << "/" << (1900 + t->tm_year) << " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << std::endl; 32 #else 33 std::cout 34 << "system_clock::to_time_t(system_clock::now()) is " 28 35 << std::asctime(std::gmtime(&sys_time)) << std::endl; 36 #endif 29 37 30 38 return 0; 31 39 } -
libs/chrono/example/runtime_resolution.cpp
42 42 43 43 namespace 44 44 { 45 //struct timeval { 46 // long tv_sec; /* seconds */ 47 // long tv_usec; /* and microseconds */ 48 //}; 45 #ifdef UNDER_CE 46 // Windows CE does not define timeval 47 struct timeval { 48 long tv_sec; /* seconds */ 49 long tv_usec; /* and microseconds */ 50 }; 51 #endif 49 52 50 53 int gettimeofday(struct timeval * tp, void *) 51 54 { 52 55 FILETIME ft; 53 ::GetSystemTimeAsFileTime( &ft ); // never fails 56 #if defined(UNDER_CE) 57 // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps. 58 SYSTEMTIME st; 59 ::GetSystemTime( &st ); 60 ::SystemTimeToFileTime( &st, &ft ); 61 #else 62 ::GetSystemTimeAsFileTime( &ft ); // never fails 63 #endif 54 64 long long t = (static_cast<long long>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 55 65 # if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0 56 66 t -= 116444736000000000LL; … … 92 102 : rep_(static_cast<rep>(d.count() * ticks_per_nanosecond)) {} 93 103 94 104 // explicit 95 operator tonanosec() const {return tonanosec(rep_/ticks_per_nanosecond);}105 tonanosec convert_to_nanosec() const {return tonanosec(rep_/ticks_per_nanosecond);} 96 106 97 107 // observer 98 108 … … 218 228 clock::duration elapsed = stop - start; 219 229 std::cout << "paused " << 220 230 boost::chrono::nanoseconds( 221 boost::chrono::duration_cast<boost::chrono::nanoseconds>( duration::tonanosec(elapsed))).count()231 boost::chrono::duration_cast<boost::chrono::nanoseconds>( elapsed.convert_to_nanosec() )).count() 222 232 << " nanoseconds\n"; 223 233 } 224 234 -
libs/chrono/example/timeval_demo.cpp
44 44 45 45 namespace 46 46 { 47 //struct timeval { 48 // long tv_sec; /* seconds */ 49 // long tv_usec; /* and microseconds */ 50 //}; 47 #ifdef UNDER_CE 48 // Windows CE does not define timeval 49 struct timeval { 50 long tv_sec; /* seconds */ 51 long tv_usec; /* and microseconds */ 52 }; 53 #endif 51 54 52 55 int gettimeofday(struct timeval * tp, void *) 53 56 { 54 57 FILETIME ft; 55 ::GetSystemTimeAsFileTime( &ft ); // never fails 58 #if defined(UNDER_CE) 59 // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps. 60 SYSTEMTIME st; 61 ::GetSystemTime( &st ); 62 ::SystemTimeToFileTime( &st, &ft ); 63 #else 64 ::GetSystemTimeAsFileTime( &ft ); // never fails 65 #endif 56 66 long long t = (static_cast<long long>(ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 57 67 # if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0 58 68 t -= 116444736000000000LL;