diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/lib/Support/Unix | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Support/Unix')
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Unix/Path.inc | 142 | ||||
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Unix/Process.inc | 6 | ||||
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Unix/Program.inc | 10 | ||||
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Unix/Signals.inc | 36 | ||||
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Unix/Threading.inc | 16 |
5 files changed, 105 insertions, 105 deletions
diff --git a/contrib/libs/llvm12/lib/Support/Unix/Path.inc b/contrib/libs/llvm12/lib/Support/Unix/Path.inc index 1c2fc15fc5..996b8aebf6 100644 --- a/contrib/libs/llvm12/lib/Support/Unix/Path.inc +++ b/contrib/libs/llvm12/lib/Support/Unix/Path.inc @@ -33,7 +33,7 @@ #include <dirent.h> #include <pwd.h> -#include <sys/file.h> +#include <sys/file.h> #ifdef __APPLE__ #include <mach-o/dyld.h> @@ -147,9 +147,9 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin) static char * getprogpath(char ret[PATH_MAX], const char *bin) { - if (bin == nullptr) - return nullptr; - + if (bin == nullptr) + return nullptr; + /* First approach: absolute path. */ if (bin[0] == '/') { if (test_dir(ret, "/", bin) == 0) @@ -793,16 +793,16 @@ std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, if (::futimes(FD, Times)) return std::error_code(errno, std::generic_category()); return std::error_code(); -#elif defined(__MVS__) - attrib_t Attr; - memset(&Attr, 0, sizeof(Attr)); - Attr.att_atimechg = 1; - Attr.att_atime = sys::toTimeT(AccessTime); - Attr.att_mtimechg = 1; - Attr.att_mtime = sys::toTimeT(ModificationTime); - if (::__fchattr(FD, &Attr, sizeof(Attr)) != 0) - return std::error_code(errno, std::generic_category()); - return std::error_code(); +#elif defined(__MVS__) + attrib_t Attr; + memset(&Attr, 0, sizeof(Attr)); + Attr.att_atimechg = 1; + Attr.att_atime = sys::toTimeT(AccessTime); + Attr.att_mtimechg = 1; + Attr.att_mtime = sys::toTimeT(ModificationTime); + if (::__fchattr(FD, &Attr, sizeof(Attr)) != 0) + return std::error_code(errno, std::generic_category()); + return std::error_code(); #else #warning Missing futimes() and futimens() return make_error_code(errc::function_not_supported); @@ -1067,13 +1067,13 @@ file_t getStdoutHandle() { return 1; } file_t getStderrHandle() { return 2; } Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) { -#if defined(__APPLE__) - size_t Size = std::min<size_t>(Buf.size(), INT32_MAX); -#else - size_t Size = Buf.size(); -#endif +#if defined(__APPLE__) + size_t Size = std::min<size_t>(Buf.size(), INT32_MAX); +#else + size_t Size = Buf.size(); +#endif ssize_t NumRead = - sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size); + sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size); if (ssize_t(NumRead) == -1) return errorCodeToError(std::error_code(errno, std::generic_category())); return NumRead; @@ -1081,69 +1081,69 @@ Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) { Expected<size_t> readNativeFileSlice(file_t FD, MutableArrayRef<char> Buf, uint64_t Offset) { -#if defined(__APPLE__) - size_t Size = std::min<size_t>(Buf.size(), INT32_MAX); -#else - size_t Size = Buf.size(); -#endif +#if defined(__APPLE__) + size_t Size = std::min<size_t>(Buf.size(), INT32_MAX); +#else + size_t Size = Buf.size(); +#endif #ifdef HAVE_PREAD ssize_t NumRead = - sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset); + sys::RetryAfterSignal(-1, ::pread, FD, Buf.data(), Size, Offset); #else if (lseek(FD, Offset, SEEK_SET) == -1) return errorCodeToError(std::error_code(errno, std::generic_category())); ssize_t NumRead = - sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size); + sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size); #endif if (NumRead == -1) return errorCodeToError(std::error_code(errno, std::generic_category())); return NumRead; } -std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) { - auto Start = std::chrono::steady_clock::now(); - auto End = Start + Timeout; - do { - struct flock Lock; - memset(&Lock, 0, sizeof(Lock)); - Lock.l_type = F_WRLCK; - Lock.l_whence = SEEK_SET; - Lock.l_start = 0; - Lock.l_len = 0; - if (::fcntl(FD, F_SETLK, &Lock) != -1) - return std::error_code(); - int Error = errno; - if (Error != EACCES && Error != EAGAIN) - return std::error_code(Error, std::generic_category()); - usleep(1000); - } while (std::chrono::steady_clock::now() < End); - return make_error_code(errc::no_lock_available); -} - -std::error_code lockFile(int FD) { - struct flock Lock; - memset(&Lock, 0, sizeof(Lock)); - Lock.l_type = F_WRLCK; - Lock.l_whence = SEEK_SET; - Lock.l_start = 0; - Lock.l_len = 0; - if (::fcntl(FD, F_SETLKW, &Lock) != -1) - return std::error_code(); - int Error = errno; - return std::error_code(Error, std::generic_category()); -} - -std::error_code unlockFile(int FD) { - struct flock Lock; - Lock.l_type = F_UNLCK; - Lock.l_whence = SEEK_SET; - Lock.l_start = 0; - Lock.l_len = 0; - if (::fcntl(FD, F_SETLK, &Lock) != -1) - return std::error_code(); - return std::error_code(errno, std::generic_category()); -} - +std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout) { + auto Start = std::chrono::steady_clock::now(); + auto End = Start + Timeout; + do { + struct flock Lock; + memset(&Lock, 0, sizeof(Lock)); + Lock.l_type = F_WRLCK; + Lock.l_whence = SEEK_SET; + Lock.l_start = 0; + Lock.l_len = 0; + if (::fcntl(FD, F_SETLK, &Lock) != -1) + return std::error_code(); + int Error = errno; + if (Error != EACCES && Error != EAGAIN) + return std::error_code(Error, std::generic_category()); + usleep(1000); + } while (std::chrono::steady_clock::now() < End); + return make_error_code(errc::no_lock_available); +} + +std::error_code lockFile(int FD) { + struct flock Lock; + memset(&Lock, 0, sizeof(Lock)); + Lock.l_type = F_WRLCK; + Lock.l_whence = SEEK_SET; + Lock.l_start = 0; + Lock.l_len = 0; + if (::fcntl(FD, F_SETLKW, &Lock) != -1) + return std::error_code(); + int Error = errno; + return std::error_code(Error, std::generic_category()); +} + +std::error_code unlockFile(int FD) { + struct flock Lock; + Lock.l_type = F_UNLCK; + Lock.l_whence = SEEK_SET; + Lock.l_start = 0; + Lock.l_len = 0; + if (::fcntl(FD, F_SETLK, &Lock) != -1) + return std::error_code(); + return std::error_code(errno, std::generic_category()); +} + std::error_code closeFile(file_t &F) { file_t TmpF = F; F = kInvalidFile; diff --git a/contrib/libs/llvm12/lib/Support/Unix/Process.inc b/contrib/libs/llvm12/lib/Support/Unix/Process.inc index 8058a3b7ce..7425d084da 100644 --- a/contrib/libs/llvm12/lib/Support/Unix/Process.inc +++ b/contrib/libs/llvm12/lib/Support/Unix/Process.inc @@ -313,7 +313,7 @@ unsigned Process::StandardErrColumns() { return getColumns(); } -#ifdef LLVM_ENABLE_TERMINFO +#ifdef LLVM_ENABLE_TERMINFO // We manually declare these extern functions because finding the correct // headers from various terminfo, curses, or other sources is harder than // writing their specs down. @@ -323,12 +323,12 @@ extern "C" int del_curterm(struct term *termp); extern "C" int tigetnum(char *capname); #endif -#ifdef LLVM_ENABLE_TERMINFO +#ifdef LLVM_ENABLE_TERMINFO static ManagedStatic<std::mutex> TermColorMutex; #endif static bool terminalHasColors(int fd) { -#ifdef LLVM_ENABLE_TERMINFO +#ifdef LLVM_ENABLE_TERMINFO // First, acquire a global lock because these C routines are thread hostile. std::lock_guard<std::mutex> G(*TermColorMutex); diff --git a/contrib/libs/llvm12/lib/Support/Unix/Program.inc b/contrib/libs/llvm12/lib/Support/Unix/Program.inc index a018bc06d1..fb56fa4b0d 100644 --- a/contrib/libs/llvm12/lib/Support/Unix/Program.inc +++ b/contrib/libs/llvm12/lib/Support/Unix/Program.inc @@ -174,8 +174,8 @@ toNullTerminatedCStringArray(ArrayRef<StringRef> Strings, StringSaver &Saver) { static bool Execute(ProcessInfo &PI, StringRef Program, ArrayRef<StringRef> Args, Optional<ArrayRef<StringRef>> Env, ArrayRef<Optional<StringRef>> Redirects, - unsigned MemoryLimit, std::string *ErrMsg, - BitVector *AffinityMask) { + unsigned MemoryLimit, std::string *ErrMsg, + BitVector *AffinityMask) { if (!llvm::sys::fs::exists(Program)) { if (ErrMsg) *ErrMsg = std::string("Executable \"") + Program.str() + @@ -183,9 +183,9 @@ static bool Execute(ProcessInfo &PI, StringRef Program, return false; } - assert(!AffinityMask && "Starting a process with an affinity mask is " - "currently not supported on Unix!"); - + assert(!AffinityMask && "Starting a process with an affinity mask is " + "currently not supported on Unix!"); + BumpPtrAllocator Allocator; StringSaver Saver(Allocator); std::vector<const char *> ArgVector, EnvVector; diff --git a/contrib/libs/llvm12/lib/Support/Unix/Signals.inc b/contrib/libs/llvm12/lib/Support/Unix/Signals.inc index 8906d28ddd..3d7b5d2fe5 100644 --- a/contrib/libs/llvm12/lib/Support/Unix/Signals.inc +++ b/contrib/libs/llvm12/lib/Support/Unix/Signals.inc @@ -36,7 +36,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Config/config.h" #include "llvm/Demangle/Demangle.h" -#include "llvm/Support/ExitCodes.h" +#include "llvm/Support/ExitCodes.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Format.h" @@ -331,7 +331,7 @@ static void RegisterHandlers() { // Not signal-safe. registerHandler(S, SignalKind::IsInfo); } -void sys::unregisterHandlers() { +void sys::unregisterHandlers() { // Restore all of the signal handlers to how they were before we showed up. for (unsigned i = 0, e = NumRegisteredSignals.load(); i != e; ++i) { sigaction(RegisteredSignalInfo[i].SigNo, @@ -367,7 +367,7 @@ static RETSIGTYPE SignalHandler(int Sig) { // 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 // instead of recursing in the signal handler. - sys::unregisterHandlers(); + sys::unregisterHandlers(); // Unmask all potentially blocked kill signals. sigset_t SigMask; @@ -382,15 +382,15 @@ static RETSIGTYPE SignalHandler(int Sig) { OneShotPipeSignalFunction.exchange(nullptr)) return OldOneShotPipeFunction(); - bool IsIntSig = llvm::is_contained(IntSigs, Sig); - if (IsIntSig) + bool IsIntSig = llvm::is_contained(IntSigs, Sig); + if (IsIntSig) if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr)) return OldInterruptFunction(); - if (Sig == SIGPIPE || IsIntSig) { - raise(Sig); // Execute the default handler. + if (Sig == SIGPIPE || IsIntSig) { + raise(Sig); // Execute the default handler. return; - } + } } // Otherwise if it is a fault (like SEGV) run any handler. @@ -555,7 +555,7 @@ static int unwindBacktrace(void **StackTrace, int MaxEntries) { // // On glibc systems we have the 'backtrace' function, which works nicely, but // doesn't demangle symbols. -void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { +void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { #if ENABLE_BACKTRACES static void *StackTrace[256]; int depth = 0; @@ -572,15 +572,15 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { #endif if (!depth) return; - // If "Depth" is not provided by the caller, use the return value of - // backtrace() for printing a symbolized stack trace. - if (!Depth) - Depth = depth; - if (printSymbolizedStackTrace(Argv0, StackTrace, Depth, OS)) + // If "Depth" is not provided by the caller, use the return value of + // backtrace() for printing a symbolized stack trace. + if (!Depth) + Depth = depth; + if (printSymbolizedStackTrace(Argv0, StackTrace, Depth, OS)) return; - OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in " - "your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point " - "to it):\n"; + OS << "Stack dump without symbol names (ensure you have llvm-symbolizer in " + "your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point " + "to it):\n"; #if HAVE_DLFCN_H && HAVE_DLADDR int width = 0; for (int i = 0; i < depth; ++i) { @@ -622,7 +622,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { OS << '\n'; } #elif defined(HAVE_BACKTRACE) - backtrace_symbols_fd(StackTrace, Depth, STDERR_FILENO); + backtrace_symbols_fd(StackTrace, Depth, STDERR_FILENO); #endif #endif } diff --git a/contrib/libs/llvm12/lib/Support/Unix/Threading.inc b/contrib/libs/llvm12/lib/Support/Unix/Threading.inc index 4e8c82dbac..a745495d6e 100644 --- a/contrib/libs/llvm12/lib/Support/Unix/Threading.inc +++ b/contrib/libs/llvm12/lib/Support/Unix/Threading.inc @@ -28,7 +28,7 @@ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include <errno.h> -#include <sys/cpuset.h> +#include <sys/cpuset.h> #include <sys/sysctl.h> #include <sys/user.h> #include <unistd.h> @@ -283,13 +283,13 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) { #include <thread> int computeHostNumHardwareThreads() { -#if defined(__FreeBSD__) - cpuset_t mask; - CPU_ZERO(&mask); - if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask), - &mask) == 0) - return CPU_COUNT(&mask); -#elif defined(__linux__) +#if defined(__FreeBSD__) + cpuset_t mask; + CPU_ZERO(&mask); + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask), + &mask) == 0) + return CPU_COUNT(&mask); +#elif defined(__linux__) cpu_set_t Set; if (sched_getaffinity(0, sizeof(Set), &Set) == 0) return CPU_COUNT(&Set); |