diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-04-05 20:19:49 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2016-04-05 20:19:49 +0000 |
commit | 9a7a3bcf2955decb12cd642133eaa594f3cd121d (patch) | |
tree | 78315f78bc0109a6778d35838e0482c165cac9bd /lib/Support/Unix/Process.inc | |
parent | fe34a372e1ab527f3102ec0521005a35eecdd229 (diff) |
Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes.
Some Include What You Use suggestions were used too.
Use anonymous namespaces in source files.
Differential revision: http://reviews.llvm.org/D18778
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/Process.inc')
-rw-r--r-- | lib/Support/Unix/Process.inc | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index cad81f8074f..350b145c28c 100644 --- a/lib/Support/Unix/Process.inc +++ b/lib/Support/Unix/Process.inc @@ -30,9 +30,7 @@ #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif +#include <csignal> // 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__) && \ @@ -60,7 +58,9 @@ using namespace llvm; using namespace sys; -static std::pair<TimeValue, TimeValue> getRUsageTimes() { +namespace { + +std::pair<TimeValue, TimeValue> getRUsageTimes() { #if defined(HAVE_GETRUSAGE) struct rusage RU; ::getrusage(RUSAGE_SELF, &RU); @@ -79,6 +79,8 @@ static 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() { @@ -189,6 +191,7 @@ Process::GetArgumentVector(SmallVectorImpl<const char *> &ArgsOut, } namespace { + class FDCloser { public: FDCloser(int &FD) : FD(FD), KeepOpen(false) {} @@ -205,7 +208,8 @@ private: int &FD; bool KeepOpen; }; -} + +} // end anonymous namespace std::error_code Process::FixupStandardFileDescriptors() { int NullFD = -1; @@ -300,7 +304,9 @@ bool Process::FileDescriptorIsDisplayed(int fd) { #endif } -static unsigned getColumns(int FileID) { +namespace { + +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); @@ -320,6 +326,8 @@ static unsigned getColumns(int FileID) { return Columns; } +} // end anonymous namespace + unsigned Process::StandardOutColumns() { if (!StandardOutIsDisplayed()) return 0; @@ -344,11 +352,13 @@ extern "C" int del_curterm(struct term *termp); extern "C" int tigetnum(char *capname); #endif +namespace { + #ifdef HAVE_TERMINFO -static ManagedStatic<sys::Mutex> TermColorMutex; +ManagedStatic<sys::Mutex> TermColorMutex; #endif -static bool terminalHasColors(int fd) { +bool terminalHasColors(int fd) { #ifdef HAVE_TERMINFO // First, acquire a global lock because these C routines are thread hostile. MutexGuard G(*TermColorMutex); @@ -388,6 +398,8 @@ static 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. @@ -428,7 +440,10 @@ const char *Process::ResetColor() { } #if !defined(HAVE_DECL_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM -static unsigned GetRandomNumberSeed() { + +namespace { + +unsigned GetRandomNumberSeed() { // Attempt to get the initial seed from /dev/urandom, if possible. int urandomFD = open("/dev/urandom", O_RDONLY); @@ -450,6 +465,9 @@ static unsigned GetRandomNumberSeed() { TimeValue Now = TimeValue::now(); return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid()); } + +} // end anonymous namespace + #endif unsigned llvm::sys::Process::GetRandomNumber() { |