summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-10-18 18:14:17 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-21 23:56:18 +0200
commitd4a6abc1b18d65a2bd665cdda10cedd97a98c249 (patch)
tree1809712a95418c814a615d647f6f2b8211c912dc
parent2761751ecaf61064c3742c639a37f110120e8292 (diff)
Fix build for boot2qt eAndroid
Reverts the removal of Android support in WTF, and brings the support up to date. Merged change to MacroAssemblerARM.cpp from QtScript. Replaces use of statvfs with statfs in one place. Replaces shm-based shared memory with ashmem-based in WebKit2. Change-Id: I440b1fbd94bb4148f7ba764d77de65230d13ed90 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp14
-rw-r--r--Source/JavaScriptCore/tools/CodeProfiling.cpp8
-rw-r--r--Source/WTF/WTF.pri1
-rw-r--r--Source/WTF/wtf/Assertions.cpp12
-rw-r--r--Source/WTF/wtf/Atomics.h12
-rw-r--r--Source/WTF/wtf/MathExtras.h8
-rw-r--r--Source/WTF/wtf/Platform.h19
-rw-r--r--Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp2
-rw-r--r--Source/WebCore/platform/qt/FileSystemQt.cpp10
-rw-r--r--Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp2
-rw-r--r--Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp2
-rw-r--r--Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp40
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp2
-rw-r--r--Source/WebKit2/WebKit2.pri2
14 files changed, 112 insertions, 22 deletions
diff --git a/Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp b/Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp
index 98dc3e987..a523939b7 100644
--- a/Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp
+++ b/Source/JavaScriptCore/assembler/MacroAssemblerARM.cpp
@@ -36,7 +36,19 @@
#include <fcntl.h>
#include <unistd.h>
#include <elf.h>
-#include <asm/hwcap.h>
+#if !OS(ANDROID) && !PLATFORM(QT)
+# include <asm/hwcap.h>
+# else
+# include <asm/procinfo.h>
+typedef struct
+{
+ uint32_t a_type;
+ union
+ {
+ uint32_t a_val;
+ } a_un;
+} Elf32_auxv_t;
+# endif
#endif
namespace JSC {
diff --git a/Source/JavaScriptCore/tools/CodeProfiling.cpp b/Source/JavaScriptCore/tools/CodeProfiling.cpp
index 740595e3e..f545be903 100644
--- a/Source/JavaScriptCore/tools/CodeProfiling.cpp
+++ b/Source/JavaScriptCore/tools/CodeProfiling.cpp
@@ -48,7 +48,7 @@ WTF::MetaAllocatorTracker* CodeProfiling::s_tracker = 0;
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#endif
-#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86) && !OS(ANDROID))
// Helper function to start & stop the timer.
// Presently we're using the wall-clock timer, since this seems to give the best results.
static void setProfileTimer(unsigned usec)
@@ -73,7 +73,7 @@ static void profilingTimer(int, siginfo_t*, void* uap)
CodeProfiling::sample(reinterpret_cast<void*>(context->__ss.__rip),
reinterpret_cast<void**>(context->__ss.__rbp));
}
-#elif OS(LINUX) && CPU(X86)
+#elif OS(LINUX) && CPU(X86) && !OS(ANDROID)
static void profilingTimer(int, siginfo_t*, void* uap)
{
mcontext_t context = static_cast<ucontext_t*>(uap)->uc_mcontext;
@@ -143,7 +143,7 @@ void CodeProfiling::begin(const SourceCode& source)
if (alreadyProfiling)
return;
-#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86) && !OS(ANDROID))
// Regsiter a signal handler & itimer.
struct sigaction action;
action.sa_sigaction = reinterpret_cast<void (*)(int, siginfo_t *, void *)>(profilingTimer);
@@ -167,7 +167,7 @@ void CodeProfiling::end()
if (s_profileStack)
return;
-#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86))
+#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86) && !OS(ANDROID))
// Stop profiling
setProfileTimer(0);
#endif
diff --git a/Source/WTF/WTF.pri b/Source/WTF/WTF.pri
index 8b3ce98b5..2697d7720 100644
--- a/Source/WTF/WTF.pri
+++ b/Source/WTF/WTF.pri
@@ -16,6 +16,7 @@ mac {
} else {
contains(QT_CONFIG,icu) {
win32: LIBS += -licuin -licuuc -licudt
+ else:android: LIBS += -licui18n -licuuc
else: LIBS += -licui18n -licuuc -licudata
}
}
diff --git a/Source/WTF/wtf/Assertions.cpp b/Source/WTF/wtf/Assertions.cpp
index f462a3ffd..1b2091f53 100644
--- a/Source/WTF/wtf/Assertions.cpp
+++ b/Source/WTF/wtf/Assertions.cpp
@@ -61,12 +61,16 @@
#include <windows.h>
#endif
-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
+#if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID)
#include <cxxabi.h>
#include <dlfcn.h>
#include <execinfo.h>
#endif
+#if HAVE(ANDROID_SDK)
+#include <android/log.h>
+#endif
+
#if PLATFORM(BLACKBERRY)
#include <BlackBerryPlatformLog.h>
#endif
@@ -115,6 +119,8 @@ static void vprintf_stderr_common(const char* format, va_list args)
#elif PLATFORM(BLACKBERRY)
BBLOGV(BlackBerry::Platform::LogLevelCritical, format, args);
+#elif HAVE(ANDROID_SDK)
+ __android_log_vprint(ANDROID_LOG_WARN, "WebKit", format, args);
#elif HAVE(ISDEBUGGERPRESENT)
if (IsDebuggerPresent()) {
size_t size = 1024;
@@ -239,7 +245,7 @@ void WTFReportArgumentAssertionFailure(const char* file, int line, const char* f
void WTFGetBacktrace(void** stack, int* size)
{
-#if OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))
+#if (OS(DARWIN) || (OS(LINUX) && !defined(__UCLIBC__))) && !OS(ANDROID)
*size = backtrace(stack, *size);
#elif OS(WINDOWS) && !OS(WINCE)
// The CaptureStackBackTrace function is available in XP, but it is not defined
@@ -278,7 +284,7 @@ void WTFReportBacktrace()
# if defined(__GLIBC__) && !defined(__UCLIBC__)
# define WTF_USE_BACKTRACE_SYMBOLS 1
# endif
-# else
+# elif !OS(ANDROID)
# define WTF_USE_DLADDR 1
# endif
#endif
diff --git a/Source/WTF/wtf/Atomics.h b/Source/WTF/wtf/Atomics.h
index d7b1597a5..b21d51520 100644
--- a/Source/WTF/wtf/Atomics.h
+++ b/Source/WTF/wtf/Atomics.h
@@ -72,6 +72,8 @@ extern "C" void _ReadWriteBarrier(void);
#include <windows.h>
#elif OS(QNX)
#include <atomic.h>
+#elif OS(ANDROID)
+#include <sys/atomics.h>
#endif
namespace WTF {
@@ -103,6 +105,16 @@ inline int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDec
inline int atomicIncrement(int volatile* addend) { return static_cast<int>(atomic_add_value(reinterpret_cast<unsigned volatile*>(addend), 1)) + 1; }
inline int atomicDecrement(int volatile* addend) { return static_cast<int>(atomic_sub_value(reinterpret_cast<unsigned volatile*>(addend), 1)) - 1; }
+#elif OS(ANDROID)
+#define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1
+
+// Note, __atomic_{inc, dec}() return the previous value of addend's content.
+inline int atomicIncrement(int volatile* addend) { return __atomic_inc(addend) + 1; }
+inline int atomicDecrement(int volatile* addend) { return __atomic_dec(addend) - 1; }
+
+inline int64_t atomicIncrement(int64_t volatile* addend) { return __sync_add_and_fetch(addend, 1); }
+inline int64_t atomicDecrement(int64_t volatile* addend) { return __sync_sub_and_fetch(addend, 1); }
+
#elif COMPILER(GCC) && !CPU(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc
#define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1
diff --git a/Source/WTF/wtf/MathExtras.h b/Source/WTF/wtf/MathExtras.h
index ce72c4aed..f07bce6a3 100644
--- a/Source/WTF/wtf/MathExtras.h
+++ b/Source/WTF/wtf/MathExtras.h
@@ -151,17 +151,17 @@ inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); }
inline long long abs(long num) { return labs(num); }
#endif
-#if COMPILER(MSVC)
-// MSVC's math.h does not currently supply log2 or log2f.
+#if OS(ANDROID) || COMPILER(MSVC)
+// ANDROID and MSVC's math.h does not currently supply log2 or log2f.
inline double log2(double num)
{
- // This constant is roughly M_LN2, which is not provided by default on Windows.
+ // This constant is roughly M_LN2, which is not provided by default on Windows and Android.
return log(num) / 0.693147180559945309417232121458176568;
}
inline float log2f(float num)
{
- // This constant is roughly M_LN2, which is not provided by default on Windows.
+ // This constant is roughly M_LN2, which is not provided by default on Windows and Android.
return logf(num) / 0.693147180559945309417232121458176568f;
}
#endif
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index d61c20383..6a544fa4f 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -186,7 +186,8 @@
#elif !defined(__ARM_EABI__) \
&& !defined(__EABI__) \
&& !defined(__VFP_FP__) \
- && !defined(_WIN32_WCE)
+ && !defined(_WIN32_WCE) \
+ && !defined(ANDROID)
#define WTF_CPU_MIDDLE_ENDIAN 1
#endif
@@ -328,6 +329,15 @@
/* ==== OS() - underlying operating system; only to be used for mandated low-level services like
virtual memory, not to choose a GUI toolkit ==== */
+/* OS(ANDROID) - Android */
+#ifdef ANDROID
+#define WTF_OS_ANDROID 1
+#endif
+
+#if OS(ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+#define WTF_HAVE_ANDROID_SDK 1
+#endif
+
/* OS(AIX) - AIX */
#ifdef _AIX
#define WTF_OS_AIX 1
@@ -414,7 +424,8 @@
#define WTF_OS_MAC ERROR "USE MAC_OS_X WITH OS NOT MAC"
/* OS(UNIX) - Any Unix-like system */
-#if OS(AIX) \
+#if OS(AIX) \
+ || OS(ANDROID) \
|| OS(DARWIN) \
|| OS(FREEBSD) \
|| OS(HURD) \
@@ -579,7 +590,7 @@
#define WTF_USE_PTHREADS 1
#endif /* OS(UNIX) */
-#if OS(UNIX) && !OS(QNX)
+#if OS(UNIX) && !OS(ANDROID) && !OS(QNX)
#define HAVE_LANGINFO_H 1
#endif
@@ -599,7 +610,7 @@
#endif
#endif
-#if !OS(WINDOWS) && !OS(SOLARIS)
+#if !OS(WINDOWS) && !OS(SOLARIS) && !OS(ANDROID)
#define HAVE_TM_GMTOFF 1
#define HAVE_TM_ZONE 1
#define HAVE_TIMEGM 1
diff --git a/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp b/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp
index bd62288f8..4ad20c8bc 100644
--- a/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp
+++ b/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp
@@ -36,7 +36,7 @@
#include "Threading.h"
-#if OS(HURD)
+#if OS(ANDROID) || OS(HURD)
// PTHREAD_KEYS_MAX is not defined in bionic nor in Hurd, so explicitly define it here.
#define PTHREAD_KEYS_MAX 1024
#else
diff --git a/Source/WebCore/platform/qt/FileSystemQt.cpp b/Source/WebCore/platform/qt/FileSystemQt.cpp
index 16f4d7420..b5d0096e7 100644
--- a/Source/WebCore/platform/qt/FileSystemQt.cpp
+++ b/Source/WebCore/platform/qt/FileSystemQt.cpp
@@ -42,7 +42,9 @@
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
-#if !defined(Q_OS_WIN)
+#if OS(ANDROID)
+#include <sys/vfs.h>
+#elif !defined(Q_OS_WIN)
#include <sys/statvfs.h>
#endif
@@ -215,9 +217,15 @@ uint64_t getVolumeFreeSizeForPath(const char* path)
return 0;
return static_cast<uint64_t>(freeBytesToCaller.QuadPart);
#else
+#if OS(ANDROID)
+ struct statfs volumeInfo;
+ if (statfs(path, &volumeInfo))
+ return 0;
+#else
struct statvfs volumeInfo;
if (statvfs(path, &volumeInfo))
return 0;
+#endif
return static_cast<uint64_t>(volumeInfo.f_bavail) * static_cast<uint64_t>(volumeInfo.f_frsize);
#endif
diff --git a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
index 15a3daf39..4f7685c98 100644
--- a/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
@@ -282,7 +282,7 @@ int InspectorServerRequestHandlerQt::webSocketSend(const char* data, size_t leng
m_tcpConnection->putChar(0x81);
if (length <= 125)
m_tcpConnection->putChar(static_cast<uint8_t>(length));
- else if (length <= pow(2, 16)) {
+ else if (length <= (1<<16)) {
m_tcpConnection->putChar(126);
quint16 length16 = qToBigEndian<quint16>(static_cast<quint16>(length));
m_tcpConnection->write(reinterpret_cast<char*>(&length16), 2);
diff --git a/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp b/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp
index d049fe3b7..a8487f2c4 100644
--- a/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp
@@ -169,7 +169,7 @@ void PlatformStrategiesQt::getPluginInfo(const WebCore::Page* page, Vector<WebCo
PluginDatabase* db = PluginDatabase::installedPlugins();
const Vector<PluginPackage*> &plugins = db->plugins();
- for (int i = 0; i < plugins.size(); ++i) {
+ for (size_t i = 0; i < plugins.size(); ++i) {
PluginInfo info;
PluginPackage* package = plugins[i];
diff --git a/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp
index 760a8ab1c..6a4d52792 100644
--- a/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp
+++ b/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp
@@ -44,6 +44,10 @@
#include <wtf/UniStdExtras.h>
#include <wtf/text/CString.h>
+#if OS(ANDROID)
+#include <linux/ashmem.h>
+#endif
+
namespace WebKit {
SharedMemory::Handle::Handle()
@@ -97,6 +101,41 @@ void SharedMemory::Handle::adoptFromAttachment(int fileDescriptor, size_t size)
m_size = size;
}
+#if OS(ANDROID)
+PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
+{
+ int fileDescriptor = open("/dev/ashmem", O_RDWR);
+ if (fileDescriptor < 0) {
+ WTFLogAlways("Failed to open ashmem device");
+ return 0;
+ }
+
+ String name = String("/WK2SharedMemory.") + String::number(static_cast<unsigned>(WTF::randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)));
+ char buf[ASHMEM_NAME_LEN];
+ strlcpy(buf,name.utf8().data(), sizeof(buf));
+ // Ashmem names does not need to be unique.
+ ioctl(fileDescriptor, ASHMEM_SET_NAME, buf);
+
+ int ret = ioctl(fileDescriptor, ASHMEM_SET_SIZE, size);
+ if (ret < 0) {
+ closeWithRetry(fileDescriptor);
+ WTFLogAlways("Failed to create shared memory of size %d", size);
+ return 0;
+ }
+
+ void* data = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0);
+ if (data == MAP_FAILED) {
+ closeWithRetry(fileDescriptor);
+ return 0;
+ }
+
+ RefPtr<SharedMemory> instance = adoptRef(new SharedMemory());
+ instance->m_data = data;
+ instance->m_fileDescriptor = fileDescriptor;
+ instance->m_size = size;
+ return instance.release();
+}
+#else
PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
{
CString tempName;
@@ -138,6 +177,7 @@ PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
instance->m_size = size;
return instance.release();
}
+#endif
static inline int accessModeMMap(SharedMemory::Protection protection)
{
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
index 128379f26..01ea5e6bd 100644
--- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -250,7 +250,7 @@ void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems)
{
QString currentGroup;
m_items.reserveInitialCapacity(webPopupItems.size());
- for (int i = 0; i < webPopupItems.size(); i++) {
+ for (size_t i = 0; i < webPopupItems.size(); i++) {
const WebPopupItem& webPopupItem = webPopupItems[i];
if (webPopupItem.m_isLabel) {
currentGroup = webPopupItem.m_text;
diff --git a/Source/WebKit2/WebKit2.pri b/Source/WebKit2/WebKit2.pri
index cf154cc19..e8d4b80d0 100644
--- a/Source/WebKit2/WebKit2.pri
+++ b/Source/WebKit2/WebKit2.pri
@@ -75,7 +75,7 @@ INCLUDEPATH += $${ROOT_WEBKIT_DIR}/Source/WTF/wtf/qt
INCLUDEPATH += $$WEBKIT2_GENERATED_SOURCES_DIR
-linux-*: {
+linux-*:!android {
# -lrt is required for shm_open and shm_unlink.
LIBS += -lrt
}