diff options
Diffstat (limited to 'lib/Support/Windows')
-rw-r--r-- | lib/Support/Windows/DynamicLibrary.inc | 2 | ||||
-rw-r--r-- | lib/Support/Windows/Process.inc | 14 | ||||
-rw-r--r-- | lib/Support/Windows/TimeValue.inc | 19 |
3 files changed, 17 insertions, 18 deletions
diff --git a/lib/Support/Windows/DynamicLibrary.inc b/lib/Support/Windows/DynamicLibrary.inc index 504471eaff..5d0278fe3c 100644 --- a/lib/Support/Windows/DynamicLibrary.inc +++ b/lib/Support/Windows/DynamicLibrary.inc @@ -58,7 +58,7 @@ extern "C" { stricmp(ModuleName, "msvcr70") != 0 && #ifndef __MINGW32__ // Mingw32 uses msvcrt.dll by default. Don't ignore it. - // Otherwise, user should be aware, what he's doing :) + // Otherwise the user should be aware what they are doing. stricmp(ModuleName, "msvcrt") != 0 && #endif stricmp(ModuleName, "msvcrt20") != 0 && diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index a87c9e88c7..c3df801dc0 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -82,16 +82,14 @@ TimeValue self_process::get_system_time() const { return getTimeValueFromFILETIME(KernelTime); } -// This function retrieves the page size using GetSystemInfo and is present -// solely so it can be called once to initialize the self_process member below. +// This function retrieves the page size using GetNativeSystemInfo() and is +// present solely so it can be called once to initialize the self_process member +// below. static unsigned getPageSize() { - // NOTE: A 32-bit application running under WOW64 is supposed to use - // GetNativeSystemInfo. However, this interface is not present prior - // to Windows XP so to use it requires dynamic linking. It is not clear - // how this affects the reported page size, if at all. One could argue - // that LLVM ought to run as 64-bits on a 64-bit system, anyway. + // GetNativeSystemInfo() provides the physical page size which may differ + // from GetSystemInfo() in 32-bit applications running under WOW64. SYSTEM_INFO info; - GetSystemInfo(&info); + GetNativeSystemInfo(&info); // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize, // but dwAllocationGranularity. return static_cast<unsigned>(info.dwPageSize); diff --git a/lib/Support/Windows/TimeValue.inc b/lib/Support/Windows/TimeValue.inc index 6c59024d9c..0223ab4244 100644 --- a/lib/Support/Windows/TimeValue.inc +++ b/lib/Support/Windows/TimeValue.inc @@ -12,6 +12,8 @@ //===----------------------------------------------------------------------===// #include "WindowsSupport.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" #include <cctype> #include <time.h> @@ -32,6 +34,7 @@ TimeValue TimeValue::now() { } std::string TimeValue::str() const { + std::string S; struct tm *LT; #ifdef __MINGW32__ // Old versions of mingw don't have _localtime64_s. Remove this once we drop support @@ -47,13 +50,11 @@ std::string TimeValue::str() const { LT = &Storage; #endif - char Buffer[25]; - // FIXME: the windows version of strftime doesn't support %e - strftime(Buffer, 25, "%b %d %H:%M %Y", LT); - assert((Buffer[3] == ' ' && isdigit(Buffer[5]) && Buffer[6] == ' ') && - "Unexpected format in strftime()!"); - // Emulate %e on %d to mute '0'. - if (Buffer[4] == '0') - Buffer[4] = ' '; - return std::string(Buffer); + char Buffer[sizeof("YYYY-MM-DD HH:MM:SS")]; + strftime(Buffer, sizeof(Buffer), "%Y-%m-%d %H:%M:%S", LT); + raw_string_ostream OS(S); + OS << format("%s.%.9u", static_cast<const char *>(Buffer), + this->nanoseconds()); + OS.flush(); + return S; } |