<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[172532] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/172532">172532</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-13 12:43:25 -0700 (Wed, 13 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Make JavaScriptCore and bmalloc build with the public SDK
https://bugs.webkit.org/show_bug.cgi?id=135848

Reviewed by Geoffrey Garen.

Source/bmalloc:

* bmalloc/BPlatform.h: Added macro BPLATFORM_IOS_SIMULATOR, which evaluates to true
when building for the iOS Simulator.
* bmalloc/PerThread.h: Use pthread_machdep.h code path when building for iOS Simulator
using the public SDK.
(_pthread_setspecific_direct): Added; only defined when building for the iOS Simulator
using the public SDK.
(_pthread_getspecific_direct): Added; only defined when building for the iOS Simulator
using the public SDK.

Source/JavaScriptCore:

* API/JSBase.h: Declare NSMap functions with external linkage when building for iOS without the
header &lt;Foundation/NSMapTablePriv.h&gt;.
* inspector/remote/RemoteInspector.mm: Define XPC functions with external linkage when building
without the system header &lt;xpc/xpc.h&gt;.
* inspector/remote/RemoteInspectorXPCConnection.h: Define xpc_connection_t and xpc_object_t when building
without the system header &lt;xpc/xpc.h&gt;.
* inspector/remote/RemoteInspectorXPCConnection.mm: Declare XPC functions with external linkage when
building without without the system header &lt;xpc/xpc.h&gt;.
(Inspector::RemoteInspectorXPCConnection::closeOnQueue): Fix code style; use nullptr instead of NULL.
(Inspector::RemoteInspectorXPCConnection::sendMessage): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSBaseh">trunk/Source/JavaScriptCore/API/JSBase.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectormm">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorXPCConnectionh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorXPCConnectionmm">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm</a></li>
<li><a href="#trunkSourcebmallocChangeLog">trunk/Source/bmalloc/ChangeLog</a></li>
<li><a href="#trunkSourcebmallocbmallocBPlatformh">trunk/Source/bmalloc/bmalloc/BPlatform.h</a></li>
<li><a href="#trunkSourcebmallocbmallocPerThreadh">trunk/Source/bmalloc/bmalloc/PerThread.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPIJSBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSBase.h (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSBase.h        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/JavaScriptCore/API/JSBase.h        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -32,7 +32,19 @@
</span><span class="cx"> 
</span><span class="cx"> #ifdef __OBJC__
</span><span class="cx"> #import &lt;Foundation/Foundation.h&gt;
</span><ins>+
+#if defined(TARGET_OS_IPHONE) &amp;&amp; TARGET_OS_IPHONE
+#if __has_include(&lt;Foundation/NSMapTablePriv.h&gt;)
+#import &lt;Foundation/NSMapTablePriv.h&gt;
+#else
+extern &quot;C&quot; {
+    void *NSMapGet(NSMapTable *, const void *key);
+    void NSMapInsert(NSMapTable *, const void *key, const void *value);
+    void NSMapRemove(NSMapTable *, const void *key);
+}
</ins><span class="cx"> #endif
</span><ins>+#endif // defined(TARGET_OS_IPHONE) &amp;&amp; TARGET_OS_IPHONE
+#endif // __OBJC__
</ins><span class="cx"> 
</span><span class="cx"> /* JavaScript engine interface */
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-08-13  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        [iOS] Make JavaScriptCore and bmalloc build with the public SDK
+        https://bugs.webkit.org/show_bug.cgi?id=135848
+
+        Reviewed by Geoffrey Garen.
+
+        * API/JSBase.h: Declare NSMap functions with external linkage when building for iOS without the
+        header &lt;Foundation/NSMapTablePriv.h&gt;.
+        * inspector/remote/RemoteInspector.mm: Define XPC functions with external linkage when building
+        without the system header &lt;xpc/xpc.h&gt;.
+        * inspector/remote/RemoteInspectorXPCConnection.h: Define xpc_connection_t and xpc_object_t when building
+        without the system header &lt;xpc/xpc.h&gt;.
+        * inspector/remote/RemoteInspectorXPCConnection.mm: Declare XPC functions with external linkage when
+        building without without the system header &lt;xpc/xpc.h&gt;.
+        (Inspector::RemoteInspectorXPCConnection::closeOnQueue): Fix code style; use nullptr instead of NULL.
+        (Inspector::RemoteInspectorXPCConnection::sendMessage): Ditto.
+
</ins><span class="cx"> 2014-08-12  Peyton Randolph  &lt;prandolph@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Runtime switch for long mouse press gesture. Part of 135257 - Add long mouse press gesture.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -37,7 +37,15 @@
</span><span class="cx"> #import &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #import &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #import &lt;wtf/text/WTFString.h&gt;
</span><ins>+
+#if __has_include(&lt;xpc/xpc.h&gt;)
</ins><span class="cx"> #import &lt;xpc/xpc.h&gt;
</span><ins>+#else
+extern &quot;C&quot; {
+    xpc_connection_t xpc_connection_create_mach_service(const char* name, dispatch_queue_t, uint64_t flags);
+    void xpc_release(xpc_object_t);
+}
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &lt;wtf/ios/WebCoreThread.h&gt;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorXPCConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -31,7 +31,13 @@
</span><span class="cx"> #import &lt;dispatch/dispatch.h&gt;
</span><span class="cx"> #import &lt;mutex&gt;
</span><span class="cx"> #import &lt;wtf/ThreadSafeRefCounted.h&gt;
</span><ins>+
+#if __has_include(&lt;xpc/xpc.h&gt;)
</ins><span class="cx"> #import &lt;xpc/xpc.h&gt;
</span><ins>+#else
+typedef void* xpc_connection_t;
+typedef void* xpc_object_t;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> OBJC_CLASS NSDictionary;
</span><span class="cx"> OBJC_CLASS NSString;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorXPCConnectionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -32,11 +32,38 @@
</span><span class="cx"> #import &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #import &lt;wtf/Ref.h&gt;
</span><span class="cx"> 
</span><ins>+#if !__has_include(&lt;xpc/xpc.h&gt;)
+extern &quot;C&quot; {
+    typedef void (^xpc_handler_t)(xpc_object_t);
+    void xpc_connection_cancel(xpc_connection_t);
+    void xpc_connection_resume(xpc_connection_t);
+    void xpc_connection_send_message(xpc_connection_t, xpc_object_t message);
+    void xpc_connection_set_event_handler(xpc_connection_t, xpc_handler_t);
+    void xpc_connection_set_target_queue(xpc_connection_t, dispatch_queue_t);
+
+    xpc_object_t xpc_retain(xpc_object_t);
+    void xpc_release(xpc_object_t);
+
+    typedef void* xpc_type_t;
+    xpc_type_t xpc_get_type(xpc_object_t);
+
+    void* XPC_ERROR_CONNECTION_INVALID;
+    void* XPC_TYPE_DICTIONARY;
+    void* XPC_TYPE_ERROR;
+
+    xpc_object_t xpc_dictionary_create(const char* const* keys, const xpc_object_t* values, size_t count);
+    xpc_object_t xpc_dictionary_get_value(xpc_object_t, const char* key);
+    void xpc_dictionary_set_value(xpc_object_t, const char* key, xpc_object_t value);
+}
+#endif
+
</ins><span class="cx"> #if __has_include(&lt;CoreFoundation/CFXPCBridge.h&gt;)
</span><span class="cx"> #import &lt;CoreFoundation/CFXPCBridge.h&gt;
</span><span class="cx"> #else
</span><del>-extern &quot;C&quot; xpc_object_t _CFXPCCreateXPCMessageWithCFObject(CFTypeRef);
-extern &quot;C&quot; CFTypeRef _CFXPCCreateCFObjectFromXPCMessage(xpc_object_t);
</del><ins>+extern &quot;C&quot; {
+    xpc_object_t _CFXPCCreateXPCMessageWithCFObject(CFTypeRef);
+    CFTypeRef _CFXPCCreateCFObjectFromXPCMessage(xpc_object_t);
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace Inspector {
</span><span class="lines">@@ -96,12 +123,12 @@
</span><span class="cx">     if (m_connection) {
</span><span class="cx">         xpc_connection_cancel(m_connection);
</span><span class="cx">         xpc_release(m_connection);
</span><del>-        m_connection = NULL;
</del><ins>+        m_connection = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_queue) {
</span><span class="cx">         dispatch_release(m_queue);
</span><del>-        m_queue = NULL;
</del><ins>+        m_queue = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -170,7 +197,7 @@
</span><span class="cx">     if (!xpcDictionary)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    xpc_object_t msg = xpc_dictionary_create(NULL, NULL, 0);
</del><ins>+    xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
</ins><span class="cx">     xpc_dictionary_set_value(msg, RemoteInspectorXPCConnectionSerializedMessageKey, xpcDictionary);
</span><span class="cx">     xpc_release(xpcDictionary);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/ChangeLog (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/ChangeLog        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/bmalloc/ChangeLog        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-08-13  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        [iOS] Make JavaScriptCore and bmalloc build with the public SDK
+        https://bugs.webkit.org/show_bug.cgi?id=135848
+
+        Reviewed by Geoffrey Garen.
+
+        * bmalloc/BPlatform.h: Added macro BPLATFORM_IOS_SIMULATOR, which evaluates to true
+        when building for the iOS Simulator.
+        * bmalloc/PerThread.h: Use pthread_machdep.h code path when building for iOS Simulator
+        using the public SDK.
+        (_pthread_setspecific_direct): Added; only defined when building for the iOS Simulator
+        using the public SDK.
+        (_pthread_getspecific_direct): Added; only defined when building for the iOS Simulator
+        using the public SDK.
+
</ins><span class="cx"> 2014-08-12  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         BPLATFORM(IOS) always evaluates to false
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocBPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/BPlatform.h (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/BPlatform.h        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/bmalloc/bmalloc/BPlatform.h        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -38,4 +38,8 @@
</span><span class="cx"> #define BPLATFORM_IOS 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if defined(TARGET_IPHONE_SIMULATOR) &amp;&amp; TARGET_IPHONE_SIMULATOR
+#define BPLATFORM_IOS_SIMULATOR 1
+#endif
+
</ins><span class="cx"> #endif // BPlatform_h
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocPerThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/PerThread.h (172531 => 172532)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/PerThread.h        2014-08-13 19:25:28 UTC (rev 172531)
+++ trunk/Source/bmalloc/bmalloc/PerThread.h        2014-08-13 19:43:25 UTC (rev 172532)
</span><span class="lines">@@ -26,11 +26,21 @@
</span><span class="cx"> #ifndef PerThread_h
</span><span class="cx"> #define PerThread_h
</span><span class="cx"> 
</span><ins>+#include &quot;BPlatform.h&quot;
</ins><span class="cx"> #include &quot;Inline.h&quot;
</span><span class="cx"> #include &lt;mutex&gt;
</span><span class="cx"> #include &lt;pthread.h&gt;
</span><span class="cx"> #if defined(__has_include) &amp;&amp; __has_include(&lt;System/pthread_machdep.h&gt;)
</span><span class="cx"> #include &lt;System/pthread_machdep.h&gt;
</span><ins>+#elif BPLATFORM(IOS_SIMULATOR)
+// FIXME: We shouldn't hardcode this constant as it can become out-of-date with the macro define of the same
+// name in System/pthread_machdep.h. Instead, we should make PerThread work without C++ thread local storage.
+// See &lt;https://bugs.webkit.org/show_bug.cgi?id=135895&gt; for more details.
+const pthread_key_t __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0 = 90;
+
+INLINE int _pthread_setspecific_direct(pthread_key_t key, const void* value) { return pthread_setspecific(key, value); }
+INLINE void* _pthread_getspecific_direct(pthread_key_t key) { return pthread_getspecific(key); }
+extern &quot;C&quot; int pthread_key_init_np(int, void (*destructor)(void*));
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace bmalloc {
</span><span class="lines">@@ -53,8 +63,7 @@
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T&gt; struct PerThreadStorage;
</span><span class="cx"> 
</span><del>-#if defined(__has_include) &amp;&amp; __has_include(&lt;System/pthread_machdep.h&gt;)
-
</del><ins>+#if (defined(__has_include) &amp;&amp; __has_include(&lt;System/pthread_machdep.h&gt;)) || BPLATFORM(IOS_SIMULATOR)
</ins><span class="cx"> // For now, we only support PerThread&lt;Cache&gt;. We can expand to other types by
</span><span class="cx"> // using more keys.
</span><span class="cx"> 
</span><span class="lines">@@ -90,7 +99,7 @@
</span><span class="cx"> template&lt;typename T&gt; pthread_key_t PerThreadStorage&lt;T&gt;::key;
</span><span class="cx"> template&lt;typename T&gt; std::once_flag PerThreadStorage&lt;T&gt;::onceFlag;
</span><span class="cx"> 
</span><del>-#endif // defined(__has_include) &amp;&amp; __has_include(&lt;System/pthread_machdep.h&gt;)
</del><ins>+#endif // (defined(__has_include) &amp;&amp; __has_include(&lt;System/pthread_machdep.h&gt;)) || BPLATFORM(IOS_SIMULATOR)
</ins><span class="cx"> 
</span><span class="cx"> template&lt;typename T&gt;
</span><span class="cx"> INLINE T* PerThread&lt;T&gt;::getFastCase()
</span></span></pre>
</div>
</div>

</body>
</html>