add mozglue support for gonk (bug 738559, r=glandium)

This commit is contained in:
Andreas Gal 2012-03-23 00:40:14 -07:00
Родитель 2205199057
Коммит 4cc04990b1
6 изменённых файлов: 102 добавлений и 6 удалений

Просмотреть файл

@ -72,6 +72,11 @@ tier_base_dirs += \
other-licenses/skia-npapi \
$(NULL)
endif
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
tier_base_dirs += \
other-licenses/android \
$(NULL)
endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/jemalloc

Просмотреть файл

@ -7235,13 +7235,11 @@ 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 "$MOZ_WIDGET_TOOLKIT" = android; then
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"
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"
fi
dnl ========================================================

Просмотреть файл

@ -52,6 +52,10 @@ ifeq (android,$(MOZ_WIDGET_TOOLKIT))
DIRS += android
endif
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
DIRS += gonk
endif
DIRS += build
TEST_DIRS = tests

Просмотреть файл

@ -92,6 +92,13 @@ SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-license
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)
endif
ifdef MOZ_LINKER
# Add custom dynamic linker
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,linker,../linker)

53
mozglue/gonk/GonkGlue.cpp Normal file
Просмотреть файл

@ -0,0 +1,53 @@
/* -*- 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 <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;
}

29
mozglue/gonk/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,29 @@
/* -*- Mode: C++; tab-width: 4; 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/. */
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