diff --git a/include/boost/interprocess/detail/intermodule_singleton_common.hpp b/include/boost/interprocess/detail/intermodule_singleton_common.hpp index f5306f6..1bb4f01 100644 --- a/include/boost/interprocess/detail/intermodule_singleton_common.hpp +++ b/include/boost/interprocess/detail/intermodule_singleton_common.hpp @@ -47,8 +47,10 @@ inline void get_pid_creation_time_str(std::string &s) { std::stringstream stream; stream << get_current_process_id() << '_'; - stream.precision(6); - stream << std::fixed << get_current_process_creation_time(); + const unsigned long long total_microsecs = get_current_process_creation_time(); + const unsigned long secs = static_cast(total_microsecs/1000000ul); + const unsigned long usecs = static_cast(total_microsecs%1000000ul); + stream << secs << '.' << usecs; s = stream.str(); } diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index deb8eef..cb0b59a 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -220,17 +220,18 @@ inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id() return get_invalid_thread_id(); } -inline long double get_current_process_creation_time() +inline unsigned long long get_current_process_creation_time() { winapi::interprocess_filetime CreationTime, ExitTime, KernelTime, UserTime; winapi::get_process_times ( winapi::get_current_process(), &CreationTime, &ExitTime, &KernelTime, &UserTime); - typedef long double ldouble_t; - const ldouble_t resolution = (100.0l/1000000000.0l); - return CreationTime.dwHighDateTime*(ldouble_t(1u<<31u)*2.0l*resolution) + - CreationTime.dwLowDateTime*resolution; + unsigned long long microsecs = CreationTime.dwHighDateTime; + microsecs <<= 32u; + microsecs |= CreationTime.dwLowDateTime; + microsecs /= 10u; + return microsecs; } inline unsigned int get_num_cores() @@ -476,8 +477,8 @@ inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id() return OS_systemwide_thread_id_t(get_invalid_process_id(), get_invalid_thread_id()); } -inline long double get_current_process_creation_time() -{ return 0.0L; } +inline unsigned long long get_current_process_creation_time() +{ return 0u; } inline unsigned int get_num_cores() {