summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2011-03-16 02:53:24 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2011-03-16 02:53:24 +0000
commitbfb25cd97ce21f511f8bcbcff57c11aade502d5b (patch)
tree68cbdae442845c217809581201aa3476e20182af /lib
parent124d0332dbf79ae44a61968c7c2d379552cc715d (diff)
downloadllvm-bfb25cd97ce21f511f8bcbcff57c11aade502d5b.tar.gz
llvm-bfb25cd97ce21f511f8bcbcff57c11aade502d5b.tar.bz2
llvm-bfb25cd97ce21f511f8bcbcff57c11aade502d5b.tar.xz
Windows/Path.inc: [PR6270] PathV1::makeUnique(): Give arbitrary initial seed for workaround.
FIXME: We should use sys::fs::unique_file() in future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-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 f4b7cec2a1..42a92f9c6d 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)