aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-25 21:37:17 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-25 21:37:17 +0000
commit05545755676b9ff35d244e55d749a15e28bb228b (patch)
tree1319237959c931cf8fe384f7b4ca1277bf32e938 /lib/System/Unix
parentdcea1400738e85a5cddbf91093983c593c323a19 (diff)
downloadexternal_llvm-05545755676b9ff35d244e55d749a15e28bb228b.zip
external_llvm-05545755676b9ff35d244e55d749a15e28bb228b.tar.gz
external_llvm-05545755676b9ff35d244e55d749a15e28bb228b.tar.bz2
For PR797:
Make the Win32 code exception free (untested/uncompiled) which forced some interface changes which had ripple effect. This should be the last of 797. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29884 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r--lib/System/Unix/MappedFile.inc10
-rw-r--r--lib/System/Unix/Signals.inc13
-rw-r--r--lib/System/Unix/Unix.h2
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/System/Unix/MappedFile.inc b/lib/System/Unix/MappedFile.inc
index ef959ba..4dccd13 100644
--- a/lib/System/Unix/MappedFile.inc
+++ b/lib/System/Unix/MappedFile.inc
@@ -122,7 +122,7 @@ size_t MappedFile::size() const {
return info_->Size;
}
-void MappedFile::size(size_t new_size) {
+bool MappedFile::size(size_t new_size, std::string* ErrMsg) {
assert(info_ && "MappedFile not initialized");
// Take the mapping out of memory
@@ -140,12 +140,14 @@ void MappedFile::size(size_t new_size) {
if (new_size > cur_size) {
// Ensure we can allocate at least the idodes necessary to handle the
// file size requested.
- ::lseek(info_->FD, new_size, SEEK_SET);
- ::write(info_->FD, "\0", 1);
+ if ((off_t)-1 == ::lseek(info_->FD, new_size, SEEK_SET))
+ return MakeErrMsg(ErrMsg, "Can't lseek: ");
+ if (-1 == ::write(info_->FD, "\0", 1))
+ return MakeErrMsg(ErrMsg, "Can't write: ");
}
// Put the mapping back into memory.
- this->map(0);
+ return this->map(ErrMsg);
}
}
diff --git a/lib/System/Unix/Signals.inc b/lib/System/Unix/Signals.inc
index e464106..35c628b 100644
--- a/lib/System/Unix/Signals.inc
+++ b/lib/System/Unix/Signals.inc
@@ -154,7 +154,7 @@ void sys::SetInterruptFunction(void (*IF)()) {
}
// RemoveFileOnSignal - The public API
-void sys::RemoveFileOnSignal(const sys::Path &Filename) {
+bool sys::RemoveFileOnSignal(const sys::Path &Filename, std::string* ErrMsg) {
if (FilesToRemove == 0)
FilesToRemove = new std::vector<sys::Path>;
@@ -162,14 +162,18 @@ void sys::RemoveFileOnSignal(const sys::Path &Filename) {
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
+ return false;
}
// RemoveDirectoryOnSignal - The public API
-void sys::RemoveDirectoryOnSignal(const sys::Path& path) {
+bool sys::RemoveDirectoryOnSignal(const sys::Path& path, std::string* ErrMsg) {
// Not a directory?
sys::FileStatus Status;
- if (path.getFileStatus(Status) || !Status.isDir)
- return;
+ if (path.getFileStatus(Status) || !Status.isDir) {
+ if (ErrMsg)
+ *ErrMsg = path.toString() + " is not a directory";
+ return true;
+ }
if (DirectoriesToRemove == 0)
DirectoriesToRemove = new std::vector<sys::Path>;
@@ -178,6 +182,7 @@ void sys::RemoveDirectoryOnSignal(const sys::Path& path) {
std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
+ return false;
}
/// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
diff --git a/lib/System/Unix/Unix.h b/lib/System/Unix/Unix.h
index 29730fd..c38c652 100644
--- a/lib/System/Unix/Unix.h
+++ b/lib/System/Unix/Unix.h
@@ -94,7 +94,7 @@ inline bool MakeErrMsg(
// but, oh well, just use a generic message
sprintf(buffer, "Error #%d", errnum);
#endif
- *ErrMsg = buffer;
+ *ErrMsg = prefix + buffer;
return true;
}