summaryrefslogtreecommitdiff
path: root/Source/WTF
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WTF')
-rw-r--r--Source/WTF/wtf/CMakeLists.txt9
-rw-r--r--Source/WTF/wtf/HashTable.h2
-rw-r--r--Source/WTF/wtf/OSRandomSource.cpp5
-rw-r--r--Source/WTF/wtf/Platform.h5
-rw-r--r--Source/WTF/wtf/PlatformQt.cmake21
-rw-r--r--Source/WTF/wtf/StringPrintStream.cpp34
-rw-r--r--Source/WTF/wtf/StringPrintStream.h1
-rw-r--r--Source/WTF/wtf/Vector.h8
-rw-r--r--Source/WTF/wtf/WorkQueue.cpp2
-rw-r--r--Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h41
-rw-r--r--Source/WTF/wtf/spi/darwin/XPCSPI.h14
-rw-r--r--Source/WTF/wtf/text/WTFString.cpp16
12 files changed, 63 insertions, 95 deletions
diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt
index 09b848c7a..297589b90 100644
--- a/Source/WTF/wtf/CMakeLists.txt
+++ b/Source/WTF/wtf/CMakeLists.txt
@@ -241,15 +241,6 @@ set(WTF_LIBRARIES
${CMAKE_DL_LIBS}
)
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- list(APPEND WTF_HEADERS
- spi/darwin/CommonCryptoSPI.h
- )
- list(APPEND WTF_INCLUDE_DIRECTORIES
- "${WTF_DIR}/wtf/spi/darwin"
- )
-endif ()
-
if (NOT USE_SYSTEM_MALLOC)
list(APPEND WTF_LIBRARIES bmalloc)
endif ()
diff --git a/Source/WTF/wtf/HashTable.h b/Source/WTF/wtf/HashTable.h
index 712022d71..f95167f23 100644
--- a/Source/WTF/wtf/HashTable.h
+++ b/Source/WTF/wtf/HashTable.h
@@ -845,7 +845,7 @@ namespace WTF {
// This initializes the bucket without copying the empty value.
// That makes it possible to use this with types that don't support copying.
// The memset to 0 looks like a slow operation but is optimized by the compilers.
- memset(&bucket, 0, sizeof(bucket));
+ memset(static_cast<void*>(std::addressof(bucket)), 0, sizeof(bucket));
}
};
diff --git a/Source/WTF/wtf/OSRandomSource.cpp b/Source/WTF/wtf/OSRandomSource.cpp
index 378795dc7..529acf714 100644
--- a/Source/WTF/wtf/OSRandomSource.cpp
+++ b/Source/WTF/wtf/OSRandomSource.cpp
@@ -41,7 +41,8 @@
#endif
#if OS(DARWIN)
-#include "CommonCryptoSPI.h"
+#include <CommonCrypto/CommonCryptoError.h>
+#include <CommonCrypto/CommonRandom.h>
#endif
namespace WTF {
@@ -61,7 +62,7 @@ NEVER_INLINE NO_RETURN_DUE_TO_CRASH static void crashUnableToReadFromURandom()
void cryptographicallyRandomValuesFromOS(unsigned char* buffer, size_t length)
{
#if OS(DARWIN)
- RELEASE_ASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
+ RELEASE_ASSERT(!CCRandomGenerateBytes(buffer, length));
#elif OS(UNIX)
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd < 0)
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index 191f3090c..5717f3ea1 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -238,7 +238,8 @@
|| defined(__ARM_ARCH_7S__)
#define WTF_ARM_ARCH_VERSION 7
-#elif defined(__ARM_ARCH_8__)
+#elif defined(__ARM_ARCH_8__) \
+ || defined(__ARM_ARCH_8A__)
#define WTF_ARM_ARCH_VERSION 8
/* MSVC sets _M_ARM */
@@ -1027,7 +1028,7 @@
#define USE_VIDEOTOOLBOX 1
#endif
-#if PLATFORM(COCOA) || PLATFORM(GTK) || (PLATFORM(WIN) && !USE(WINGDI))
+#if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(QT) || (PLATFORM(WIN) && !USE(WINGDI))
#define USE_REQUEST_ANIMATION_FRAME_TIMER 1
#endif
diff --git a/Source/WTF/wtf/PlatformQt.cmake b/Source/WTF/wtf/PlatformQt.cmake
index 684119455..b7f4149f2 100644
--- a/Source/WTF/wtf/PlatformQt.cmake
+++ b/Source/WTF/wtf/PlatformQt.cmake
@@ -27,7 +27,13 @@ if (QT_STATIC_BUILD)
)
endif ()
-if (UNIX AND NOT APPLE)
+if (USE_MACH_PORTS)
+ list(APPEND WTF_SOURCES
+ cocoa/WorkQueueCocoa.cpp
+ )
+endif ()
+
+if (USE_UNIX_DOMAIN_SOCKETS)
list(APPEND WTF_SOURCES
UniStdExtras.cpp
@@ -66,8 +72,6 @@ endif ()
if (APPLE)
list(APPEND WTF_SOURCES
- cocoa/WorkQueueCocoa.cpp
-
text/cf/AtomicStringImplCF.cpp
text/cf/StringCF.cpp
text/cf/StringImplCF.cpp
@@ -77,3 +81,14 @@ if (APPLE)
${COREFOUNDATION_LIBRARY}
)
endif ()
+
+if (UNIX AND NOT APPLE)
+ check_function_exists(clock_gettime CLOCK_GETTIME_EXISTS)
+ if (NOT CLOCK_GETTIME_EXISTS)
+ set(CMAKE_REQUIRED_LIBRARIES rt)
+ check_function_exists(clock_gettime CLOCK_GETTIME_REQUIRES_LIBRT)
+ if (CLOCK_GETTIME_REQUIRES_LIBRT)
+ list(APPEND WTF_LIBRARIES rt)
+ endif ()
+ endif ()
+endif ()
diff --git a/Source/WTF/wtf/StringPrintStream.cpp b/Source/WTF/wtf/StringPrintStream.cpp
index 0fd6e4760..6a8881c5b 100644
--- a/Source/WTF/wtf/StringPrintStream.cpp
+++ b/Source/WTF/wtf/StringPrintStream.cpp
@@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
@@ -52,32 +52,34 @@ void StringPrintStream::vprintf(const char* format, va_list argList)
{
ASSERT_WITH_SECURITY_IMPLICATION(m_next < m_size);
ASSERT(!m_buffer[m_next]);
-
+
va_list firstPassArgList;
va_copy(firstPassArgList, argList);
-
+
int numberOfBytesNotIncludingTerminatorThatWouldHaveBeenWritten =
vsnprintf(m_buffer + m_next, m_size - m_next, format, firstPassArgList);
-
+
+ va_end(firstPassArgList);
+
int numberOfBytesThatWouldHaveBeenWritten =
numberOfBytesNotIncludingTerminatorThatWouldHaveBeenWritten + 1;
-
+
if (m_next + numberOfBytesThatWouldHaveBeenWritten <= m_size) {
m_next += numberOfBytesNotIncludingTerminatorThatWouldHaveBeenWritten;
return; // This means that vsnprintf() succeeded.
}
-
+
increaseSize(m_next + numberOfBytesThatWouldHaveBeenWritten);
-
+
int numberOfBytesNotIncludingTerminatorThatWereWritten =
vsnprintf(m_buffer + m_next, m_size - m_next, format, argList);
-
+
int numberOfBytesThatWereWritten = numberOfBytesNotIncludingTerminatorThatWereWritten + 1;
-
+
ASSERT_UNUSED(numberOfBytesThatWereWritten, m_next + numberOfBytesThatWereWritten <= m_size);
-
+
m_next += numberOfBytesNotIncludingTerminatorThatWereWritten;
-
+
ASSERT_WITH_SECURITY_IMPLICATION(m_next < m_size);
ASSERT(!m_buffer[m_next]);
}
@@ -100,14 +102,20 @@ String StringPrintStream::toString()
return String::fromUTF8(m_buffer, m_next);
}
+String StringPrintStream::toStringWithLatin1Fallback()
+{
+ ASSERT(m_next == strlen(m_buffer));
+ return String::fromUTF8WithLatin1Fallback(m_buffer, m_next);
+}
+
void StringPrintStream::increaseSize(size_t newSize)
{
ASSERT_WITH_SECURITY_IMPLICATION(newSize > m_size);
ASSERT(newSize > sizeof(m_inlineBuffer));
-
+
// Use exponential resizing to reduce thrashing.
m_size = newSize << 1;
-
+
// Use fastMalloc instead of fastRealloc because we know that for the sizes we're using,
// fastRealloc will just do malloc+free anyway. Also, this simplifies the code since
// we can't realloc the inline buffer.
diff --git a/Source/WTF/wtf/StringPrintStream.h b/Source/WTF/wtf/StringPrintStream.h
index 18eecb208..c526b8aa1 100644
--- a/Source/WTF/wtf/StringPrintStream.h
+++ b/Source/WTF/wtf/StringPrintStream.h
@@ -43,6 +43,7 @@ public:
WTF_EXPORT_PRIVATE CString toCString();
WTF_EXPORT_PRIVATE String toString();
+ WTF_EXPORT_PRIVATE String toStringWithLatin1Fallback();
WTF_EXPORT_PRIVATE void reset();
private:
diff --git a/Source/WTF/wtf/Vector.h b/Source/WTF/wtf/Vector.h
index 18268b6ef..d9a25ac6f 100644
--- a/Source/WTF/wtf/Vector.h
+++ b/Source/WTF/wtf/Vector.h
@@ -85,7 +85,7 @@ struct VectorInitializer<true, true, T>
{
static void initialize(T* begin, T* end)
{
- memset(begin, 0, reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin));
+ memset(static_cast<void*>(begin), 0, reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin));
}
};
@@ -125,11 +125,11 @@ struct VectorMover<true, T>
{
static void move(const T* src, const T* srcEnd, T* dst)
{
- memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memcpy(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
static void moveOverlapping(const T* src, const T* srcEnd, T* dst)
{
- memmove(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memmove(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
};
@@ -155,7 +155,7 @@ struct VectorCopier<true, T>
{
static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
{
- memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memcpy(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
template<typename U>
static void uninitializedCopy(const T* src, const T* srcEnd, U* dst)
diff --git a/Source/WTF/wtf/WorkQueue.cpp b/Source/WTF/wtf/WorkQueue.cpp
index e26ae3bf2..3624d3902 100644
--- a/Source/WTF/wtf/WorkQueue.cpp
+++ b/Source/WTF/wtf/WorkQueue.cpp
@@ -52,7 +52,7 @@ WorkQueue::~WorkQueue()
platformInvalidate();
}
-#if !PLATFORM(COCOA) && !(PLATFORM(QT) && OS(DARWIN))
+#if !PLATFORM(COCOA) && !(PLATFORM(QT) && USE(MACH_PORTS))
void WorkQueue::concurrentApply(size_t iterations, const std::function<void (size_t index)>& function)
{
if (!iterations)
diff --git a/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h b/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h
deleted file mode 100644
index 325cbe81b..000000000
--- a/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CommonCryptoSPI_h
-#define CommonCryptoSPI_h
-
-#if OS(DARWIN)
-
-#if USE(APPLE_INTERNAL_SDK)
-#include <CommonCrypto/CommonRandomSPI.h>
-#endif
-
-typedef struct __CCRandom* CCRandomRef;
-extern const CCRandomRef kCCRandomDefault;
-extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-
-#endif // OS(DARWIN)
-
-#endif /* CommonCryptoSPI_h */
diff --git a/Source/WTF/wtf/spi/darwin/XPCSPI.h b/Source/WTF/wtf/spi/darwin/XPCSPI.h
index e30315ab5..2820b9d04 100644
--- a/Source/WTF/wtf/spi/darwin/XPCSPI.h
+++ b/Source/WTF/wtf/spi/darwin/XPCSPI.h
@@ -56,11 +56,15 @@ typedef void* xpc_connection_t;
typedef const struct _xpc_type_s* xpc_type_t;
+#if PLATFORM(IOS) && __has_attribute(noescape)
+#define XPC_NOESCAPE __attribute__((__noescape__))
+#endif
+
#if COMPILER_SUPPORTS(BLOCKS)
typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t);
typedef bool (^xpc_dictionary_applier_t)(const char *key, xpc_object_t value);
typedef void (^xpc_handler_t)(xpc_object_t);
-#endif
+#endif // COMPILER_SUPPORTS(BLOCKS)
typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);
@@ -79,6 +83,10 @@ typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);
#include <xpc/private.h>
#endif
+#if !defined(XPC_NOESCAPE)
+#define XPC_NOESCAPE
+#endif
+
EXTERN_C const struct _xpc_dictionary_s _xpc_error_connection_invalid;
EXTERN_C const struct _xpc_dictionary_s _xpc_error_termination_imminent;
@@ -90,8 +98,8 @@ EXTERN_C const struct _xpc_type_s _xpc_type_string;
EXTERN_C xpc_object_t xpc_array_create(const xpc_object_t*, size_t count);
#if COMPILER_SUPPORTS(BLOCKS)
-EXTERN_C bool xpc_array_apply(xpc_object_t, xpc_array_applier_t);
-EXTERN_C bool xpc_dictionary_apply(xpc_object_t xdict, xpc_dictionary_applier_t applier);
+EXTERN_C bool xpc_array_apply(xpc_object_t, XPC_NOESCAPE xpc_array_applier_t);
+EXTERN_C bool xpc_dictionary_apply(xpc_object_t xdict, XPC_NOESCAPE xpc_dictionary_applier_t applier);
#endif
EXTERN_C size_t xpc_array_get_count(xpc_object_t);
EXTERN_C const char* xpc_array_get_string(xpc_object_t, size_t index);
diff --git a/Source/WTF/wtf/text/WTFString.cpp b/Source/WTF/wtf/text/WTFString.cpp
index 958fd2069..ce376e23a 100644
--- a/Source/WTF/wtf/text/WTFString.cpp
+++ b/Source/WTF/wtf/text/WTFString.cpp
@@ -460,21 +460,6 @@ Vector<UChar> String::charactersWithNullTermination() const
String String::format(const char *format, ...)
{
-#if PLATFORM(QT)
- // Use QString::vsprintf to avoid the locale dependent formatting of vsnprintf.
- // https://bugs.webkit.org/show_bug.cgi?id=18994
- va_list args;
- va_start(args, format);
-
- QString buffer;
- buffer.vsprintf(format, args);
-
- va_end(args);
-
- QByteArray ba = buffer.toUtf8();
- return StringImpl::create(reinterpret_cast<const LChar*>(ba.constData()), ba.length());
-
-#else
va_list args;
va_start(args, format);
@@ -503,7 +488,6 @@ String String::format(const char *format, ...)
va_end(args);
return StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), len);
-#endif
}
String String::number(int number)