Title: [101041] trunk/Source/_javascript_Core
Revision
101041
Author
dba...@webkit.org
Date
2011-11-22 19:30:34 -0800 (Tue, 22 Nov 2011)

Log Message

Add WTF infrastructure for the BlackBerry port
https://bugs.webkit.org/show_bug.cgi?id=72970

Reviewed by Antonio Gomes.

* wtf/Assertions.cpp: Added BlackBerry-specific logging directive.
* wtf/MathExtras.h:
(abs): Added; stdlib doesn't contain abs() on QNX.
* wtf/Platform.h: Define WTF_PLATFORM_BLACKBERRY and enable some platform features.
* wtf/RandomNumberSeed.h:
(WTF::initializeRandomNumberGenerator): For the BlackBerry port, we initialize
the bad pseudo random number generator using time(3) before initializing the
Mersenne Twister random number generator.
* wtf/ThreadingPthreads.cpp:
(WTF::createThreadInternal): Added.
* wtf/blackberry: Added.
* wtf/blackberry/MainThreadBlackBerry.cpp: Added.
(WTF::initializeMainThreadPlatform):
(WTF::scheduleDispatchFunctionsOnMainThread):
* wtf/text/WTFString.h: Added constructor and conversion operator for
BlackBerry WebString string object.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (101040 => 101041)


--- trunk/Source/_javascript_Core/ChangeLog	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-11-23 03:30:34 UTC (rev 101041)
@@ -1,3 +1,27 @@
+2011-11-22  Daniel Bates  <dba...@rim.com>
+
+        Add WTF infrastructure for the BlackBerry port
+        https://bugs.webkit.org/show_bug.cgi?id=72970
+
+        Reviewed by Antonio Gomes.
+
+        * wtf/Assertions.cpp: Added BlackBerry-specific logging directive.
+        * wtf/MathExtras.h:
+        (abs): Added; stdlib doesn't contain abs() on QNX.
+        * wtf/Platform.h: Define WTF_PLATFORM_BLACKBERRY and enable some platform features.
+        * wtf/RandomNumberSeed.h:
+        (WTF::initializeRandomNumberGenerator): For the BlackBerry port, we initialize
+        the bad pseudo random number generator using time(3) before initializing the
+        Mersenne Twister random number generator.
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::createThreadInternal): Added.
+        * wtf/blackberry: Added.
+        * wtf/blackberry/MainThreadBlackBerry.cpp: Added.
+        (WTF::initializeMainThreadPlatform):
+        (WTF::scheduleDispatchFunctionsOnMainThread):
+        * wtf/text/WTFString.h: Added constructor and conversion operator for
+        BlackBerry WebString string object.
+
 2011-11-22  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r100988.

