Bug 588607 - 3. Add support for the custom library loader to plugin-container, r=cjones a=blocking-fennec
authorMichael Wu <mwu@mozilla.com>
Fri, 15 Oct 2010 11:28:07 -0700
changeset 55918 884b917c7628
parent 55917 a6b6ebdd29a2
child 55919 e3cdf1619342
push id16337
push usermwu@mozilla.com
push dateFri, 15 Oct 2010 23:41:19 +0000
treeherdermozilla-central@ab6d8c5a300a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones, blocking-fennec
bugs588607
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 588607 - 3. Add support for the custom library loader to plugin-container, r=cjones a=blocking-fennec
ipc/app/Makefile.in
ipc/app/MozillaRuntimeMainAndroid.cpp
--- a/ipc/app/Makefile.in
+++ b/ipc/app/Makefile.in
@@ -46,20 +46,26 @@ MODULE = ipc
 
 include $(topsrcdir)/ipc/app/defs.mk
 PROGRAM = $(MOZ_CHILD_PROCESS_NAME)
 
 CPPSRCS = \
   MozillaRuntimeMain.cpp \
   $(NULL)
 
+ifeq (Android,$(OS_TARGET))
+WRAP_MALLOC_CFLAGS =
+WRAP_MALLOC_LIB =
+CPPSRCS = MozillaRuntimeMainAndroid.cpp
+else
 LIBS += \
   $(XPCOM_LIBS) \
   $(NSPR_LIBS) \
   $(NULL)
+endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
@@ -87,17 +93,19 @@ ifdef WINCE
 EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME,corelibc)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 msimg32)
 endif
 
+ifneq (Android,$(OS_TARGET))
 LIBS += $(JEMALLOC_LIBS)
+endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
 #
 # Control the default heap size.
 # This is the heap returned by GetProcessHeap().
 # As we use the CRT heap, the default size is too large and wastes VM.
new file mode 100644
--- /dev/null
+++ b/ipc/app/MozillaRuntimeMainAndroid.cpp
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: sw=4 ts=4 et :
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Plugin App.
+ *
+ * The Initial Developer of the Original Code is
+ *   Ben Turner <bent.mozilla@gmail.com>.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Chris Jones <jones.chris.g@gmail.com>.
+ *   Michael Wu <mwu@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <dlfcn.h>
+#include <android/log.h>
+
+int
+main(int argc, char* argv[])
+{
+    // Check for the absolute minimum number of args we need to move
+    // forward here. We expect the last arg to be the child process type.
+    if (argc < 2)
+        return 1;
+
+    void *mozloader_handle = dlopen("libmozutils.so", RTLD_LAZY);
+    if (!mozloader_handle) {
+      __android_log_print(ANDROID_LOG_ERROR, "GeckoChildLoad",
+                          "Couldn't load mozloader because %s", dlerror());
+        return 1;
+    }
+
+    typedef int (*ChildProcessInit_t)(int, char**);
+    ChildProcessInit_t fChildProcessInit =
+        (ChildProcessInit_t)dlsym(mozloader_handle, "ChildProcessInit");
+    if (!fChildProcessInit) {
+        __android_log_print(ANDROID_LOG_ERROR, "GeckoChildLoad",
+                            "Couldn't load cpi_t because %s", dlerror());
+        return 1;
+    }
+
+    return fChildProcessInit(argc, argv);
+}