summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
diff options
context:
space:
mode:
authorivmai <ivmai>2010-12-26 15:20:38 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:55 +0200
commit7b66e36f08dd096bc6df1ebc362d2689264f7825 (patch)
treece2884e5f794a843f6849592dd437c4e34eb427c /pthread_stop_world.c
parentda518ec93509c607211f69d1ab0565fe0b663397 (diff)
2010-12-26 Ivan Maidanski <ivmai@mail.ru> (mostly really Geoff Norton
and Jonathan Pryor) * configure.ac: Use AC_CHECK_LIB() to check for pthread instead of just blindly linking to -lpthread, as Android includes pthread support within libc and does not provide a separate libpthread. * dyn_load.c (GC_register_dynamic_libraries): Skip current link map entry if l_addr is NULL (Android/bionic only). * pthread_stop_world.c (android_thread_kill): New internal function (Android only). * pthread_stop_world.c (GC_suspend_all, GC_start_world): Call android_thread_kill (based on tkill) instead of pthread_kill on Android (since pthread_kill cannot be used safely on the platform). * pthread_support.c (GC_new_thread): Store thread Id (obtained from gettid) for use by android_thread_kill (Android only). * include/private/pthread_support.h (GC_Thread_Rep): Add kernel_id structure member (Android only). * include/private/gcconfig.h: Recognize __x86_64 macro as a synonym of __x86_64__ (Darwin); define __environ macro (Android on M68K). * configure: Regenerate.
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r--pthread_stop_world.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index 96bd792..6478980 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -360,6 +360,22 @@ GC_INNER void GC_push_all_stacks(void)
int GC_stopping_pid = 0;
#endif
+#ifdef PLATFORM_ANDROID
+ static int android_thread_kill(pid_t tid, int sig)
+ {
+ int ret;
+ int old_errno = errno;
+
+ ret = tkill(tid, sig);
+ if (ret < 0) {
+ ret = errno;
+ errno = old_errno;
+ }
+
+ return ret;
+ }
+#endif /* PLATFORM_ANDROID */
+
/* We hold the allocation lock. Suspend all threads that might */
/* still be running. Return the number of suspend signals that */
/* were sent. */
@@ -402,7 +418,11 @@ STATIC int GC_suspend_all(void)
p -> stop_info.stack_ptr =
*(ptr_t *)((char *)p -> id + UTHREAD_SP_OFFSET);
# else
- result = pthread_kill(p -> id, SIG_SUSPEND);
+# ifndef PLATFORM_ANDROID
+ result = pthread_kill(p -> id, SIG_SUSPEND);
+# else
+ result = android_thread_kill(p -> kernel_id, SIG_SUSPEND);
+# endif
switch(result) {
case ESRCH:
/* Not really there anymore. Possible? */
@@ -541,9 +561,13 @@ GC_INNER void GC_start_world(void)
# ifdef GC_OPENBSD_THREADS
if (pthread_resume_np(p -> id) != 0)
- ABORT("pthread_kill failed");
+ ABORT("pthread_resume_np failed");
# else
- result = pthread_kill(p -> id, SIG_THR_RESTART);
+# ifndef PLATFORM_ANDROID
+ result = pthread_kill(p -> id, SIG_THR_RESTART);
+# else
+ result = android_thread_kill(p -> kernel_id, SIG_THR_RESTART);
+# endif
switch(result) {
case ESRCH:
/* Not really there anymore. Possible? */