Reviewed by Oliver Hunt.

WebCore fails to build with Clang on ARM
https://bugs.webkit.org/show_bug.cgi?id=56257

Add an explicit instantiation of writeLittleEndian for uint8_t and move it to
namespace scope, since explicit specializations are not allowed at class scope.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::writeLittleEndian):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@80949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.cpp b/Source/WebCore/bindings/js/SerializedScriptValue.cpp
index 6c69cc2..5659ff4 100644
--- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/Source/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -206,6 +206,46 @@
     MarkedArgumentBuffer m_gcBuffer;
 };
 
+#if ASSUME_LITTLE_ENDIAN
+template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
+{
+    buffer.append(reinterpret_cast<uint8_t*>(&value), sizeof(value));
+}
+#else
+template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
+{
+    for (unsigned i = 0; i < sizeof(T); i++) {
+        buffer.append(value & 0xFF);
+        value >>= 8;
+    }
+}
+#endif
+
+template <> static void writeLittleEndian<uint8_t>(Vector<uint8_t>& buffer, uint8_t value)
+{
+    buffer.append(value);
+}
+
+template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, const T* values, uint32_t length)
+{
+    if (length > numeric_limits<uint32_t>::max() / sizeof(T))
+        return false;
+
+#if ASSUME_LITTLE_ENDIAN
+    buffer.append(reinterpret_cast<const uint8_t*>(values), length * sizeof(T));
+#else
+    for (unsigned i = 0; i < length; i++) {
+        T value = values[i];
+        for (unsigned j = 0; j < sizeof(T); j++) {
+            buffer.append(static_cast<uint8_t>(value & 0xFF));
+            value >>= 8;
+        }
+    }
+#endif
+    return true;
+}
+
+
 class CloneSerializer : CloneBase {
 public:
     static bool serialize(ExecState* exec, JSValue value, Vector<uint8_t>& out)
@@ -444,43 +484,6 @@
         writeLittleEndian(m_buffer, c);
     }
 
-#if ASSUME_LITTLE_ENDIAN
-    template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
-    {
-        if (sizeof(T) == 1)
-            buffer.append(value);
-        else
-            buffer.append(reinterpret_cast<uint8_t*>(&value), sizeof(value));
-    }
-#else
-    template <typename T> static void writeLittleEndian(Vector<uint8_t>& buffer, T value)
-    {
-        for (unsigned i = 0; i < sizeof(T); i++) {
-            buffer.append(value & 0xFF);
-            value >>= 8;
-        }
-    }
-#endif
-
-    template <typename T> static bool writeLittleEndian(Vector<uint8_t>& buffer, const T* values, uint32_t length)
-    {
-        if (length > numeric_limits<uint32_t>::max() / sizeof(T))
-            return false;
-
-#if ASSUME_LITTLE_ENDIAN
-        buffer.append(reinterpret_cast<const uint8_t*>(values), length * sizeof(T));
-#else
-        for (unsigned i = 0; i < length; i++) {
-            T value = values[i];
-            for (unsigned j = 0; j < sizeof(T); j++) {
-                buffer.append(static_cast<uint8_t>(value & 0xFF));
-                value >>= 8;
-            }
-        }
-#endif
-        return true;
-    }
-
     void write(uint32_t i)
     {
         writeLittleEndian(m_buffer, i);