[llvm-commits] [llvm] r127723 - /llvm/trunk/lib/Support/Windows/Path.inc

NAKAMURA Takumi geek4civic at gmail.com
Tue Mar 15 19:53:24 PDT 2011


Author: chapuni
Date: Tue Mar 15 21:53:24 2011
New Revision: 127723

URL: http://llvm.org/viewvc/llvm-project?rev=127723&view=rev
Log:
Windows/Path.inc: [PR6270] PathV1::makeUnique(): Give arbitrary initial seed for workaround.

FIXME: We should use sys::fs::unique_file() in future.

Modified:
    llvm/trunk/lib/Support/Windows/Path.inc

Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=127723&r1=127722&r2=127723&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Tue Mar 15 21:53:24 2011
@@ -882,7 +882,17 @@
   // Find a numeric suffix that isn't used by an existing file.  Assume there
   // won't be more than 1 million files with the same prefix.  Probably a safe
   // bet.
-  static unsigned FCounter = 0;
+  static int FCounter = -1;
+  if (FCounter < 0) {
+    // Give arbitrary initial seed.
+    // FIXME: We should use sys::fs::unique_file() in future.
+    LARGE_INTEGER cnt64;
+    DWORD x = GetCurrentProcessId();
+    x = (x << 16) | (x >> 16);
+    if (QueryPerformanceCounter(&cnt64))    // RDTSC
+      x ^= cnt64.HighPart ^ cnt64.LowPart;
+    FCounter = x % 1000000;
+  }
   do {
     sprintf(FNBuffer+offset, "-%06u", FCounter);
     if (++FCounter > 999999)





More information about the llvm-commits mailing list