Bug 741272 - Implement raise() using pthread_kill() so the signal will be sent to the the caller thread instead of a random thread in the thread group. r=blassey,khuey
authorCervantes Yu <cyu@mozilla.com>
Mon, 02 Apr 2012 17:59:29 +0800
changeset 94592 dde6ab4aa2c31e93a5cd1dcc13ea4fb202debe2d
parent 94591 6990e7e757c39e6ddc9cba8a70a77b684ae8b933
child 94593 81012bc3fa5dc90353893a52fc3ae017a7369732
push idunknown
push userunknown
push dateunknown
reviewersblassey, khuey
bugs741272
milestone14.0a1
Bug 741272 - Implement raise() using pthread_kill() so the signal will be sent to the the caller thread instead of a random thread in the thread group. r=blassey,khuey
configure.in
mozglue/android/APKOpen.cpp
mozglue/gonk/GonkGlue.cpp
--- a/configure.in
+++ b/configure.in
@@ -7225,17 +7225,17 @@ AC_SUBST(DLLFLAGS)
 dnl We need to wrap dlopen and related functions on Android because we use
 dnl our own linker.
 if test "$OS_TARGET" = Android; then
     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
     if test -n "$MOZ_OLD_LINKER"; then
         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
     fi
     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
-    WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork"
+    WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
 fi
 
 dnl ========================================================
 dnl = Use malloc wrapper lib
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
     _WRAP_MALLOC=1,
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -44,16 +44,17 @@
 #include <jni.h>
 #include <android/log.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/limits.h>
 #include <errno.h>
+#include <pthread.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <zlib.h>
 #ifdef MOZ_OLD_LINKER
 #include <linux/ashmem.h>
@@ -1077,8 +1078,15 @@ extern "C" NS_EXPORT pid_t
   default:
     for (std::vector<AtForkFuncs>::iterator it = atfork.begin();
          it < atfork.end(); ++it)
       if (it->parent)
         it->parent();
   }
   return pid;
 }
+
+extern "C" NS_EXPORT int
+__wrap_raise(int sig)
+{
+  return pthread_kill(pthread_self(), sig);
+}
+
--- a/mozglue/gonk/GonkGlue.cpp
+++ b/mozglue/gonk/GonkGlue.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <unistd.h>
+#include <pthread.h>
 #include <vector>
 
 #define NS_EXPORT __attribute__ ((visibility("default")))
 
 /* Android doesn't have pthread_atfork(), so we need to use our own. */
 struct AtForkFuncs {
   void (*prepare)(void);
   void (*parent)(void);
@@ -46,8 +47,15 @@ extern "C" NS_EXPORT pid_t
   default:
     for (std::vector<AtForkFuncs>::iterator it = atfork.begin();
          it < atfork.end(); ++it)
       if (it->parent)
         it->parent();
   }
   return pid;
 }
+
+extern "C" NS_EXPORT int
+__wrap_raise(int sig)
+{
+  return pthread_kill(pthread_self(), sig);
+}
+