aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-03-24 06:17:12 +0000
committerBill Wendling <isanbard@gmail.com>2011-03-24 06:17:12 +0000
commit135a17e564bdb0ec98e9fda3da720f22d870b649 (patch)
tree9fa8bea66184099197846efc8fd64614d6989b47
parent89d31400e264a352824a547bd453ad38f1e7d1b8 (diff)
downloadllvm-135a17e564bdb0ec98e9fda3da720f22d870b649.zip
llvm-135a17e564bdb0ec98e9fda3da720f22d870b649.tar.gz
llvm-135a17e564bdb0ec98e9fda3da720f22d870b649.tar.bz2
--- Merging r127723 into '.':
U lib/Support/Windows/Path.inc llvm-svn: 128202
-rw-r--r--llvm/lib/Support/Windows/Path.inc12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 625f67a..d6b5823 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -882,7 +882,17 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
// 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)