summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/Support/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Support/Unix')
-rw-r--r--contrib/llvm/lib/Support/Unix/Memory.inc2
-rw-r--r--contrib/llvm/lib/Support/Unix/PathV2.inc4
-rw-r--r--contrib/llvm/lib/Support/Unix/Program.inc24
-rw-r--r--contrib/llvm/lib/Support/Unix/Signals.inc21
4 files changed, 44 insertions, 7 deletions
diff --git a/contrib/llvm/lib/Support/Unix/Memory.inc b/contrib/llvm/lib/Support/Unix/Memory.inc
index f397408..2bb9bf1 100644
--- a/contrib/llvm/lib/Support/Unix/Memory.inc
+++ b/contrib/llvm/lib/Support/Unix/Memory.inc
@@ -325,7 +325,7 @@ void Memory::InvalidateInstructionCache(const void *Addr,
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
asm volatile("icbi 0, %0" : : "r"(Line));
asm volatile("isync");
-# elif defined(__arm__) && defined(__GNUC__) && !defined(__FreeBSD__)
+# elif (defined(__arm__) || defined(__aarch64__)) && defined(__GNUC__) && !defined(__FreeBSD__)
// FIXME: Can we safely always call this for __GNUC__ everywhere?
const char *Start = static_cast<const char *>(Addr);
const char *End = Start + Len;
diff --git a/contrib/llvm/lib/Support/Unix/PathV2.inc b/contrib/llvm/lib/Support/Unix/PathV2.inc
index a3dfd4b..7e0aead 100644
--- a/contrib/llvm/lib/Support/Unix/PathV2.inc
+++ b/contrib/llvm/lib/Support/Unix/PathV2.inc
@@ -430,9 +430,7 @@ rety_open_create:
if (SavedErrno == errc::file_exists)
goto retry_random_path;
// If path prefix doesn't exist, try to create it.
- if (SavedErrno == errc::no_such_file_or_directory &&
- !exists(path::parent_path(RandomPath)) &&
- !TriedToCreateParent) {
+ if (SavedErrno == errc::no_such_file_or_directory && !TriedToCreateParent) {
TriedToCreateParent = true;
StringRef p(RandomPath);
SmallString<64> dir_to_create;
diff --git a/contrib/llvm/lib/Support/Unix/Program.inc b/contrib/llvm/lib/Support/Unix/Program.inc
index 117151c..aa03d48 100644
--- a/contrib/llvm/lib/Support/Unix/Program.inc
+++ b/contrib/llvm/lib/Support/Unix/Program.inc
@@ -32,6 +32,9 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef HAVE_POSIX_SPAWN
#include <spawn.h>
#if !defined(__APPLE__)
@@ -409,4 +412,25 @@ error_code Program::ChangeStderrToBinary(){
return make_error_code(errc::success);
}
+bool llvm::sys::argumentsFitWithinSystemLimits(ArrayRef<const char*> Args) {
+ static long ArgMax = sysconf(_SC_ARG_MAX);
+
+ // System says no practical limit.
+ if (ArgMax == -1)
+ return true;
+
+ // Conservatively account for space required by environment variables.
+ ArgMax /= 2;
+
+ size_t ArgLength = 0;
+ for (ArrayRef<const char*>::iterator I = Args.begin(), E = Args.end();
+ I != E; ++I) {
+ ArgLength += strlen(*I) + 1;
+ if (ArgLength > size_t(ArgMax)) {
+ return false;
+ }
+ }
+ return true;
+}
+
}
diff --git a/contrib/llvm/lib/Support/Unix/Signals.inc b/contrib/llvm/lib/Support/Unix/Signals.inc
index 66338f1..64d1fc1 100644
--- a/contrib/llvm/lib/Support/Unix/Signals.inc
+++ b/contrib/llvm/lib/Support/Unix/Signals.inc
@@ -27,10 +27,12 @@
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
-#if HAVE_DLFCN_H && __GNUG__
-#include <dlfcn.h>
+#if HAVE_CXXABI_H
#include <cxxabi.h>
#endif
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
#if HAVE_MACH_MACH_H
#include <mach/mach.h>
#endif
@@ -184,6 +186,15 @@ static RETSIGTYPE SignalHandler(int Sig) {
// Otherwise if it is a fault (like SEGV) run any handler.
for (unsigned i = 0, e = CallBacksToRun.size(); i != e; ++i)
CallBacksToRun[i].first(CallBacksToRun[i].second);
+
+#ifdef __s390__
+ // On S/390, certain signals are delivered with PSW Address pointing to
+ // *after* the faulting instruction. Simply returning from the signal
+ // handler would continue execution after that point, instead of
+ // re-raising the signal. Raise the signal manually in those cases.
+ if (Sig == SIGILL || Sig == SIGFPE || Sig == SIGTRAP)
+ raise(Sig);
+#endif
}
void llvm::sys::RunInterruptHandlers() {
@@ -290,9 +301,13 @@ void llvm::sys::PrintStackTrace(FILE *FD) {
(int)(sizeof(void*) * 2) + 2, (unsigned long)StackTrace[i]);
if (dlinfo.dli_sname != NULL) {
- int res;
fputc(' ', FD);
+# if HAVE_CXXABI_H
+ int res;
char* d = abi::__cxa_demangle(dlinfo.dli_sname, NULL, NULL, &res);
+# else
+ char* d = NULL;
+# endif
if (d == NULL) fputs(dlinfo.dli_sname, FD);
else fputs(d, FD);
free(d);
OpenPOWER on IntegriCloud