[llvm-commits] [PATCH] Some tweaks (PathV2, Archive, &c)
NAKAMURA Takumi
geek4civic at gmail.com
Mon Jan 17 02:35:27 PST 2011
Michael and guys,
Four patches are here. Checked on Windows XP, Windows 7 and CentOS5.
They are trivial, and feel free to commit them by yourself with
appropriate approval,
or improve them, please ;)
[Win/posix]
* 0002-lib-Archive-ArchiveWriter.cpp-Don-t-concatenate-.patch.txt
On Posix, we would see weird directories in the temporary directory.
eg.) /tmp/f8-d3-97-7c/home/chapuni/BUILD/llvm-static/test/Linker/Output
On Win32, make_unique() tried to make invalid directory and path.
eg.) 59-7f-5e-53C:/cygwin/home/....
For now, I got rid of adding prefix or suffix to the model to unique().
[Win32]
* 0001-lib-Support-Windows-Signals.inc-Showstopper-dial.patch.txt
On mingw and msvc, I think it would be enough. :)
* 0003-Windows-PathV2.inc-MoveFileEx-can-behave-like-Po.patch.txt
On win32, we can use MoveFileEx().
* 0004-Windows-PathV2.inc-For-CryptAcquireContext-CRYPT.patch.txt
On some circumstances (afaik some Windows XP), CryptAcquireContext
to default would fail.
(On windows7, it succeeds)
CRYPT_VERIFYCONTEXT can provide a trivial context, I understand.
Anyway, I think Crypto API would be overkill for random number generation.
...Takumi
-------------- next part --------------
From f1da4feb13fc845fc2f909457725f563907ee0db Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Mon, 17 Jan 2011 14:39:59 +0900
Subject: [PATCH 1/4] lib/Support/Windows/Signals.inc: "Showstopper" dialogs may be suppressed with SetErrorMode() on Windows 7.
---
lib/Support/Windows/Signals.inc | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/Support/Windows/Signals.inc b/lib/Support/Windows/Signals.inc
index c0e3eca..14f3f21 100644
--- a/lib/Support/Windows/Signals.inc
+++ b/lib/Support/Windows/Signals.inc
@@ -112,6 +112,9 @@ static void RegisterHandler() {
#ifdef _MSC_VER
_CrtSetReportHook(CRTReportHook);
#endif
+ SetErrorMode(SEM_FAILCRITICALERRORS |
+ SEM_NOGPFAULTERRORBOX |
+ SEM_NOOPENFILEERRORBOX);
ExitOnUnhandledExceptions = true;
}
--
1.7.1.GIT
-------------- next part --------------
From 51c1d4cf0f6f276169941e7307f101a7a56328a9 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Mon, 17 Jan 2011 18:00:25 +0900
Subject: [PATCH 2/4] lib/Archive/ArchiveWriter.cpp: Don't concatenate the model string before archPath, when archPath is absolute!
---
lib/Archive/ArchiveWriter.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp
index 59fb7bd..063000c 100644
--- a/lib/Archive/ArchiveWriter.cpp
+++ b/lib/Archive/ArchiveWriter.cpp
@@ -364,7 +364,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
// Create a temporary file to store the archive in
SmallString<128> TempArchivePath;
int ArchFD;
- if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%" + archPath.str(),
+ if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%",
ArchFD, TempArchivePath)) {
if (ErrMsg) *ErrMsg = ec.message();
return true;
@@ -421,7 +421,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
// Open another temporary file in order to avoid invalidating the
// mmapped data
- if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%" + archPath.str(),
+ if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%",
ArchFD, TempArchiveWithSymbolTablePath)) {
if (ErrMsg) *ErrMsg = ec.message();
return true;
--
1.7.1.GIT
-------------- next part --------------
From 251774b2389de9cc83581da9e5c28857e59f7ec3 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Mon, 17 Jan 2011 18:03:23 +0900
Subject: [PATCH 3/4] Windows/PathV2.inc: MoveFileEx() can behave like Posix's mv(1) to specify MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING.
---
lib/Support/Windows/PathV2.inc | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index f4629a1..a631bc6 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -310,7 +310,8 @@ error_code rename(const Twine &from, const Twine &to) {
if (error_code ec = UTF8ToUTF16(f, wide_from)) return ec;
if (error_code ec = UTF8ToUTF16(t, wide_to)) return ec;
- if (!::MoveFileW(wide_from.begin(), wide_to.begin()))
+ if (!::MoveFileExW(wide_from.begin(), wide_to.begin(),
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING))
return windows_error(::GetLastError());
return success;
--
1.7.1.GIT
-------------- next part --------------
From d65e8aff05e5afb9249cdcae4c863c68ec77c0c1 Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Mon, 17 Jan 2011 18:15:14 +0900
Subject: [PATCH 4/4] Windows/PathV2.inc: For CryptAcquireContext(), CRYPT_VERIFYCONTEXT may be specified for easy use.
---
lib/Support/Windows/PathV2.inc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index a631bc6..b36b291 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -525,7 +525,7 @@ error_code unique_file(const Twine &model, int &result_fd,
NULL,
NULL,
PROV_RSA_FULL,
- 0))
+ CRYPT_VERIFYCONTEXT))
return windows_error(::GetLastError());
ScopedCryptContext CryptoProvider(HCPC);
--
1.7.1.GIT
More information about the llvm-commits
mailing list