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
commit81d1e0bcac2a43bd44f15f72149731b6759d496c (patch)
tree5f4fce4029dba5e4168bb4aa54f8000804ffd0e6
parentc9acfcd22cd5eda93e58f2e558b7a6ce86f9b217 (diff)
--- Merging r127723 into '.':
U lib/Support/Windows/Path.inc git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_29@128202 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/Windows/Path.inc12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 625f67aa91..d6b582318d 100644
--- a/lib/Support/Windows/Path.inc
+++ b/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)