diff options
Diffstat (limited to 'lib/Support/Unix')
| -rw-r--r-- | lib/Support/Unix/Host.inc | 13 | ||||
| -rw-r--r-- | lib/Support/Unix/Path.inc | 5 | ||||
| -rw-r--r-- | lib/Support/Unix/PathV2.inc | 41 | ||||
| -rw-r--r-- | lib/Support/Unix/Program.inc | 12 |
4 files changed, 28 insertions, 43 deletions
diff --git a/lib/Support/Unix/Host.inc b/lib/Support/Unix/Host.inc index dda3ce2..726e2fb 100644 --- a/lib/Support/Unix/Host.inc +++ b/lib/Support/Unix/Host.inc @@ -35,14 +35,11 @@ static std::string getOSVersion() { return info.release; } -std::string sys::getHostTriple() { - // FIXME: Derive directly instead of relying on the autoconf generated - // variable. +std::string sys::getDefaultTargetTriple() { + StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); + std::pair<StringRef, StringRef> ArchSplit = TargetTripleString.split('-'); - StringRef HostTripleString(LLVM_HOSTTRIPLE); - std::pair<StringRef, StringRef> ArchSplit = HostTripleString.split('-'); - - // Normalize the arch, since the host triple may not actually match the host. + // Normalize the arch, since the target triple may not actually match the target. std::string Arch = ArchSplit.first; std::string Triple(Arch); @@ -55,7 +52,7 @@ std::string sys::getHostTriple() { Triple[1] = '3'; // On darwin, we want to update the version to match that of the - // host. + // target. std::string::size_type DarwinDashIdx = Triple.find("-darwin"); if (DarwinDashIdx != std::string::npos) { Triple.resize(DarwinDashIdx + strlen("-darwin")); diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc index 85c7c40..418dc07 100644 --- a/lib/Support/Unix/Path.inc +++ b/lib/Support/Unix/Path.inc @@ -235,11 +235,6 @@ Path::GetBitcodeLibraryPaths(std::vector<sys::Path>& Paths) { } Path -Path::GetLLVMDefaultConfigDir() { - return Path("/etc/llvm/"); -} - -Path Path::GetUserHomeDirectory() { const char* home = getenv("HOME"); Path result; diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index b5488de..aebb4ab 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -275,28 +275,17 @@ error_code exists(const Twine &path, bool &result) { return success; } -error_code equivalent(const Twine &A, const Twine &B, bool &result) { - // Get arguments. - SmallString<128> a_storage; - SmallString<128> b_storage; - StringRef a = A.toNullTerminatedStringRef(a_storage); - StringRef b = B.toNullTerminatedStringRef(b_storage); - - struct stat stat_a, stat_b; - int error_b = ::stat(b.begin(), &stat_b); - int error_a = ::stat(a.begin(), &stat_a); - - // If both are invalid, it's an error. If only one is, the result is false. - if (error_a != 0 || error_b != 0) { - if (error_a == error_b) - return error_code(errno, system_category()); - result = false; - } else { - result = - stat_a.st_dev == stat_b.st_dev && - stat_a.st_ino == stat_b.st_ino; - } +bool equivalent(file_status A, file_status B) { + assert(status_known(A) && status_known(B)); + return A.st_dev == B.st_dev && + A.st_ino == B.st_ino; +} +error_code equivalent(const Twine &A, const Twine &B, bool &result) { + file_status fsA, fsB; + if (error_code ec = status(A, fsA)) return ec; + if (error_code ec = status(B, fsB)) return ec; + result = equivalent(fsA, fsB); return success; } @@ -343,6 +332,9 @@ error_code status(const Twine &path, file_status &result) { else result = file_status(file_type::type_unknown); + result.st_dev = status.st_dev; + result.st_ino = status.st_ino; + return success; } @@ -441,7 +433,8 @@ rety_open_create: return success; } -error_code directory_iterator_construct(directory_iterator &it, StringRef path){ +error_code detail::directory_iterator_construct(detail::DirIterState &it, + StringRef path){ SmallString<128> path_null(path); DIR *directory = ::opendir(path_null.c_str()); if (directory == 0) @@ -454,7 +447,7 @@ error_code directory_iterator_construct(directory_iterator &it, StringRef path){ return directory_iterator_increment(it); } -error_code directory_iterator_destruct(directory_iterator& it) { +error_code detail::directory_iterator_destruct(detail::DirIterState &it) { if (it.IterationHandle) ::closedir(reinterpret_cast<DIR *>(it.IterationHandle)); it.IterationHandle = 0; @@ -462,7 +455,7 @@ error_code directory_iterator_destruct(directory_iterator& it) { return success; } -error_code directory_iterator_increment(directory_iterator& it) { +error_code detail::directory_iterator_increment(detail::DirIterState &it) { errno = 0; dirent *cur_dir = ::readdir(reinterpret_cast<DIR *>(it.IterationHandle)); if (cur_dir == 0 && errno != 0) { diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc index 346baf1..e5990d0 100644 --- a/lib/Support/Unix/Program.inc +++ b/lib/Support/Unix/Program.inc @@ -412,19 +412,19 @@ Program::Kill(std::string* ErrMsg) { return false; } -bool Program::ChangeStdinToBinary(){ +error_code Program::ChangeStdinToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. - return false; + return make_error_code(errc::success); } -bool Program::ChangeStdoutToBinary(){ +error_code Program::ChangeStdoutToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. - return false; + return make_error_code(errc::success); } -bool Program::ChangeStderrToBinary(){ +error_code Program::ChangeStderrToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. - return false; + return make_error_code(errc::success); } } |
