diff options
| -rw-r--r-- | Source/JavaScriptCore/config.h | 9 | ||||
| -rw-r--r-- | Source/WTF/WTF.pro | 1 | ||||
| -rw-r--r-- | Source/WTF/config.h | 9 | ||||
| -rw-r--r-- | Source/WTF/wtf/Atomics.cpp | 110 | ||||
| -rw-r--r-- | Source/WTF/wtf/Atomics.h | 25 | ||||
| -rw-r--r-- | Source/WTF/wtf/Platform.h | 32 | ||||
| -rw-r--r-- | Source/WebCore/WebCorePrefix.h | 9 | ||||
| -rw-r--r-- | Source/WebCore/config.h | 9 | ||||
| -rw-r--r-- | Source/WebKit2/Platform/CoreIPC/Connection.cpp | 6 | ||||
| -rw-r--r-- | Source/WebKit2/Platform/CoreIPC/Connection.h | 4 | ||||
| -rw-r--r-- | Source/WebKit2/UIProcess/StatisticsRequest.cpp | 10 | ||||
| -rw-r--r-- | Source/WebKit2/config.h | 13 | ||||
| -rw-r--r-- | Tools/DumpRenderTree/config.h | 6 |
13 files changed, 66 insertions, 177 deletions
diff --git a/Source/JavaScriptCore/config.h b/Source/JavaScriptCore/config.h index 4e1d2b91c..a5df3aa7a 100644 --- a/Source/JavaScriptCore/config.h +++ b/Source/JavaScriptCore/config.h @@ -34,15 +34,6 @@ #endif #if OS(WINDOWS) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#endif - -#ifndef WINVER -#define WINVER 0x0502 -#endif - // If we don't define these, they get defined in windef.h. // We want to use std::min and std::max #define max max diff --git a/Source/WTF/WTF.pro b/Source/WTF/WTF.pro index 2187e6dfe..f3a77dd06 100644 --- a/Source/WTF/WTF.pro +++ b/Source/WTF/WTF.pro @@ -187,7 +187,6 @@ SOURCES += \ ArrayBuffer.cpp \ ArrayBufferView.cpp \ Assertions.cpp \ - Atomics.cpp \ BitVector.cpp \ CryptographicallyRandomNumber.cpp \ CurrentTime.cpp \ diff --git a/Source/WTF/config.h b/Source/WTF/config.h index 5552be3ee..175b29c7c 100644 --- a/Source/WTF/config.h +++ b/Source/WTF/config.h @@ -31,15 +31,6 @@ #include <wtf/ExportMacros.h> #if OS(WINDOWS) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#endif - -#ifndef WINVER -#define WINVER 0x0502 -#endif - // If we don't define these, they get defined in windef.h. // We want to use std::min and std::max #define max max diff --git a/Source/WTF/wtf/Atomics.cpp b/Source/WTF/wtf/Atomics.cpp deleted file mode 100644 index 0feea1532..000000000 --- a/Source/WTF/wtf/Atomics.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2010, 2012 Apple Inc. All rights reserved. - * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) - * - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. - * - * - * Note: The implementations of InterlockedIncrement and InterlockedDecrement are based - * on atomic_increment and atomic_exchange_and_add from the Boost C++ Library. The license - * is virtually identical to the Apple license above but is included here for completeness. - * - * Boost Software License - Version 1.0 - August 17th, 2003 - * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: - * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "config.h" -#include "Atomics.h" - -// Some architectures, like MIPS32, don't have GCC implementation for builtin __sync_* functions -// with 64 bits variable size. Official GCC answer for the problem: If a target doesn't support -// atomic operations on certain variable sizes, you are out of luck with atomicity in that case -// (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56296). GCC >= 4.8 will support __atomic_* builtin -// functions for this purpose for all the GCC targets, but for current compilers we have to include -// our own implementation. -#if COMPILER(GCC) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) && USE(LOCKFREE_THREADSAFEREFCOUNTED) && USE(PTHREADS) - -#include "ThreadingPrimitives.h" - -namespace WTF { - -static const size_t kSwapLockCount = 32; -static Mutex s_swapLocks[kSwapLockCount]; - -static inline Mutex& getSwapLock(const volatile int64_t* addr) -{ - return s_swapLocks[(reinterpret_cast<intptr_t>(addr) >> 3U) % kSwapLockCount]; -} - -static int64_t atomicStep(int64_t volatile* addend, int64_t step) -{ - Mutex& mutex = getSwapLock(addend); - - mutex.lock(); - int64_t value = *addend + step; - *addend = value; - mutex.unlock(); - - return value; -} - -extern "C" { - -int64_t __sync_add_and_fetch_8(int64_t volatile* addend, int64_t value) -{ - return atomicStep(addend, value); -} - -int64_t __sync_sub_and_fetch_8(int64_t volatile* addend, int64_t value) -{ - return atomicStep(addend, -value); -} - -} // extern "C" - -} // namespace WTF - -#endif diff --git a/Source/WTF/wtf/Atomics.h b/Source/WTF/wtf/Atomics.h index b21d51520..ea4f55f95 100644 --- a/Source/WTF/wtf/Atomics.h +++ b/Source/WTF/wtf/Atomics.h @@ -78,24 +78,16 @@ extern "C" void _ReadWriteBarrier(void); namespace WTF { +// 32bit atomicIncrement/atomicDecrement #if OS(WINDOWS) #define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 -#if OS(WINCE) -inline int atomicIncrement(int* addend) { return InterlockedIncrement(reinterpret_cast<long*>(addend)); } -inline int atomicDecrement(int* addend) { return InterlockedDecrement(reinterpret_cast<long*>(addend)); } -#elif COMPILER(MINGW) +#if OS(WINCE) || COMPILER(MINGW) inline int atomicIncrement(int* addend) { return InterlockedIncrement(reinterpret_cast<long*>(addend)); } inline int atomicDecrement(int* addend) { return InterlockedDecrement(reinterpret_cast<long*>(addend)); } - -inline int64_t atomicIncrement(int64_t* addend) { return InterlockedIncrement64(reinterpret_cast<long long*>(addend)); } -inline int64_t atomicDecrement(int64_t* addend) { return InterlockedDecrement64(reinterpret_cast<long long*>(addend)); } #else inline int atomicIncrement(int volatile* addend) { return InterlockedIncrement(reinterpret_cast<long volatile*>(addend)); } inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(reinterpret_cast<long volatile*>(addend)); } - -inline int64_t atomicIncrement(int64_t volatile* addend) { return InterlockedIncrement64(reinterpret_cast<long long volatile*>(addend)); } -inline int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDecrement64(reinterpret_cast<long long volatile*>(addend)); } #endif #elif OS(QNX) @@ -115,17 +107,26 @@ inline int atomicDecrement(int volatile* addend) { return __atomic_dec(addend) - 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 +#elif COMPILER(GCC) #define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 inline int atomicIncrement(int volatile* addend) { return __sync_add_and_fetch(addend, 1); } inline int atomicDecrement(int volatile* addend) { return __sync_sub_and_fetch(addend, 1); } +#endif + +// 64bit atomicIncrement/atomicDecrement +#if HAVE(ATOMICS_64BIT) +#if COMPILER(GCC) 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 OS(WINDOWS) +inline int64_t atomicIncrement(int64_t volatile* addend) { return InterlockedIncrement64(reinterpret_cast<long long volatile*>(addend)); } +inline int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDecrement64(reinterpret_cast<long long volatile*>(addend)); } +#endif #endif + #if OS(WINDOWS) inline bool weakCompareAndSwap(volatile unsigned* location, unsigned expected, unsigned newValue) { diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 6a544fa4f..3a9b509f2 100644 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -440,6 +440,33 @@ #define WTF_OS_UNIX 1 #endif +#if OS(WINDOWS) +// Minimum supported windows is Windows XP. +// The original WinXP was NT 5.1, but Win XP 64bit was NT 5.2 +#if CPU(X86_64) +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0502 +#endif + +#ifndef WINVER +#define WINVER 0x0502 +#endif + +#else /* !CPU(X86_64) */ + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + +#ifndef WINVER +#define WINVER 0x0501 +#endif + +#endif + +#endif + + /* Operating environments */ /* FIXME: these are all mixes of OS, operating environment and policy choices. */ @@ -1020,6 +1047,11 @@ #define WTF_USE_CONTENT_FILTERING 1 #endif +#if COMPILER(GCC) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) +#define HAVE_ATOMICS_64BIT 1 +#elif OS(WINDOWS) && (_WIN32_WINNT >= 0x0502) +#define HAVE_ATOMICS_64BIT 1 +#endif #define WTF_USE_GRAMMAR_CHECKING 1 diff --git a/Source/WebCore/WebCorePrefix.h b/Source/WebCore/WebCorePrefix.h index 543f50f61..575687226 100644 --- a/Source/WebCore/WebCorePrefix.h +++ b/Source/WebCore/WebCorePrefix.h @@ -38,15 +38,6 @@ #endif #if OS(WINDOWS) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#endif - -#ifndef WINVER -#define WINVER 0x0502 -#endif - #if !USE(CURL) #ifndef _WINSOCKAPI_ #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h diff --git a/Source/WebCore/config.h b/Source/WebCore/config.h index 30bed8e6a..d0be35d94 100644 --- a/Source/WebCore/config.h +++ b/Source/WebCore/config.h @@ -47,15 +47,6 @@ #endif /* __APPLE__ */ #if OS(WINDOWS) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#endif - -#ifndef WINVER -#define WINVER 0x0502 -#endif - // If we don't define these, they get defined in windef.h. // We want to use std::min and std::max. #ifndef max diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.cpp b/Source/WebKit2/Platform/CoreIPC/Connection.cpp index b6cdf9325..e618e9d1b 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.cpp +++ b/Source/WebKit2/Platform/CoreIPC/Connection.cpp @@ -348,9 +348,15 @@ PassOwnPtr<MessageEncoder> Connection::createSyncMessageEncoder(StringReference OwnPtr<MessageEncoder> encoder = MessageEncoder::create(messageReceiverName, messageName, destinationID); encoder->setIsSyncMessage(true); +#if HAVE(ATOMICS_64BIT) // Encode the sync request ID. COMPILE_ASSERT(sizeof(m_syncRequestID) == sizeof(int64_t), CanUseAtomicIncrement); syncRequestID = atomicIncrement(reinterpret_cast<int64_t*>(&m_syncRequestID)); +#else + m_syncRequestLock.lock(); + syncRequestID = ++m_syncRequestID; + m_syncRequestLock.unlock(); +#endif *encoder << syncRequestID; return encoder.release(); diff --git a/Source/WebKit2/Platform/CoreIPC/Connection.h b/Source/WebKit2/Platform/CoreIPC/Connection.h index 50a9c9876..be1923699 100644 --- a/Source/WebKit2/Platform/CoreIPC/Connection.h +++ b/Source/WebKit2/Platform/CoreIPC/Connection.h @@ -254,6 +254,10 @@ private: Mutex m_waitForMessageMutex; HashMap<std::pair<std::pair<StringReference, StringReference>, uint64_t>, OwnPtr<MessageDecoder> > m_waitForMessageMap; +#if !HAVE(ATOMICS_64BIT) + Mutex m_syncRequestLock; +#endif + // Represents a sync request for which we're waiting on a reply. struct PendingSyncReply { // The request ID. diff --git a/Source/WebKit2/UIProcess/StatisticsRequest.cpp b/Source/WebKit2/UIProcess/StatisticsRequest.cpp index 0fa1fb7a7..6f81ccbb3 100644 --- a/Source/WebKit2/UIProcess/StatisticsRequest.cpp +++ b/Source/WebKit2/UIProcess/StatisticsRequest.cpp @@ -28,7 +28,7 @@ #include "ImmutableArray.h" #include "MutableDictionary.h" -#include <wtf/Atomics.h> +#include <wtf/Threading.h> namespace WebKit { @@ -47,7 +47,15 @@ uint64_t StatisticsRequest::addOutstandingRequest() { static int64_t uniqueRequestID; +#if HAVE(ATOMICS_64BIT) uint64_t requestID = atomicIncrement(&uniqueRequestID); +#else + static Mutex uniqueRequestMutex; + uniqueRequestMutex.lock(); + uint64_t requestID = ++uniqueRequestID; + uniqueRequestMutex.unlock(); +#endif + m_outstandingRequests.add(requestID); return requestID; } diff --git a/Source/WebKit2/config.h b/Source/WebKit2/config.h index c80c29ef4..37cc06f6a 100644 --- a/Source/WebKit2/config.h +++ b/Source/WebKit2/config.h @@ -55,16 +55,7 @@ static const type& name() \ return name##Value; \ } -#if defined(WIN32) || defined(_WIN32) - -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#endif - -#ifndef WINVER -#define WINVER 0x0502 -#endif - +#if OS(WINDOWS) /* If we don't define these, they get defined in windef.h. */ /* We want to use std::min and std::max. */ #ifndef max @@ -87,7 +78,7 @@ static const type& name() \ #include <CoreGraphics/CoreGraphics.h> #endif -#endif /* defined(WIN32) || defined(_WIN32) */ +#endif /* OS(WINDOWS) */ #ifdef __cplusplus diff --git a/Tools/DumpRenderTree/config.h b/Tools/DumpRenderTree/config.h index 6424465dc..05b264ed1 100644 --- a/Tools/DumpRenderTree/config.h +++ b/Tools/DumpRenderTree/config.h @@ -75,12 +75,6 @@ #define WTF_USE_CFNETWORK 1 #endif -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 - -#undef WINVER -#define WINVER 0x0502 - #undef _WINSOCKAPI_ #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h #endif // PLATFORM(WIN) |
