summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2017-01-31 14:33:16 +0000
committer Roland Levillain <rpl@google.com> 2017-01-31 14:51:00 +0000
commit32a5bb2017f95d3cd1f1ffbe6a5d012d5ae6d5ef (patch)
treedfa8a93b5b07dc35df924da5ef979db46dd3a828
parentb49cc5506bdf8c3aa406eab5579bcd64fdaa3a43 (diff)
Fix macOS build in ART's runtime/runtime_common.{h,cc}
Test: mmma art (on macOS) Bug: 32466479 Change-Id: I9996c6a495d2465a4b00affd2ef19102c815a58f
-rw-r--r--runtime/runtime_common.cc25
-rw-r--r--runtime/runtime_common.h20
2 files changed, 31 insertions, 14 deletions
diff --git a/runtime/runtime_common.cc b/runtime/runtime_common.cc
index 1d8c16d22b..70aff37961 100644
--- a/runtime/runtime_common.cc
+++ b/runtime/runtime_common.cc
@@ -126,6 +126,20 @@ const char* GetSignalCodeName(int signal_number, int signal_code) {
return "?";
}
+struct UContext {
+ explicit UContext(void* raw_context)
+ : context(reinterpret_cast<ucontext_t*>(raw_context)->uc_mcontext) {}
+
+ void Dump(std::ostream& os) const;
+
+ void DumpRegister32(std::ostream& os, const char* name, uint32_t value) const;
+ void DumpRegister64(std::ostream& os, const char* name, uint64_t value) const;
+
+ void DumpX86Flags(std::ostream& os, uint32_t flags) const;
+
+ mcontext_t& context;
+};
+
void UContext::Dump(std::ostream& os) const {
// TODO: support non-x86 hosts.
#if defined(__APPLE__) && defined(__i386__)
@@ -274,6 +288,13 @@ static bool IsTimeoutSignal(int signal_number) {
return signal_number == GetTimeoutSignal();
}
+#if defined(__APPLE__)
+// On macOS, clang complains about art::HandleUnexpectedSignalCommon's
+// stack frame size being too large; disable that warning locally.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than="
+#endif
+
void HandleUnexpectedSignalCommon(int signal_number,
siginfo_t* info,
void* raw_context,
@@ -356,6 +377,10 @@ void HandleUnexpectedSignalCommon(int signal_number,
}
}
+#if defined(__APPLE__)
+#pragma GCC diagnostic pop
+#endif
+
void InitPlatformSignalHandlersCommon(void (*newact)(int, siginfo_t*, void*),
struct sigaction* oldact,
bool handle_timeout_signal) {
diff --git a/runtime/runtime_common.h b/runtime/runtime_common.h
index 52817fd34f..832b6bbf3e 100644
--- a/runtime/runtime_common.h
+++ b/runtime/runtime_common.h
@@ -19,6 +19,12 @@
// Code shared by runtime/runtime_android.cc and runtime/runtime_linux.cc.
+#if defined(__APPLE__)
+// On macOS, _XOPEN_SOURCE must be defined to access ucontext
+// routines, as they are considered deprecated on that platform.
+#define _XOPEN_SOURCE
+#endif
+
#include <sys/utsname.h>
#include <ucontext.h>
@@ -56,20 +62,6 @@ struct OsInfo {
const char* GetSignalName(int signal_number);
const char* GetSignalCodeName(int signal_number, int signal_code);
-struct UContext {
- explicit UContext(void* raw_context)
- : context(reinterpret_cast<ucontext_t*>(raw_context)->uc_mcontext) {}
-
- void Dump(std::ostream& os) const;
-
- void DumpRegister32(std::ostream& os, const char* name, uint32_t value) const;
- void DumpRegister64(std::ostream& os, const char* name, uint64_t value) const;
-
- void DumpX86Flags(std::ostream& os, uint32_t flags) const;
-
- mcontext_t& context;
-};
-
// Return the signal number we recognize as timeout. -1 means not active/supported.
int GetTimeoutSignal();