Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
--- Merging r127723 into '.':
Browse files Browse the repository at this point in the history
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
  • Loading branch information
isanbard committed Mar 24, 2011
1 parent c9acfcd commit 81d1e0b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Support/Windows/Path.inc
Expand Up @@ -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)
Expand Down

0 comments on commit 81d1e0b

Please sign in to comment.