diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-05 20:45:04 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-05 20:45:04 +0000 |
commit | 91d3cfed785b46723ebbf8197f70aa0f854c05d7 (patch) | |
tree | 94f71306bb51cc3e1cadab7d71e0de2d51328b89 /llvm/lib/Support/Unix | |
parent | 27e95f7c7b22117e5f36d1ef874dac9b48555f18 (diff) | |
download | bcm5719-llvm-91d3cfed785b46723ebbf8197f70aa0f854c05d7.tar.gz bcm5719-llvm-91d3cfed785b46723ebbf8197f70aa0f854c05d7.zip |
Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes."
This reverts commit r265454 since it broke the build. E.g.:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/
llvm-svn: 265459
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 41 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Process.inc | 36 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 29 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Signals.inc | 53 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/ThreadLocal.inc | 12 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Unix.h | 8 |
6 files changed, 64 insertions, 115 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(); diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc index 350b145c28c..cad81f8074f 100644 --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -30,7 +30,9 @@ #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif -#include <csignal> +#if HAVE_SIGNAL_H +#include <signal.h> +#endif // DragonFlyBSD, OpenBSD, and Bitrig have deprecated <malloc.h> for // <stdlib.h> instead. Unix.h includes this for us already. #if defined(HAVE_MALLOC_H) && !defined(__DragonFly__) && \ @@ -58,9 +60,7 @@ using namespace llvm; using namespace sys; -namespace { - -std::pair<TimeValue, TimeValue> getRUsageTimes() { +static std::pair<TimeValue, TimeValue> getRUsageTimes() { #if defined(HAVE_GETRUSAGE) struct rusage RU; ::getrusage(RUSAGE_SELF, &RU); @@ -79,8 +79,6 @@ std::pair<TimeValue, TimeValue> getRUsageTimes() { #endif } -} // end anonymous namespace - // On Cygwin, getpagesize() returns 64k(AllocationGranularity) and // offset in mmap(3) should be aligned to the AllocationGranularity. unsigned Process::getPageSize() { @@ -191,7 +189,6 @@ Process::GetArgumentVector(SmallVectorImpl<const char *> &ArgsOut, } namespace { - class FDCloser { public: FDCloser(int &FD) : FD(FD), KeepOpen(false) {} @@ -208,8 +205,7 @@ private: int &FD; bool KeepOpen; }; - -} // end anonymous namespace +} std::error_code Process::FixupStandardFileDescriptors() { int NullFD = -1; @@ -304,9 +300,7 @@ bool Process::FileDescriptorIsDisplayed(int fd) { #endif } -namespace { - -unsigned getColumns(int FileID) { +static unsigned getColumns(int FileID) { // If COLUMNS is defined in the environment, wrap to that many columns. if (const char *ColumnsStr = std::getenv("COLUMNS")) { int Columns = std::atoi(ColumnsStr); @@ -326,8 +320,6 @@ unsigned getColumns(int FileID) { return Columns; } -} // end anonymous namespace - unsigned Process::StandardOutColumns() { if (!StandardOutIsDisplayed()) return 0; @@ -352,13 +344,11 @@ extern "C" int del_curterm(struct term *termp); extern "C" int tigetnum(char *capname); #endif -namespace { - #ifdef HAVE_TERMINFO -ManagedStatic<sys::Mutex> TermColorMutex; +static ManagedStatic<sys::Mutex> TermColorMutex; #endif -bool terminalHasColors(int fd) { +static bool terminalHasColors(int fd) { #ifdef HAVE_TERMINFO // First, acquire a global lock because these C routines are thread hostile. MutexGuard G(*TermColorMutex); @@ -398,8 +388,6 @@ bool terminalHasColors(int fd) { return false; } -} // end anonymous namespace - bool Process::FileDescriptorHasColors(int fd) { // A file descriptor has colors if it is displayed and the terminal has // colors. @@ -440,10 +428,7 @@ const char *Process::ResetColor() { } #if !defined(HAVE_DECL_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM - -namespace { - -unsigned GetRandomNumberSeed() { +static unsigned GetRandomNumberSeed() { // Attempt to get the initial seed from /dev/urandom, if possible. int urandomFD = open("/dev/urandom", O_RDONLY); @@ -465,9 +450,6 @@ unsigned GetRandomNumberSeed() { TimeValue Now = TimeValue::now(); return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid()); } - -} // end anonymous namespace - #endif unsigned llvm::sys::Process::GetRandomNumber() { diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index ee7df0a86b8..7d3537e2072 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -1,4 +1,4 @@ -//===- llvm/Support/Unix/Program.cpp ----------------------------*- C++ -*-===// +//===- llvm/Support/Unix/Program.cpp -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -30,7 +30,9 @@ #if HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif -#include <csignal> +#if HAVE_SIGNAL_H +#include <signal.h> +#endif #if HAVE_FCNTL_H #include <fcntl.h> #endif @@ -94,9 +96,7 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name, return errc::no_such_file_or_directory; } -namespace { - -bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) { +static bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) { if (!Path) // Noop return false; std::string File; @@ -125,8 +125,8 @@ bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) { } #ifdef HAVE_POSIX_SPAWN -bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg, - posix_spawn_file_actions_t *FileActions) { +static bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg, + posix_spawn_file_actions_t *FileActions) { if (!Path) // Noop return false; const char *File; @@ -144,10 +144,10 @@ bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg, } #endif -void TimeOutHandler(int Sig) { +static void TimeOutHandler(int Sig) { } -void SetMemoryLimits (unsigned size) +static void SetMemoryLimits (unsigned size) { #if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT struct rlimit r; @@ -176,9 +176,7 @@ void SetMemoryLimits (unsigned size) #endif } -} // end anonymous namespace - -} // end namespace llvm +} static bool Execute(ProcessInfo &PI, StringRef Program, const char **args, const char **envp, const StringRef **redirects, @@ -421,12 +419,12 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, return WaitResult; } -std::error_code sys::ChangeStdinToBinary() { + std::error_code sys::ChangeStdinToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. return std::error_code(); } -std::error_code sys::ChangeStdoutToBinary() { + std::error_code sys::ChangeStdoutToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. return std::error_code(); } @@ -468,5 +466,4 @@ bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef<co } return true; } - -} // end namespace llvm +} diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 8be91cd5fb8..061cdb3da21 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -1,4 +1,4 @@ -//===- Signals.cpp - Generic Unix Signals Implementation --------*- C++ -*-===// +//===- Signals.cpp - Generic Unix Signals Implementation -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -27,7 +27,9 @@ #if HAVE_EXECINFO_H # include <execinfo.h> // For backtrace(). #endif -#include <csignal> +#if HAVE_SIGNAL_H +#include <signal.h> +#endif #if HAVE_SYS_STAT_H #include <sys/stat.h> #endif @@ -46,27 +48,25 @@ using namespace llvm; -namespace { - -RETSIGTYPE SignalHandler(int Sig); // defined below. +static RETSIGTYPE SignalHandler(int Sig); // defined below. -ManagedStatic<SmartMutex<true> > SignalsMutex; +static ManagedStatic<SmartMutex<true> > SignalsMutex; /// InterruptFunction - The function to call if ctrl-c is pressed. -void (*InterruptFunction)() = nullptr; +static void (*InterruptFunction)() = nullptr; -ManagedStatic<std::vector<std::string>> FilesToRemove; +static ManagedStatic<std::vector<std::string>> FilesToRemove; // IntSigs - Signals that represent requested termination. There's no bug // or failure, or if there is, it's not our direct responsibility. For whatever // reason, our continued execution is no longer desirable. -const int IntSigs[] = { +static const int IntSigs[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2 }; // KillSigs - Signals that represent that we have a bug, and our prompt // termination has been ordered. -const int KillSigs[] = { +static const int KillSigs[] = { SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGQUIT #ifdef SIGSYS , SIGSYS @@ -82,13 +82,14 @@ const int KillSigs[] = { #endif }; -unsigned NumRegisteredSignals = 0; -struct { +static unsigned NumRegisteredSignals = 0; +static struct { struct sigaction SA; int SigNo; } RegisteredSignalInfo[array_lengthof(IntSigs) + array_lengthof(KillSigs)]; -void RegisterHandler(int Signal) { + +static void RegisterHandler(int Signal) { assert(NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"); @@ -105,7 +106,7 @@ void RegisterHandler(int Signal) { ++NumRegisteredSignals; } -void RegisterHandlers() { +static void RegisterHandlers() { // We need to dereference the signals mutex during handler registration so // that we force its construction. This is to prevent the first use being // during handling an actual signal because you can't safely call new in a @@ -119,7 +120,7 @@ void RegisterHandlers() { for (auto S : KillSigs) RegisterHandler(S); } -void UnregisterHandlers() { +static void UnregisterHandlers() { // Restore all of the signal handlers to how they were before we showed up. for (unsigned i = 0, e = NumRegisteredSignals; i != e; ++i) sigaction(RegisteredSignalInfo[i].SigNo, @@ -127,11 +128,12 @@ void UnregisterHandlers() { NumRegisteredSignals = 0; } + /// RemoveFilesToRemove - Process the FilesToRemove list. This function /// should be called with the SignalsMutex lock held. /// NB: This must be an async signal safe function. It cannot allocate or free /// memory, even in debug builds. -void RemoveFilesToRemove() { +static void RemoveFilesToRemove() { // Avoid constructing ManagedStatic in the signal handler. // If FilesToRemove is not constructed, there are no files to remove. if (!FilesToRemove.isConstructed()) @@ -162,7 +164,7 @@ void RemoveFilesToRemove() { } // SignalHandler - The signal handler that runs. -RETSIGTYPE SignalHandler(int Sig) { +static RETSIGTYPE SignalHandler(int Sig) { // Restore the signal behavior to default, so that the program actually // crashes when we return and the signal reissues. This also ensures that if // we crash in our signal handler that the program will terminate immediately @@ -207,8 +209,6 @@ RETSIGTYPE SignalHandler(int Sig) { #endif } -} // end anonymous namespace - void llvm::sys::RunInterruptHandlers() { sys::SmartScopedLock<true> Guard(*SignalsMutex); RemoveFilesToRemove(); @@ -264,9 +264,7 @@ struct DlIteratePhdrData { const char *main_exec_name; }; -namespace { - -int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) { +static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) { DlIteratePhdrData *data = (DlIteratePhdrData*)arg; const char *name = data->first ? data->main_exec_name : info->dlpi_name; data->first = false; @@ -289,8 +287,6 @@ int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) { return 0; } -} // end anonymous namespace - /// If this is an ELF platform, we can find all loaded modules and their virtual /// addresses with dl_iterate_phdr. static bool findModulesAndOffsets(void **StackTrace, int Depth, @@ -379,14 +375,10 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS) { #endif } -namespace { - -void PrintStackTraceSignalHandler(void *) { +static void PrintStackTraceSignalHandler(void *) { PrintStackTrace(llvm::errs()); } -} // end anonymous namespace - void llvm::sys::DisableSystemDialogsOnCrash() {} /// PrintStackTraceOnErrorSignal - When an error signal (such as SIGABRT or @@ -411,6 +403,9 @@ void llvm::sys::PrintStackTraceOnErrorSignal(bool DisableCrashReporting) { #endif } + +/***/ + // On Darwin, raise sends a signal to the main thread instead of the current // thread. This has the unfortunate effect that assert() and abort() will end up // bypassing our crash recovery attempts. We work around this for anything in diff --git a/llvm/lib/Support/Unix/ThreadLocal.inc b/llvm/lib/Support/Unix/ThreadLocal.inc index 78c694c908d..31c3f3835b2 100644 --- a/llvm/lib/Support/Unix/ThreadLocal.inc +++ b/llvm/lib/Support/Unix/ThreadLocal.inc @@ -19,11 +19,10 @@ #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_GETSPECIFIC) #include <cassert> -#include <cstdlib> #include <pthread.h> +#include <stdlib.h> namespace llvm { - using namespace sys; ThreadLocalImpl::ThreadLocalImpl() : data() { @@ -57,19 +56,14 @@ void ThreadLocalImpl::removeInstance() { setInstance(nullptr); } -} // end namespace llvm +} #else - namespace llvm { - using namespace sys; - ThreadLocalImpl::ThreadLocalImpl() : data() { } ThreadLocalImpl::~ThreadLocalImpl() { } void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);} void *ThreadLocalImpl::getInstance() { return data; } void ThreadLocalImpl::removeInstance() { setInstance(0); } - -} // end namespace llvm - +} #endif diff --git a/llvm/lib/Support/Unix/Unix.h b/llvm/lib/Support/Unix/Unix.h index 832d65bcc3a..871e612f6c1 100644 --- a/llvm/lib/Support/Unix/Unix.h +++ b/llvm/lib/Support/Unix/Unix.h @@ -1,4 +1,4 @@ -//===- llvm/Support/Unix/Unix.h - Common Unix Include File ------*- C++ -*-===// +//===- llvm/Support/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -22,7 +22,7 @@ #include "llvm/Config/config.h" // Get autoconf configuration settings #include "llvm/Support/Errno.h" #include <algorithm> -#include <cassert> +#include <assert.h> #include <cerrno> #include <cstdio> #include <cstdlib> @@ -42,7 +42,7 @@ #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #endif -#include <ctime> +#include <time.h> #ifdef HAVE_DLFCN_H # include <dlfcn.h> @@ -65,4 +65,4 @@ static inline bool MakeErrMsg( return true; } -#endif // LLVM_LIB_SUPPORT_UNIX_UNIX_H +#endif |