Bug 738561 - Cleanup mozglue for gonk, r=glandium
authorMichael Wu <mwu@mozilla.com>
Thu, 29 Mar 2012 18:32:44 -0700
changeset 91374 4c40a352e2a45a36f8f6331c2bc47fd5d0d3dbab
parent 91373 7936634f5fe3832ed7a52ec2d7055ba1b85d55f7
child 91375 8e82bc639a0a3f1156bc352675f963db12b11d30
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs738561
milestone14.0a1
Bug 738561 - Cleanup mozglue for gonk, r=glandium
mozglue/Makefile.in
mozglue/android/APKOpen.cpp
mozglue/build/BionicGlue.cpp
mozglue/build/Makefile.in
mozglue/gonk/GonkGlue.cpp
mozglue/gonk/Makefile.in
--- a/mozglue/Makefile.in
+++ b/mozglue/Makefile.in
@@ -47,17 +47,13 @@ DIRS =
 ifdef MOZ_LINKER
 DIRS += linker
 endif
 
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 DIRS += android
 endif
 
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-DIRS += gonk
-endif
-
 DIRS += build
 
 TEST_DIRS = tests
 
 include $(topsrcdir)/config/rules.mk
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -44,17 +44,16 @@
 #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>
@@ -1035,58 +1034,8 @@ ChildProcessInit(int argc, char* argv[])
   XRE_InitChildProcess_t fXRE_InitChildProcess =
     (XRE_InitChildProcess_t)__wrap_dlsym(xul_handle, "XRE_InitChildProcess");
 
   GeckoProcessType proctype = fXRE_StringToChildProcessType(argv[--argc]);
 
   return fXRE_InitChildProcess(argc, argv, proctype);
 }
 
-/* Android doesn't have pthread_atfork(), so we need to use our own. */
-struct AtForkFuncs {
-  void (*prepare)(void);
-  void (*parent)(void);
-  void (*child)(void);
-};
-static std::vector<AtForkFuncs> atfork;
-
-extern "C" NS_EXPORT int
-__wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
-{
-  AtForkFuncs funcs;
-  funcs.prepare = prepare;
-  funcs.parent = parent;
-  funcs.child = child;
-  atfork.push_back(funcs);
-  return 0;
-}
-
-extern "C" NS_EXPORT pid_t
-__wrap_fork(void)
-{
-  pid_t pid;
-  for (std::vector<AtForkFuncs>::reverse_iterator it = atfork.rbegin();
-       it < atfork.rend(); ++it)
-    if (it->prepare)
-      it->prepare();
-
-  switch ((pid = fork())) {
-  case 0:
-    for (std::vector<AtForkFuncs>::iterator it = atfork.begin();
-         it < atfork.end(); ++it)
-      if (it->child)
-        it->child();
-    break;
-  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);
-}
-
new file mode 100644
--- /dev/null
+++ b/mozglue/build/BionicGlue.cpp
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 2; 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);
+  void (*child)(void);
+};
+static std::vector<AtForkFuncs> atfork;
+
+extern "C" NS_EXPORT int
+__wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
+{
+  AtForkFuncs funcs;
+  funcs.prepare = prepare;
+  funcs.parent = parent;
+  funcs.child = child;
+  atfork.push_back(funcs);
+  return 0;
+}
+
+extern "C" NS_EXPORT pid_t
+__wrap_fork(void)
+{
+  pid_t pid;
+  for (std::vector<AtForkFuncs>::reverse_iterator it = atfork.rbegin();
+       it < atfork.rend(); ++it)
+    if (it->prepare)
+      it->prepare();
+
+  switch ((pid = fork())) {
+  case 0:
+    for (std::vector<AtForkFuncs>::iterator it = atfork.begin();
+         it < atfork.end(); ++it)
+      if (it->child)
+        it->child();
+    break;
+  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/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -77,32 +77,29 @@ GARBAGE += mozglue.def
 LDFLAGS += -ENTRY:DllMain
 
 ifneq (,$(filter -DEFAULTLIB:mozcrt,$(MOZ_GLUE_LDFLAGS)))
 # Don't install the import library if we use mozcrt
 NO_INSTALL_IMPORT_LIBRARY = 1
 endif
 endif
 
-ifeq (android, $(MOZ_WIDGET_TOOLKIT))
-# Add Android specific code
-EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
+ifeq (Android,$(OS_TARGET))
 ifdef MOZ_MEMORY
 # To properly wrap jemalloc's pthread_atfork call.
 EXTRA_DSO_LDOPTS += -Wl,--wrap=pthread_atfork
+CPPSRCS += BionicGlue.cpp
 endif
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
-SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,../android)
 endif
 
-ifeq (gonk, $(MOZ_WIDGET_TOOLKIT))
-# To properly wrap jemalloc's pthread_atfork call.
-EXTRA_DSO_LDOPTS += -Wl,--wrap=pthread_atfork
-SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
-SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,gonk,../gonk)
+ifeq (android, $(MOZ_WIDGET_TOOLKIT))
+# Add Android specific code
+EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
+SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,../android)
 endif
 
 ifdef MOZ_LINKER
 # Add custom dynamic linker
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker)
 
 ifeq (arm, $(TARGET_CPU))
 EXTRA_DSO_LDOPTS += -Wl,-version-script,$(srcdir)/arm-eabi-filter
deleted file mode 100644
--- a/mozglue/gonk/GonkGlue.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- 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);
-  void (*child)(void);
-};
-static std::vector<AtForkFuncs> atfork;
-
-extern "C" NS_EXPORT int
-__wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
-{
-  AtForkFuncs funcs;
-  funcs.prepare = prepare;
-  funcs.parent = parent;
-  funcs.child = child;
-  atfork.push_back(funcs);
-  return 0;
-}
-
-extern "C" NS_EXPORT pid_t
-__wrap_fork(void)
-{
-  pid_t pid;
-  for (std::vector<AtForkFuncs>::reverse_iterator it = atfork.rbegin();
-       it < atfork.rend(); ++it)
-    if (it->prepare)
-      it->prepare();
-
-  switch ((pid = fork())) {
-  case 0:
-    for (std::vector<AtForkFuncs>::iterator it = atfork.begin();
-         it < atfork.end(); ++it)
-      if (it->child)
-        it->child();
-    break;
-  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);
-}
-
deleted file mode 100644
--- a/mozglue/gonk/Makefile.in
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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/.
-
-DEPTH		= ../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE           = gonk
-LIBRARY_NAME     = gonk
-FORCE_STATIC_LIB = 1
-STL_FLAGS=
-
-DEFINES += \
-  -DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"' \
-  $(NULL)
-
-CPPSRCS = \
-  GonkGlue.cpp \
-  $(NULL)
-
-LOCAL_INCLUDES += -I$(DEPTH)/build
-LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
-
-include $(topsrcdir)/config/rules.mk