Modified: trunk/Source/_javascript_Core/wtf/Assertions.cpp (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/Assertions.cpp	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/Assertions.cpp	2011-11-23 03:30:34 UTC (rev 101041)
@@ -55,6 +55,10 @@
 #include <execinfo.h>
 #endif
 
+#if PLATFORM(BLACKBERRY)
+#include <BlackBerryPlatformMisc.h>
+#endif
+
 extern "C" {
 
 WTF_ATTRIBUTE_PRINTF(1, 0)
@@ -77,7 +81,8 @@
         CFRelease(cfFormat);
         return;
     }
-
+#elif PLATFORM(BLACKBERRY)
+    BlackBerry::Platform::logV(BlackBerry::Platform::LogLevelInfo, format, args);
 #elif HAVE(ISDEBUGGERPRESENT)
     if (IsDebuggerPresent()) {
         size_t size = 1024;

Modified: trunk/Source/_javascript_Core/wtf/MathExtras.h (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/MathExtras.h	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/MathExtras.h	2011-11-23 03:30:34 UTC (rev 101041)
@@ -50,6 +50,13 @@
 #include <limits>
 #endif
 
+#if OS(QNX)
+// FIXME: Look into a way to have cmath import its functions into both the standard and global
+// namespace. For now, we include math.h since the QNX cmath header only imports its functions
+// into the standard namespace.
+#include <math.h>
+#endif
+
 #ifndef M_PI
 const double piDouble = 3.14159265358979323846;
 const float piFloat = 3.14159265358979323846f;
@@ -133,6 +140,11 @@
 
 #endif
 
+#if COMPILER(GCC) && OS(QNX)
+// The stdlib on QNX doesn't contain long abs(long). See PR #104666.
+inline long long abs(long num) { return labs(num); }
+#endif
+
 #if COMPILER(MSVC)
 // The 64bit version of abs() is already defined in stdlib.h which comes with VC10
 #if COMPILER(MSVC9_OR_LOWER)

Modified: trunk/Source/_javascript_Core/wtf/Platform.h (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/Platform.h	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/Platform.h	2011-11-23 03:30:34 UTC (rev 101041)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2007-2009 Torch Mobile, Inc.
- * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -409,6 +409,7 @@
 /* PLATFORM(QT) */
 /* PLATFORM(WX) */
 /* PLATFORM(GTK) */
+/* PLATFORM(BLACKBERRY) */
 /* PLATFORM(MAC) */
 /* PLATFORM(WIN) */
 #if defined(BUILDING_CHROMIUM__)
@@ -419,6 +420,8 @@
 #define WTF_PLATFORM_WX 1
 #elif defined(BUILDING_GTK__)
 #define WTF_PLATFORM_GTK 1
+#elif defined(BUILDING_BLACKBERRY__)
+#define WTF_PLATFORM_BLACKBERRY 1
 #elif OS(DARWIN)
 #define WTF_PLATFORM_MAC 1
 #elif OS(WINDOWS)
@@ -470,6 +473,13 @@
 #endif
 #endif
 
+#if PLATFORM(BLACKBERRY)
+#define ENABLE_DRAG_SUPPORT 0
+#define USE_SYSTEM_MALLOC 1
+#define WTF_USE_MERSENNE_TWISTER_19937 1
+#define WTF_USE_SKIA 1
+#endif
+
 #if PLATFORM(GTK)
 #define WTF_USE_CAIRO 1
 #endif

Modified: trunk/Source/_javascript_Core/wtf/RandomNumberSeed.h (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/RandomNumberSeed.h	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/RandomNumberSeed.h	2011-11-23 03:30:34 UTC (rev 101041)
@@ -56,7 +56,7 @@
     srand(GetTickCount());
 #elif COMPILER(MSVC) && defined(_CRT_RAND_S)
     // On Windows we use rand_s which initialises itself
-#elif OS(UNIX)
+#elif OS(UNIX) && !PLATFORM(BLACKBERRY)
     // srandomdev is not guaranteed to exist on linux so we use this poor seed, this should be improved
     timeval time;
     gettimeofday(&time, 0);

Modified: trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/ThreadingPthreads.cpp	2011-11-23 03:30:34 UTC (rev 101041)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Justin Haygood (jhayg...@reaktix.com)
+ * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,6 +56,11 @@
 #include <objc/objc-auto.h>
 #endif
 
+#if PLATFORM(BLACKBERRY)
+#include <BlackBerryPlatformMisc.h>
+#include <BlackBerryPlatformSettings.h>
+#endif
+
 namespace WTF {
 
 typedef HashMap<ThreadIdentifier, pthread_t> ThreadMap;
@@ -146,6 +152,40 @@
     threadMap().remove(id);
 }
 
+#if PLATFORM(BLACKBERRY)
+ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char* threadName)
+{
+    pthread_attr_t attr;
+    if (pthread_attr_init(&attr)) {
+        LOG_ERROR("pthread_attr_init() failed: %d", errno);
+        return 0;
+    }
+
+    void* stackAddr;
+    size_t stackSize;
+    if (pthread_attr_getstack(&attr, &stackAddr, &stackSize))
+        LOG_ERROR("pthread_attr_getstack() failed: %d", errno);
+    else {
+        stackSize = BlackBerry::Platform::Settings::get()->secondaryThreadStackSize();
+        if (pthread_attr_setstack(&attr, stackAddr, stackSize))
+            LOG_ERROR("pthread_attr_getstack() failed: %d", errno);
+    }
+
+    pthread_t threadHandle;
+    if (pthread_create(&threadHandle, &attr, entryPoint, data)) {
+        LOG_ERROR("pthread_create() failed: %d", errno);
+        threadHandle = 0;
+    }
+    pthread_setname_np(threadHandle, threadName);
+
+    pthread_attr_destroy(&attr);
+
+    if (!threadHandle)
+        return 0;
+
+    return establishIdentifierForPthreadHandle(threadHandle);
+}
+#else
 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)
 {
     pthread_t threadHandle;
@@ -156,6 +196,7 @@
 
     return establishIdentifierForPthreadHandle(threadHandle);
 }
+#endif
 
 void initializeCurrentThreadInternal(const char* threadName)
 {

Added: trunk/Source/_javascript_Core/wtf/blackberry/MainThreadBlackBerry.cpp (0 => 101041)


--- trunk/Source/_javascript_Core/wtf/blackberry/MainThreadBlackBerry.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/wtf/blackberry/MainThreadBlackBerry.cpp	2011-11-23 03:30:34 UTC (rev 101041)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "MainThread.h"
+
+#include <BlackBerryPlatformClient.h>
+
+namespace WTF {
+
+void initializeMainThreadPlatform()
+{
+}
+
+void scheduleDispatchFunctionsOnMainThread()
+{
+    BlackBerry::Platform::Client::get()->scheduleCallOnMainThread(dispatchFunctionsFromMainThread);
+}
+
+} // namespace WTF

Modified: trunk/Source/_javascript_Core/wtf/text/WTFString.h (101040 => 101041)


--- trunk/Source/_javascript_Core/wtf/text/WTFString.h	2011-11-23 03:16:00 UTC (rev 101040)
+++ trunk/Source/_javascript_Core/wtf/text/WTFString.h	2011-11-23 03:30:34 UTC (rev 101041)
@@ -46,6 +46,14 @@
 class wxString;
 #endif
 
+#if PLATFORM(BLACKBERRY)
+namespace BlackBerry {
+namespace WebKit {
+    class WebString;
+}
+}
+#endif
+
 namespace WTF {
 
 class CString;
@@ -334,6 +342,11 @@
     WTF_EXPORT_PRIVATE operator wxString() const;
 #endif
 
+#if PLATFORM(BLACKBERRY)
+    String(const BlackBerry::WebKit::WebString&);
+    operator BlackBerry::WebKit::WebString() const;
+#endif
+
     // String::fromUTF8 will return a null string if
     // the input data contains invalid UTF-8 sequences.
     WTF_EXPORT_PRIVATE static String fromUTF8(const LChar*, size_t);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to