summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/Path.inc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/Unix/Path.inc')
-rw-r--r--llvm/lib/Support/Unix/Path.inc41
1 files changed, 11 insertions, 30 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 8d1dfc76aea..3cedf64d4b0 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -17,9 +17,8 @@
//===----------------------------------------------------------------------===//
#include "Unix.h"
-#include <cassert>
-#include <climits>
-#include <cstdio>
+#include <limits.h>
+#include <stdio.h>
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
@@ -87,10 +86,7 @@ namespace fs {
#if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
defined(__OpenBSD__) || defined(__minix) || defined(__FreeBSD_kernel__) || \
defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__)
-
-namespace {
-
-int
+static int
test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
{
struct stat sb;
@@ -105,7 +101,7 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
return 0;
}
-char *
+static char *
getprogpath(char ret[PATH_MAX], const char *bin)
{
char *pv, *s, *t;
@@ -142,9 +138,6 @@ getprogpath(char ret[PATH_MAX], const char *bin)
free(pv);
return nullptr;
}
-
-} // end anonymous namespace
-
#endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
/// GetMainExecutable - Return the path to the main executable, given the
@@ -337,9 +330,7 @@ std::error_code resize_file(int FD, uint64_t Size) {
return std::error_code();
}
-namespace {
-
-int convertAccessMode(AccessMode Mode) {
+static int convertAccessMode(AccessMode Mode) {
switch (Mode) {
case AccessMode::Exist:
return F_OK;
@@ -351,8 +342,6 @@ int convertAccessMode(AccessMode Mode) {
llvm_unreachable("invalid enum");
}
-} // end anonymous namespace
-
std::error_code access(const Twine &Path, AccessMode Mode) {
SmallString<128> PathStorage;
StringRef P = Path.toNullTerminatedStringRef(PathStorage);
@@ -392,10 +381,8 @@ std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
return std::error_code();
}
-namespace {
-
-std::error_code fillStatus(int StatRet, const struct stat &Status,
- file_status &Result) {
+static std::error_code fillStatus(int StatRet, const struct stat &Status,
+ file_status &Result) {
if (StatRet != 0) {
std::error_code ec(errno, std::generic_category());
if (ec == errc::no_such_file_or_directory)
@@ -429,8 +416,6 @@ std::error_code fillStatus(int StatRet, const struct stat &Status,
return std::error_code();
}
-} // end anonymous namespace
-
std::error_code status(const Twine &Path, file_status &Result) {
SmallString<128> PathStorage;
StringRef P = Path.toNullTerminatedStringRef(PathStorage);
@@ -612,9 +597,7 @@ bool home_directory(SmallVectorImpl<char> &result) {
return false;
}
-namespace {
-
-bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
+static bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
#if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
// On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
// macros defined in <unistd.h> on darwin >= 9
@@ -639,7 +622,7 @@ bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
return false;
}
-bool getUserCacheDir(SmallVectorImpl<char> &Result) {
+static bool getUserCacheDir(SmallVectorImpl<char> &Result) {
// First try using XDG_CACHE_HOME env variable,
// as specified in XDG Base Directory Specification at
// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -662,7 +645,7 @@ bool getUserCacheDir(SmallVectorImpl<char> &Result) {
return false;
}
-const char *getEnvTempDir() {
+static const char *getEnvTempDir() {
// Check whether the temporary directory is specified by an environment
// variable.
const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
@@ -674,7 +657,7 @@ const char *getEnvTempDir() {
return nullptr;
}
-const char *getDefaultTempDir(bool ErasedOnReboot) {
+static const char *getDefaultTempDir(bool ErasedOnReboot) {
#ifdef P_tmpdir
if ((bool)P_tmpdir)
return P_tmpdir;
@@ -685,8 +668,6 @@ const char *getDefaultTempDir(bool ErasedOnReboot) {
return "/var/tmp";
}
-} // end anonymous namespace
-
void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl<char> &Result) {
Result.clear();
OpenPOWER on IntegriCloud