summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/thread.cc37
-rw-r--r--runtime/thread.h3
-rw-r--r--runtime/thread_android.cc8
-rw-r--r--runtime/thread_linux.cc37
4 files changed, 48 insertions, 37 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index d6bd8a45a6..645c12caec 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -216,43 +216,6 @@ static size_t FixStackSize(size_t stack_size) {
return stack_size;
}
-static void SigAltStack(stack_t* new_stack, stack_t* old_stack) {
- if (sigaltstack(new_stack, old_stack) == -1) {
- PLOG(FATAL) << "sigaltstack failed";
- }
-}
-
-static void SetUpAlternateSignalStack() {
- // Create and set an alternate signal stack.
- stack_t ss;
- ss.ss_sp = new uint8_t[SIGSTKSZ];
- ss.ss_size = SIGSTKSZ;
- ss.ss_flags = 0;
- CHECK(ss.ss_sp != NULL);
- SigAltStack(&ss, NULL);
-
- // Double-check that it worked.
- ss.ss_sp = NULL;
- SigAltStack(NULL, &ss);
- VLOG(threads) << "Alternate signal stack is " << PrettySize(ss.ss_size) << " at " << ss.ss_sp;
-}
-
-static void TearDownAlternateSignalStack() {
- // Get the pointer so we can free the memory.
- stack_t ss;
- SigAltStack(NULL, &ss);
- uint8_t* allocated_signal_stack = reinterpret_cast<uint8_t*>(ss.ss_sp);
-
- // Tell the kernel to stop using it.
- ss.ss_sp = NULL;
- ss.ss_flags = SS_DISABLE;
- ss.ss_size = SIGSTKSZ; // Avoid ENOMEM failure with Mac OS' buggy libc.
- SigAltStack(&ss, NULL);
-
- // Free it.
- delete[] allocated_signal_stack;
-}
-
void Thread::CreateNativeThread(JNIEnv* env, jobject java_peer, size_t stack_size, bool is_daemon) {
CHECK(java_peer != NULL);
Thread* self = static_cast<JNIEnvExt*>(env)->self;
diff --git a/runtime/thread.h b/runtime/thread.h
index 0daf763359..e496cfc1f8 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -618,6 +618,9 @@ class PACKED(4) Thread {
void InitPthreadKeySelf();
void InitStackHwm();
+ void SetUpAlternateSignalStack();
+ void TearDownAlternateSignalStack();
+
void NotifyLocked(Thread* self) EXCLUSIVE_LOCKS_REQUIRED(wait_mutex_);
static void ThreadExitCallback(void* arg);
diff --git a/runtime/thread_android.cc b/runtime/thread_android.cc
index 7c4551fa24..73a9e54ea5 100644
--- a/runtime/thread_android.cc
+++ b/runtime/thread_android.cc
@@ -87,4 +87,12 @@ int Thread::GetNativePriority() {
return managed_priority;
}
+void Thread::SetUpAlternateSignalStack() {
+ // Bionic does this for us.
+}
+
+void Thread::TearDownAlternateSignalStack() {
+ // Bionic does this for us.
+}
+
} // namespace art
diff --git a/runtime/thread_linux.cc b/runtime/thread_linux.cc
index 6f4b75dac1..1bd708ae45 100644
--- a/runtime/thread_linux.cc
+++ b/runtime/thread_linux.cc
@@ -26,4 +26,41 @@ int Thread::GetNativePriority() {
return kNormThreadPriority;
}
+static void SigAltStack(stack_t* new_stack, stack_t* old_stack) {
+ if (sigaltstack(new_stack, old_stack) == -1) {
+ PLOG(FATAL) << "sigaltstack failed";
+ }
+}
+
+void Thread::SetUpAlternateSignalStack() {
+ // Create and set an alternate signal stack.
+ stack_t ss;
+ ss.ss_sp = new uint8_t[SIGSTKSZ];
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ CHECK(ss.ss_sp != NULL);
+ SigAltStack(&ss, NULL);
+
+ // Double-check that it worked.
+ ss.ss_sp = NULL;
+ SigAltStack(NULL, &ss);
+ VLOG(threads) << "Alternate signal stack is " << PrettySize(ss.ss_size) << " at " << ss.ss_sp;
+}
+
+void Thread::TearDownAlternateSignalStack() {
+ // Get the pointer so we can free the memory.
+ stack_t ss;
+ SigAltStack(NULL, &ss);
+ uint8_t* allocated_signal_stack = reinterpret_cast<uint8_t*>(ss.ss_sp);
+
+ // Tell the kernel to stop using it.
+ ss.ss_sp = NULL;
+ ss.ss_flags = SS_DISABLE;
+ ss.ss_size = SIGSTKSZ; // Avoid ENOMEM failure with Mac OS' buggy libc.
+ SigAltStack(&ss, NULL);
+
+ // Free it.
+ delete[] allocated_signal_stack;
+}
+
} // namespace art