summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-06-06 16:47:18 +0300
committerSebastian Dröge <sebastian@centricular.com>2016-06-07 10:04:27 +0300
commiteaba7747756d9b90079d5422e579aba727d62551 (patch)
treec386e716a853e408addea2157ab3ee4f4bad43f4
parentd839d328ad5346a4f01e99e364094ec18be79980 (diff)
android: Work around NDK ABI incompatibility around bsd_signal/signal in a different way
Get the correct symbol via dlsym() instead of letting the linker figure it out. Letting the linker do it can bring us into infinite recursion calling into our very own weak symbol. https://bugzilla.gnome.org/show_bug.cgi?id=766235
-rw-r--r--config/cross-android.cbc1
-rw-r--r--data/ndk-build/gstreamer_android-1.0.c.in30
2 files changed, 30 insertions, 1 deletions
diff --git a/config/cross-android.cbc b/config/cross-android.cbc
index 4d72bbfd..d4a8f45d 100644
--- a/config/cross-android.cbc
+++ b/config/cross-android.cbc
@@ -7,3 +7,4 @@ target_distro_version = DistroVersion.ANDROID_GINGERBREAD
target_arch = Architecture.ARM
#variants = ['nodebug']
+allow_parallel_build = True
diff --git a/data/ndk-build/gstreamer_android-1.0.c.in b/data/ndk-build/gstreamer_android-1.0.c.in
index 54ede21d..da3851ee 100644
--- a/data/ndk-build/gstreamer_android-1.0.c.in
+++ b/data/ndk-build/gstreamer_android-1.0.c.in
@@ -8,10 +8,38 @@
* symbol but only signal().
* See https://bugzilla.gnome.org/show_bug.cgi?id=766235
*/
+static gpointer
+load_real_signal (gpointer data)
+{
+ GModule *module;
+ gpointer ret = NULL;
+
+ module = g_module_open ("libc.so", G_MODULE_BIND_LOCAL);
+ g_module_symbol (module, "signal", &ret);
+
+ /* As fallback, let's try bsd_signal */
+ if (ret == NULL) {
+ g_warning ("Can't find signal(3) in libc.so!");
+ g_module_symbol (module, "bsd_signal", &ret);
+ }
+
+ g_module_close (module);
+
+ return ret;
+}
+
__sighandler_t bsd_signal(int signum, __sighandler_t handler) __attribute__((weak));
__sighandler_t bsd_signal(int signum, __sighandler_t handler)
{
- return signal(signum, handler);
+ static GOnce gonce = G_ONCE_INIT;
+ __sighandler_t (*real_signal) (int signum, __sighandler_t handler);
+
+ g_once (&gonce, load_real_signal, NULL);
+
+ real_signal = gonce.retval;
+ g_assert (real_signal != NULL);
+
+ return real_signal(signum, handler);
}
static jobject _context = NULL;