WebKit Bugzilla
Attachment 360384 Details for
Bug 193929
: Move platform-specific files out of WTF root directory.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193929-20190128151940.patch (text/plain), 104.26 KB, created by
Ross Kirsling
on 2019-01-28 15:19:41 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ross Kirsling
Created:
2019-01-28 15:19:41 PST
Size:
104.26 KB
patch
obsolete
>Subversion Revision: 240600 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index cccca497e797f8dc9f435cce42c6932a63e86112..9cf0ec1460cd8c3e89a3166ae7b3807f3b90c4fc 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,27 @@ >+2019-01-28 Ross Kirsling <ross.kirsling@sony.com> >+ >+ Move platform-specific files out of WTF root directory. >+ https://bugs.webkit.org/show_bug.cgi?id=193929 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WTF.xcodeproj/project.pbxproj: >+ * wtf/CMakeLists.txt: >+ * wtf/PlatformGTK.cmake: >+ * wtf/PlatformJSCOnly.cmake: >+ * wtf/PlatformMac.cmake: >+ * wtf/PlatformPlayStation.cmake: >+ * wtf/PlatformWPE.cmake: >+ * wtf/PlatformWin.cmake: >+ * wtf/cf/RunLoopTimerCF.cpp: Renamed from Source/WTF/wtf/RunLoopTimerCF.cpp. >+ * wtf/cf/SchedulePairCF.cpp: Renamed from Source/WTF/wtf/SchedulePairCF.cpp. >+ * wtf/mac/SchedulePairMac.mm: Renamed from Source/WTF/wtf/SchedulePairMac.mm. >+ * wtf/posix/OSAllocatorPOSIX.cpp: Renamed from Source/WTF/wtf/OSAllocatorPosix.cpp. >+ * wtf/win/CONTRIBUTORS.pthreads-win32: Renamed from Source/WTF/wtf/CONTRIBUTORS.pthreads-win32. >+ * wtf/win/OSAllocatorWin.cpp: Renamed from Source/WTF/wtf/OSAllocatorWin.cpp. >+ * wtf/win/ThreadSpecificWin.cpp: Renamed from Source/WTF/wtf/ThreadSpecificWin.cpp. >+ * wtf/win/ThreadingWin.cpp: Renamed from Source/WTF/wtf/ThreadingWin.cpp. >+ > 2019-01-28 Ross Kirsling <ross.kirsling@sony.com> > > [JSCOnly][WTF] Expose FileSystem. >diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj >index d953b1baf7e727189d008caa8adb1f32819f1686..07814236b876516d13e96f9c011eb2b8ac480583 100644 >--- a/Source/WTF/WTF.xcodeproj/project.pbxproj >+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj >@@ -46,9 +46,6 @@ > 14022F4118F5C3FC007FF0EB /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14022F4018F5C3FC007FF0EB /* libbmalloc.a */; }; > 143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */ = {isa = PBXBuildFile; fileRef = 143DDE9520C8BC37007F76FA /* Entitlements.mm */; }; > 143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; }; >- 1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */; }; >- 1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1469419516EAAFF80024E146 /* SchedulePairMac.mm */; }; >- 1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419816EAB0410024E146 /* SchedulePairCF.cpp */; }; > 1469419D16EAB10A0024E146 /* AutodrainedPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */; }; > 1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; }; > 1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; }; >@@ -97,6 +94,10 @@ > A331D96721F24ABD009F02AA /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */; }; > A3B725EC987446AD93F1A440 /* RandomDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */; }; > A3E4DD931F3A803400DED0B4 /* TextStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3E4DD911F3A803400DED0B4 /* TextStream.cpp */; }; >+ A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */; }; >+ A3EE5C3D21FFAC7D00FABD61 /* SchedulePairCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */; }; >+ A3EE5C3E21FFAC7D00FABD61 /* RunLoopTimerCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */; }; >+ A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */; }; > A5BA15F3182433A900A82E69 /* StringCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F2182433A900A82E69 /* StringCocoa.mm */; }; > A5BA15F51824348000A82E69 /* StringImplCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F41824348000A82E69 /* StringImplCocoa.mm */; }; > A5BA15FA182435A600A82E69 /* AtomicStringImplCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15F7182435A600A82E69 /* AtomicStringImplCF.cpp */; }; >@@ -126,7 +127,6 @@ > A8A473E9151A825B004123FF /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CA151A825B004123FF /* MD5.cpp */; }; > A8A473EC151A825B004123FF /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CD151A825B004123FF /* MetaAllocator.cpp */; }; > A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D5151A825B004123FF /* NumberOfCores.cpp */; }; >- A8A473F7151A825B004123FF /* OSAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */; }; > A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472DA151A825B004123FF /* OSRandomSource.cpp */; }; > A8A47402151A825B004123FF /* PageBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472E3151A825B004123FF /* PageBlock.cpp */; }; > A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472FB151A825B004123FF /* RandomNumber.cpp */; }; >@@ -281,10 +281,7 @@ > 1447AEC518FCE57700B3D7FF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; > 1447AECA18FCE5B900B3D7FF /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; }; > 1469419016EAAF6D0024E146 /* RunLoopTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoopTimer.h; sourceTree = "<group>"; }; >- 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopTimerCF.cpp; sourceTree = "<group>"; }; > 1469419416EAAFF80024E146 /* SchedulePair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchedulePair.h; sourceTree = "<group>"; }; >- 1469419516EAAFF80024E146 /* SchedulePairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchedulePairMac.mm; sourceTree = "<group>"; }; >- 1469419816EAB0410024E146 /* SchedulePairCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulePairCF.cpp; sourceTree = "<group>"; }; > 1469419A16EAB10A0024E146 /* AutodrainedPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutodrainedPool.h; sourceTree = "<group>"; }; > 1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutodrainedPool.cpp; sourceTree = "<group>"; }; > 149EF16216BBFE0D000A4331 /* TriState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriState.h; sourceTree = "<group>"; }; >@@ -449,6 +446,10 @@ > A3D273B921F2EE9100866971 /* MetadataSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; }; > A3E4DD911F3A803400DED0B4 /* TextStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextStream.cpp; sourceTree = "<group>"; }; > A3E4DD921F3A803400DED0B4 /* TextStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextStream.h; sourceTree = "<group>"; }; >+ A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPOSIX.cpp; sourceTree = "<group>"; }; >+ A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulePairCF.cpp; sourceTree = "<group>"; }; >+ A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopTimerCF.cpp; sourceTree = "<group>"; }; >+ A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchedulePairMac.mm; sourceTree = "<group>"; }; > A5098AFF1C169E0700087797 /* SandboxSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxSPI.h; sourceTree = "<group>"; }; > A5098B011C16A4F900087797 /* SecuritySPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecuritySPI.h; sourceTree = "<group>"; }; > A561F30F1DF2642100FF675D /* DeprecatedOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeprecatedOptional.h; sourceTree = "<group>"; }; >@@ -540,7 +541,6 @@ > A8A472D5151A825B004123FF /* NumberOfCores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NumberOfCores.cpp; sourceTree = "<group>"; }; > A8A472D6151A825B004123FF /* NumberOfCores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberOfCores.h; sourceTree = "<group>"; }; > A8A472D7151A825B004123FF /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; }; >- A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPosix.cpp; sourceTree = "<group>"; }; > A8A472DA151A825B004123FF /* OSRandomSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSRandomSource.cpp; sourceTree = "<group>"; }; > A8A472DB151A825B004123FF /* OSRandomSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSRandomSource.h; sourceTree = "<group>"; }; > A8A472DF151A825B004123FF /* PackedIntVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackedIntVector.h; sourceTree = "<group>"; }; >@@ -735,6 +735,8 @@ > A331D95C21F249E4009F02AA /* FileSystemCF.cpp */, > C2BCFC411F61D61600C9222C /* LanguageCF.cpp */, > 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */, >+ A3EE5C3C21FFAC7D00FABD61 /* RunLoopTimerCF.cpp */, >+ A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */, > 1AFDE647195201C300C48FFA /* TypeCastsCF.h */, > 5C1F0594216437B30039302C /* URLCF.cpp */, > ); >@@ -794,6 +796,7 @@ > isa = PBXGroup; > children = ( > A331D96621F24ABD009F02AA /* FileSystemPOSIX.cpp */, >+ A3EE5C3921FFAC5E00FABD61 /* OSAllocatorPOSIX.cpp */, > ); > path = posix; > sourceTree = "<group>"; >@@ -1034,7 +1037,6 @@ > 1A4656181C7FC68E00F5920F /* OptionSet.h */, > 0F9495831C571CC900413A48 /* OrderMaker.h */, > A8A472D7151A825B004123FF /* OSAllocator.h */, >- A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */, > 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */, > A8A472DA151A825B004123FF /* OSRandomSource.cpp */, > A8A472DB151A825B004123FF /* OSRandomSource.h */, >@@ -1090,11 +1092,8 @@ > 2CDED0F118115C85004DBA70 /* RunLoop.cpp */, > 2CDED0F218115C85004DBA70 /* RunLoop.h */, > 1469419016EAAF6D0024E146 /* RunLoopTimer.h */, >- 1469419116EAAF6D0024E146 /* RunLoopTimerCF.cpp */, > 14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */, > 1469419416EAAFF80024E146 /* SchedulePair.h */, >- 1469419816EAB0410024E146 /* SchedulePairCF.cpp */, >- 1469419516EAAFF80024E146 /* SchedulePairMac.mm */, > 1A3524AA1D63A2FF0031729B /* Scope.h */, > 0FEC84B01BDACD390080FF74 /* ScopedLambda.h */, > 0F66B2841DC97BAB004A1D3F /* Seconds.cpp */, >@@ -1229,6 +1228,7 @@ > 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */, > A331D96021F24A0A009F02AA /* FileSystemMac.mm */, > 53534F291EC0E10E00141B2F /* MachExceptions.defs */, >+ A3EE5C3F21FFACA200FABD61 /* SchedulePairMac.mm */, > ); > path = mac; > sourceTree = "<group>"; >@@ -1548,7 +1548,7 @@ > 0F66B28C1DC97BAB004A1D3F /* MonotonicTime.cpp in Sources */, > 5CC0EE8A2162BC2200A1A842 /* NSURLExtras.mm in Sources */, > A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */, >- A8A473F7151A825B004123FF /* OSAllocatorPosix.cpp in Sources */, >+ A3EE5C3A21FFAC5F00FABD61 /* OSAllocatorPOSIX.cpp in Sources */, > A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */, > A8A47402151A825B004123FF /* PageBlock.cpp in Sources */, > 0FFF19DC1BB334EB00886D91 /* ParallelHelperPool.cpp in Sources */, >@@ -1566,9 +1566,9 @@ > A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */, > 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */, > 2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */, >- 1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */, >- 1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */, >- 1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */, >+ A3EE5C3E21FFAC7D00FABD61 /* RunLoopTimerCF.cpp in Sources */, >+ A3EE5C3D21FFAC7D00FABD61 /* SchedulePairCF.cpp in Sources */, >+ A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */, > 0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */, > A8A47421151A825B004123FF /* SHA1.cpp in Sources */, > 5311BD531EA71CAD00525281 /* Signals.cpp in Sources */, >diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt >index 6bfbcf5b0bc14f2ccd6dbec069f44e137ff0e605..178383dff491b4b1bb1a2d69000d2f6a430e0b52 100644 >--- a/Source/WTF/wtf/CMakeLists.txt >+++ b/Source/WTF/wtf/CMakeLists.txt >@@ -492,23 +492,6 @@ list(APPEND WTF_LIBRARIES > ${ICU_LIBRARIES} > ) > >-if (WIN32) >- list(APPEND WTF_SOURCES >- OSAllocatorWin.cpp >- ThreadSpecificWin.cpp >- ThreadingWin.cpp >- ) >- list(APPEND WTF_LIBRARIES >- DbgHelp >- winmm >- ) >-else () >- list(APPEND WTF_SOURCES >- OSAllocatorPosix.cpp >- ThreadingPthreads.cpp >- ) >-endif () >- > WEBKIT_FRAMEWORK_DECLARE(WTF) > WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS() > >diff --git a/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 b/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 >deleted file mode 100644 >index 7de0f260659e44e4e6f728dd87fe9cd9b0d98d14..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/CONTRIBUTORS.pthreads-win32 >+++ /dev/null >@@ -1,137 +0,0 @@ >-This is a copy of CONTRIBUTORS file for the Pthreads-win32 library, downloaded >-from http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/CONTRIBUTORS?rev=1.32&cvsroot=pthreads-win32 >- >-Included here to compliment the Pthreads-win32 license header in wtf/ThreadingWin.cpp file. >-WebKit is using derived sources of ThreadCondition code from Pthreads-win32. >- >-------------------------------------------------------------------------------- >- >-Contributors (in approximate order of appearance) >- >-[See also the ChangeLog file where individuals are >-attributed in log entries. Likewise in the FAQ file.] >- >-Ben Elliston bje at cygnus dot com >- Initiated the project; >- setup the project infrastructure (CVS, web page, etc.); >- early prototype routines. >-Ross Johnson rpj at callisto dot canberra dot edu dot au >- early prototype routines; >- ongoing project coordination/maintenance; >- implementation of spin locks and barriers; >- various enhancements; >- bug fixes; >- documentation; >- testsuite. >-Robert Colquhoun rjc at trump dot net dot au >- Early bug fixes. >-John E. Bossom John dot Bossom at cognos dot com >- Contributed substantial original working implementation; >- bug fixes; >- ongoing guidance and standards interpretation. >-Anders Norlander anorland at hem2 dot passagen dot se >- Early enhancements and runtime checking for supported >- Win32 routines. >-Tor Lillqvist tml at iki dot fi >- General enhancements; >- early bug fixes to condition variables. >-Scott Lightner scott at curriculum dot com >- Bug fix. >-Kevin Ruland Kevin dot Ruland at anheuser-busch dot com >- Various bug fixes. >-Mike Russo miker at eai dot com >- Bug fix. >-Mark E. Armstrong avail at pacbell dot net >- Bug fixes. >-Lorin Hochstein lmh at xiphos dot ca >- general bug fixes; bug fixes to condition variables. >-Peter Slacik Peter dot Slacik at tatramed dot sk >- Bug fixes. >-Mumit Khan khan at xraylith dot wisc dot edu >- Fixes to work with Mingw32. >-Milan Gardian mg at tatramed dot sk >- Bug fixes and reports/analyses of obscure problems. >-Aurelio Medina aureliom at crt dot com >- First implementation of read-write locks. >-Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au >- Bug fix in condition variables. >-Tristan Savatier tristan at mpegtv dot com >- WinCE port. >-Erik Hensema erik at hensema dot xs4all dot nl >- Bug fixes. >-Rich Peters rpeters at micro-magic dot com >-Todd Owen towen at lucidcalm dot dropbear dot id dot au >- Bug fixes to dll loading. >-Jason Nye jnye at nbnet dot nb dot ca >- Implementation of async cancelation. >-Fred Forester fforest at eticomm dot net >-Kevin D. Clark kclark at cabletron dot com >-David Baggett dmb at itasoftware dot com >- Bug fixes. >-Paul Redondo paul at matchvision dot com >-Scott McCaskill scott at 3dfx dot com >- Bug fixes. >-Jef Gearhart jgearhart at tpssys dot com >- Bug fix. >-Arthur Kantor akantor at bexusa dot com >- Mutex enhancements. >-Steven Reddie smr at essemer dot com dot au >- Bug fix. >-Alexander Terekhov TEREKHOV at de dot ibm dot com >- Re-implemented and improved read-write locks; >- (with Louis Thomas) re-implemented and improved >- condition variables; >- enhancements to semaphores; >- enhancements to mutexes; >- new mutex implementation in 'futex' style; >- suggested a robust implementation of pthread_once >- similar to that implemented by V.Kliathcko; >- system clock change handling re CV timeouts; >- bug fixes. >-Thomas Pfaff tpfaff at gmx dot net >- Changes to make C version usable with C++ applications; >- re-implemented mutex routines to avoid Win32 mutexes >- and TryEnterCriticalSection; >- procedure to fix Mingw32 thread-safety issues. >-Franco Bez franco dot bez at gmx dot de >- procedure to fix Mingw32 thread-safety issues. >-Louis Thomas lthomas at arbitrade dot com >- (with Alexander Terekhov) re-implemented and improved >- condition variables. >-David Korn dgk at research dot att dot com >- Ported to UWIN. >-Phil Frisbie, Jr. phil at hawksoft dot com >- Bug fix. >-Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de >- Bug fix. >-prionx at juno dot com prionx at juno dot com >- Bug fixes. >-Max Woodbury mtew at cds dot duke dot edu >- POSIX versioning conditionals; >- reduced namespace pollution; >- idea to separate routines to reduce statically >- linked image sizes. >-Rob Fanner rfanner at stonethree dot com >- Bug fix. >-Michael Johnson michaelj at maine dot rr dot com >- Bug fix. >-Nicolas Barry boozai at yahoo dot com >- Bug fixes. >-Piet van Bruggen pietvb at newbridges dot nl >- Bug fix. >-Makoto Kato raven at oldskool dot jp >- AMD64 port. >-Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr >- Contributed the QueueUserAPCEx package which >- makes preemptive async cancelation possible. >-Will Bryant will dot bryant at ecosm dot com >- Borland compiler patch and makefile. >-Anuj Goyal anuj dot goyal at gmail dot com >- Port to Digital Mars compiler. >-Gottlob Frege gottlobfrege at gmail dot com >- re-implemented pthread_once (version 2) >- (pthread_once cancellation added by rpj). >-Vladimir Kliatchko vladimir at kliatchko dot com >- reimplemented pthread_once with the same form >- as described by A.Terekhov (later version 2); >- implementation of MCS (Mellor-Crummey/Scott) locks. >\ No newline at end of file >diff --git a/Source/WTF/wtf/OSAllocatorPosix.cpp b/Source/WTF/wtf/OSAllocatorPosix.cpp >deleted file mode 100644 >index 923a8843eeb7ad4b6584824e0e9d9c333d114ad6..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/OSAllocatorPosix.cpp >+++ /dev/null >@@ -1,186 +0,0 @@ >-/* >- * Copyright (C) 2010 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. 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 INC. 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. >- */ >- >-#include "config.h" >-#include <wtf/OSAllocator.h> >- >-#if OS(UNIX) >- >-#include <errno.h> >-#include <sys/mman.h> >-#include <wtf/Assertions.h> >-#include <wtf/PageAllocation.h> >- >-namespace WTF { >- >-void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >-{ >-#if OS(LINUX) >- UNUSED_PARAM(usage); >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >- UNUSED_PARAM(includesGuardPages); >- >- void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0); >- if (result == MAP_FAILED) >- CRASH(); >- madvise(result, bytes, MADV_DONTNEED); >-#else >- void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); >-#if HAVE(MADV_FREE_REUSE) >- if (result) { >- // To support the "reserve then commit" model, we have to initially decommit. >- while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >- } >-#endif >- >-#endif >- >- return result; >-} >- >-void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >-{ >- // All POSIX reservations start out logically committed. >- int protection = PROT_READ; >- if (writable) >- protection |= PROT_WRITE; >- if (executable) >- protection |= PROT_EXEC; >- >- int flags = MAP_PRIVATE | MAP_ANON; >-#if OS(DARWIN) >- if (executable) >- flags |= MAP_JIT; >-#endif >- >-#if OS(DARWIN) >- int fd = usage; >-#else >- UNUSED_PARAM(usage); >- int fd = -1; >-#endif >- >- void* result = 0; >-#if (OS(DARWIN) && CPU(X86_64)) >- if (executable) { >- ASSERT(includesGuardPages); >- // Cook up an address to allocate at, using the following recipe: >- // 17 bits of zero, stay in userspace kids. >- // 26 bits of randomness for ASLR. >- // 21 bits of zero, at least stay aligned within one level of the pagetables. >- // >- // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854), >- // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus >- // 2^24, which should put up somewhere in the middle of userspace (in the address range >- // 0x200000000000 .. 0x5fffffffffff). >- intptr_t randomLocation = 0; >- randomLocation = arc4random() & ((1 << 25) - 1); >- randomLocation += (1 << 24); >- randomLocation <<= 21; >- result = reinterpret_cast<void*>(randomLocation); >- } >-#endif >- >- result = mmap(result, bytes, protection, flags, fd, 0); >- if (result == MAP_FAILED) { >- if (executable) >- result = 0; >- else >- CRASH(); >- } >- if (result && includesGuardPages) { >- // We use mmap to remap the guardpages rather than using mprotect as >- // mprotect results in multiple references to the code region. This >- // breaks the madvise based mechanism we use to return physical memory >- // to the OS. >- mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >- mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >- } >- return result; >-} >- >-void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >-{ >-#if OS(LINUX) >- int protection = PROT_READ; >- if (writable) >- protection |= PROT_WRITE; >- if (executable) >- protection |= PROT_EXEC; >- if (mprotect(address, bytes, protection)) >- CRASH(); >- madvise(address, bytes, MADV_WILLNEED); >-#elif HAVE(MADV_FREE_REUSE) >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >- while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } >-#else >- // Non-MADV_FREE_REUSE reservations automatically commit on demand. >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >- UNUSED_PARAM(writable); >- UNUSED_PARAM(executable); >-#endif >-} >- >-void OSAllocator::decommit(void* address, size_t bytes) >-{ >-#if OS(LINUX) >- madvise(address, bytes, MADV_DONTNEED); >- if (mprotect(address, bytes, PROT_NONE)) >- CRASH(); >-#elif HAVE(MADV_FREE_REUSE) >- while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >-#elif HAVE(MADV_FREE) >- while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { } >-#elif HAVE(MADV_DONTNEED) >- while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >-#else >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >-#endif >-} >- >-void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) >-{ >-#if HAVE(MADV_DONTNEED) >- while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >-#else >- UNUSED_PARAM(address); >- UNUSED_PARAM(bytes); >-#endif >-} >- >-void OSAllocator::releaseDecommitted(void* address, size_t bytes) >-{ >- int result = munmap(address, bytes); >- if (result == -1) >- CRASH(); >-} >- >-} // namespace WTF >- >-#endif // OS(UNIX) >diff --git a/Source/WTF/wtf/OSAllocatorWin.cpp b/Source/WTF/wtf/OSAllocatorWin.cpp >deleted file mode 100644 >index d615498c994fca5d8b51954c5f652543a97c4b74..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/OSAllocatorWin.cpp >+++ /dev/null >@@ -1,102 +0,0 @@ >-/* >- * Copyright (C) 2010, 2014 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. 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 INC. 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. >- */ >- >-#include "config.h" >-#include <wtf/OSAllocator.h> >- >-#if OS(WINDOWS) >- >-#include <wtf/Assertions.h> >-#include <windows.h> >- >-namespace WTF { >- >-static inline DWORD protection(bool writable, bool executable) >-{ >- return executable ? >- (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) : >- (writable ? PAGE_READWRITE : PAGE_READONLY); >-} >- >-void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool executable, bool) >-{ >- void* result = VirtualAlloc(0, bytes, MEM_RESERVE, protection(writable, executable)); >- if (!result) >- CRASH(); >- return result; >-} >- >-void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool) >-{ >- void* result = VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, protection(writable, executable)); >- if (!result) >- CRASH(); >- return result; >-} >- >-void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >-{ >- void* result = VirtualAlloc(address, bytes, MEM_COMMIT, protection(writable, executable)); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::decommit(void* address, size_t bytes) >-{ >- // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >- // bytes (i.e. dwSize) being 0 when dwFreeType is MEM_DECOMMIT means that we'll >- // decommit the entire region allocated by VirtualAlloc() instead of decommitting >- // nothing as we would expect. Hence, we should check if bytes is 0 and handle it >- // appropriately before calling VirtualFree(). >- // See: https://bugs.webkit.org/show_bug.cgi?id=121972. >- if (!bytes) >- return; >- // Silence warning about using MEM_DECOMMIT instead of MEM_RELEASE: >-#pragma warning(suppress: 6250) >- bool result = VirtualFree(address, bytes, MEM_DECOMMIT); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::releaseDecommitted(void* address, size_t bytes) >-{ >- // See comment in OSAllocator::decommit(). Similarly, when bytes is 0, we >- // don't want to release anything. So, don't call VirtualFree() below. >- if (!bytes) >- return; >- // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >- // dwSize must be 0 if dwFreeType is MEM_RELEASE. >- bool result = VirtualFree(address, 0, MEM_RELEASE); >- if (!result) >- CRASH(); >-} >- >-void OSAllocator::hintMemoryNotNeededSoon(void*, size_t) >-{ >-} >- >-} // namespace WTF >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/PlatformGTK.cmake b/Source/WTF/wtf/PlatformGTK.cmake >index 7fec12dc2fc315bc5168f02b3bf76470c0d9cbad..eb6117ed027dabed279c2c5d8dcac83f675a0aba 100644 >--- a/Source/WTF/wtf/PlatformGTK.cmake >+++ b/Source/WTF/wtf/PlatformGTK.cmake >@@ -17,6 +17,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") > endif () > > list(APPEND WTF_SOURCES >+ ThreadingPthreads.cpp > UniStdExtras.cpp > > generic/MainThreadGeneric.cpp >@@ -28,6 +29,8 @@ list(APPEND WTF_SOURCES > glib/RunLoopGLib.cpp > glib/URLGLib.cpp > >+ posix/OSAllocatorPOSIX.cpp >+ > text/unix/TextBreakIteratorInternalICUUnix.cpp > > unix/CPUTimeUnix.cpp >diff --git a/Source/WTF/wtf/PlatformJSCOnly.cmake b/Source/WTF/wtf/PlatformJSCOnly.cmake >index ebaf6ba7a3f4b876b3b43835480f78d6713907f8..be6c141379607e9b33b0c0682ec97e5041a26e9a 100644 >--- a/Source/WTF/wtf/PlatformJSCOnly.cmake >+++ b/Source/WTF/wtf/PlatformJSCOnly.cmake >@@ -11,7 +11,10 @@ if (WIN32) > win/FileSystemWin.cpp > win/LanguageWin.cpp > win/MainThreadWin.cpp >+ win/OSAllocatorWin.cpp > win/PathWalker.cpp >+ win/ThreadSpecificWin.cpp >+ win/ThreadingWin.cpp > ) > list(APPEND WTF_PUBLIC_HEADERS > win/DbgHelperWin.h >@@ -20,15 +23,19 @@ if (WIN32) > text/win/WCharStringExtras.h > ) > list(APPEND WTF_LIBRARIES >+ DbgHelp > shlwapi >+ winmm > ) > else () > list(APPEND WTF_SOURCES >+ ThreadingPthreads.cpp > UniStdExtras.cpp > > generic/MainThreadGeneric.cpp > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp > > text/unix/TextBreakIteratorInternalICUUnix.cpp > >diff --git a/Source/WTF/wtf/PlatformMac.cmake b/Source/WTF/wtf/PlatformMac.cmake >index 0e3e14160912b78617734350a925d99dba2cda01..d1ecead4ee2d3d3a795dbe5bc3ec165c16e3729a 100644 >--- a/Source/WTF/wtf/PlatformMac.cmake >+++ b/Source/WTF/wtf/PlatformMac.cmake >@@ -38,15 +38,15 @@ list(APPEND WTF_PUBLIC_HEADERS > ) > > list(APPEND WTF_SOURCES >+ ThreadingPthreads.cpp > BlockObjCExceptions.mm >- RunLoopTimerCF.cpp >- SchedulePairCF.cpp >- SchedulePairMac.mm > > cf/CFURLExtras.cpp > cf/FileSystemCF.cpp > cf/LanguageCF.cpp > cf/RunLoopCF.cpp >+ cf/RunLoopTimerCF.cpp >+ cf/SchedulePairCF.cpp > cf/URLCF.cpp > > cocoa/AutodrainedPool.cpp >@@ -63,8 +63,10 @@ list(APPEND WTF_SOURCES > > mac/DeprecatedSymbolsUsedBySafari.mm > mac/FileSystemMac.mm >+ mac/SchedulePairMac.mm > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp > > text/cf/AtomicStringImplCF.cpp > text/cf/StringCF.cpp >diff --git a/Source/WTF/wtf/PlatformPlayStation.cmake b/Source/WTF/wtf/PlatformPlayStation.cmake >index 3e9e75c928a6c94605b4bfcaa7fbb2b9f42f8390..822b091c62459ccdc66e2836fe243a975edd96e7 100644 >--- a/Source/WTF/wtf/PlatformPlayStation.cmake >+++ b/Source/WTF/wtf/PlatformPlayStation.cmake >@@ -1,4 +1,6 @@ > list(APPEND WTF_SOURCES >+ ThreadingPthreads.cpp >+ > generic/MainThreadGeneric.cpp > generic/MemoryFootprintGeneric.cpp > generic/MemoryPressureHandlerGeneric.cpp >@@ -6,6 +8,7 @@ list(APPEND WTF_SOURCES > generic/WorkQueueGeneric.cpp > > posix/FileSystemPOSIX.cpp >+ posix/OSAllocatorPOSIX.cpp > > text/unix/TextBreakIteratorInternalICUUnix.cpp > >diff --git a/Source/WTF/wtf/PlatformWPE.cmake b/Source/WTF/wtf/PlatformWPE.cmake >index 086add3aa919fc49239d71c1cc8685c5fc739bd4..31dfc58f79457eb2a4a2e4e7992b1a05a97f0939 100644 >--- a/Source/WTF/wtf/PlatformWPE.cmake >+++ b/Source/WTF/wtf/PlatformWPE.cmake >@@ -11,6 +11,7 @@ list(APPEND WTF_PUBLIC_HEADERS > ) > > list(APPEND WTF_SOURCES >+ ThreadingPthreads.cpp > UniStdExtras.cpp > > generic/MainThreadGeneric.cpp >@@ -26,6 +27,8 @@ list(APPEND WTF_SOURCES > linux/MemoryFootprintLinux.cpp > linux/MemoryPressureHandlerLinux.cpp > >+ posix/OSAllocatorPOSIX.cpp >+ > text/unix/TextBreakIteratorInternalICUUnix.cpp > > unix/CPUTimeUnix.cpp >diff --git a/Source/WTF/wtf/PlatformWin.cmake b/Source/WTF/wtf/PlatformWin.cmake >index b6c0ac6f4de5e05f27d4d9ac0ffbd5cc4097a6e3..2c34022549d8840eb9230284a1ddd9d285239aae 100644 >--- a/Source/WTF/wtf/PlatformWin.cmake >+++ b/Source/WTF/wtf/PlatformWin.cmake >@@ -17,13 +17,18 @@ list(APPEND WTF_SOURCES > win/MainThreadWin.cpp > win/MemoryFootprintWin.cpp > win/MemoryPressureHandlerWin.cpp >+ win/OSAllocatorWin.cpp > win/PathWalker.cpp > win/RunLoopWin.cpp >+ win/ThreadSpecificWin.cpp >+ win/ThreadingWin.cpp > win/WorkQueueWin.cpp > ) > > list(APPEND WTF_LIBRARIES >+ DbgHelp > shlwapi >+ winmm > ) > > if (USE_CF) >diff --git a/Source/WTF/wtf/RunLoopTimerCF.cpp b/Source/WTF/wtf/RunLoopTimerCF.cpp >deleted file mode 100644 >index 7418fdd3ea27dbf8940502e90d9143b528352a85..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/RunLoopTimerCF.cpp >+++ /dev/null >@@ -1,92 +0,0 @@ >-/* >- * Copyright (C) 2009, 2013 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. >- * 3. Neither the name of Apple 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. >- */ >- >-#include "config.h" >- >-#if PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >- >-#include <wtf/RunLoopTimer.h> >- >-#include <wtf/AutodrainedPool.h> >- >-namespace WTF { >- >-RunLoopTimerBase::~RunLoopTimerBase() >-{ >- stop(); >-} >- >-static void timerFired(CFRunLoopTimerRef, void* context) >-{ >- // CFRunLoopTimer does not create an NSAutoreleasePool, like NSTimer does. This can lead to >- // autoreleased objects being pushed into NSAutoreleasePools underneath the run loop, which >- // are very infrequently drained. Create a new autorelease pool here to give autoreleased objects >- // a place to collect. >- AutodrainedPool pool; >- RunLoopTimerBase* timer = static_cast<RunLoopTimerBase*>(context); >- timer->fired(); >-} >- >-void RunLoopTimerBase::start(Seconds nextFireInterval, Seconds repeatInterval) >-{ >- if (m_timer) >- CFRunLoopTimerInvalidate(m_timer.get()); >- CFRunLoopTimerContext context = { 0, this, 0, 0, 0 }; >- m_timer = adoptCF(CFRunLoopTimerCreate(0, CFAbsoluteTimeGetCurrent() + nextFireInterval.seconds(), repeatInterval.seconds(), 0, 0, timerFired, &context)); >-} >- >-void RunLoopTimerBase::schedule(const SchedulePair* schedulePair) >-{ >- ASSERT_ARG(schedulePair, schedulePair); >- ASSERT_WITH_MESSAGE(m_timer, "Timer must have one of the start functions called before calling schedule()."); >- CFRunLoopAddTimer(schedulePair->runLoop(), m_timer.get(), schedulePair->mode()); >-} >- >-void RunLoopTimerBase::schedule(const SchedulePairHashSet& schedulePairs) >-{ >- SchedulePairHashSet::const_iterator end = schedulePairs.end(); >- for (SchedulePairHashSet::const_iterator it = schedulePairs.begin(); it != end; ++it) >- schedule((*it).get()); >-} >- >-void RunLoopTimerBase::stop() >-{ >- if (!m_timer) >- return; >- CFRunLoopTimerInvalidate(m_timer.get()); >- m_timer = 0; >-} >- >-bool RunLoopTimerBase::isActive() const >-{ >- return m_timer && CFRunLoopTimerIsValid(m_timer.get()); >-} >- >-} // namespace WTF >- >-#endif // PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >diff --git a/Source/WTF/wtf/SchedulePairCF.cpp b/Source/WTF/wtf/SchedulePairCF.cpp >deleted file mode 100644 >index 46f65c33f00b7da152f80e5268f04730135cca35..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/SchedulePairCF.cpp >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* >- * Copyright (C) 2008, 2013 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. >- * 3. Neither the name of Apple 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. >- */ >- >-#include "config.h" >-#include <wtf/SchedulePair.h> >- >-namespace WTF { >- >-bool SchedulePair::operator==(const SchedulePair& other) const >-{ >- if (runLoop() != other.runLoop()) >- return false; >- CFStringRef thisMode = mode(); >- CFStringRef otherMode = other.mode(); >- if (!thisMode || !otherMode) >- return thisMode == otherMode; >- return CFEqual(thisMode, otherMode); >-} >- >-} // namespace >diff --git a/Source/WTF/wtf/SchedulePairMac.mm b/Source/WTF/wtf/SchedulePairMac.mm >deleted file mode 100644 >index 62261ad3f9d6a661203bdb1416c318eb2e4ee77a..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/SchedulePairMac.mm >+++ /dev/null >@@ -1,42 +0,0 @@ >-/* >- * Copyright (C) 2008, 2013 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. >- * 3. Neither the name of Apple 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. >- */ >- >-#include "config.h" >-#include <wtf/SchedulePair.h> >- >-namespace WTF { >- >-SchedulePair::SchedulePair(NSRunLoop* runLoop, CFStringRef mode) >- : m_nsRunLoop(runLoop) >- , m_runLoop([runLoop getCFRunLoop]) >-{ >- if (mode) >- m_mode = adoptCF(CFStringCreateCopy(0, mode)); >-} >- >-} // namespace >diff --git a/Source/WTF/wtf/ThreadSpecificWin.cpp b/Source/WTF/wtf/ThreadSpecificWin.cpp >deleted file mode 100644 >index ae7ae847cbabfc40362872ca3606dbfa09127fde..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/ThreadSpecificWin.cpp >+++ /dev/null >@@ -1,47 +0,0 @@ >-/* >- * Copyright (C) 2009 Jian Li <jianli@chromium.org> >- * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Library 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 >- * Library General Public License for more details. >- * >- * You should have received a copy of the GNU Library General Public License >- * along with this library; see the file COPYING.LIB. If not, write to >- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >- * Boston, MA 02110-1301, USA. >- * >- */ >- >-#include "config.h" >-#include <wtf/ThreadSpecific.h> >- >-#if OS(WINDOWS) >- >-#if !USE(PTHREADS) >- >-namespace WTF { >- >-long& flsKeyCount() >-{ >- static long count; >- return count; >-} >- >-DWORD* flsKeys() >-{ >- static DWORD keys[kMaxFlsKeySize]; >- return keys; >-} >- >-} // namespace WTF >- >-#endif // !USE(PTHREADS) >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/ThreadingWin.cpp b/Source/WTF/wtf/ThreadingWin.cpp >deleted file mode 100644 >index 10d46ac8ad8c9471a933ac7816298705071a2e02..0000000000000000000000000000000000000000 >--- a/Source/WTF/wtf/ThreadingWin.cpp >+++ /dev/null >@@ -1,464 +0,0 @@ >-/* >- * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. >- * Copyright (C) 2009 Google Inc. All rights reserved. >- * Copyright (C) 2009 Torch Mobile, 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. >- * 3. Neither the name of Apple 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. >- */ >- >-/* >- * There are numerous academic and practical works on how to implement pthread_cond_wait/pthread_cond_signal/pthread_cond_broadcast >- * functions on Win32. Here is one example: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html which is widely credited as a 'starting point' >- * of modern attempts. There are several more or less proven implementations, one in Boost C++ library (http://www.boost.org) and another >- * in pthreads-win32 (http://sourceware.org/pthreads-win32/). >- * >- * The number of articles and discussions is the evidence of significant difficulties in implementing these primitives correctly. >- * The brief search of revisions, ChangeLog entries, discussions in comp.programming.threads and other places clearly documents >- * numerous pitfalls and performance problems the authors had to overcome to arrive to the suitable implementations. >- * Optimally, WebKit would use one of those supported/tested libraries directly. To roll out our own implementation is impractical, >- * if even for the lack of sufficient testing. However, a faithful reproduction of the code from one of the popular supported >- * libraries seems to be a good compromise. >- * >- * The early Boost implementation (http://www.boxbackup.org/trac/browser/box/nick/win/lib/win32/boost_1_32_0/libs/thread/src/condition.cpp?rev=30) >- * is identical to pthreads-win32 (http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32). >- * Current Boost uses yet another (although seemingly equivalent) algorithm which came from their 'thread rewrite' effort. >- * >- * This file includes timedWait/signal/broadcast implementations translated to WebKit coding style from the latest algorithm by >- * Alexander Terekhov and Louis Thomas, as captured here: http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32 >- * It replaces the implementation of their previous algorithm, also documented in the same source above. >- * The naming and comments are left very close to original to enable easy cross-check. >- * >- * The corresponding Pthreads-win32 License is included below, and CONTRIBUTORS file which it refers to is added to >- * source directory (as CONTRIBUTORS.pthreads-win32). >- */ >- >-/* >- * Pthreads-win32 - POSIX Threads Library for Win32 >- * Copyright(C) 1998 John E. Bossom >- * Copyright(C) 1999,2005 Pthreads-win32 contributors >- * >- * Contact Email: rpj@callisto.canberra.edu.au >- * >- * The current list of contributors is contained >- * in the file CONTRIBUTORS included with the source >- * code distribution. The list can also be seen at the >- * following World Wide Web location: >- * http://sources.redhat.com/pthreads-win32/contributors.html >- * >- * 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 in the file COPYING.LIB; >- * if not, write to the Free Software Foundation, Inc., >- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA >- */ >- >-#include "config.h" >-#include <wtf/Threading.h> >- >-#if OS(WINDOWS) >- >-#include <errno.h> >-#include <process.h> >-#include <windows.h> >-#include <wtf/HashMap.h> >-#include <wtf/Lock.h> >-#include <wtf/MainThread.h> >-#include <wtf/MathExtras.h> >-#include <wtf/NeverDestroyed.h> >-#include <wtf/ThreadingPrimitives.h> >- >-namespace WTF { >- >-static Lock globalSuspendLock; >- >-Thread::~Thread() >-{ >- // It is OK because FLSAlloc's callback will be called even before there are some open handles. >- // This easily ensures that all the thread resources are automatically closed. >- if (m_handle != INVALID_HANDLE_VALUE) >- CloseHandle(m_handle); >-} >- >-void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >-{ >-} >- >-// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. >-static const DWORD MS_VC_EXCEPTION = 0x406D1388; >- >-#pragma pack(push, 8) >-typedef struct tagTHREADNAME_INFO { >- DWORD dwType; // must be 0x1000 >- LPCSTR szName; // pointer to name (in user addr space) >- DWORD dwThreadID; // thread ID (-1=caller thread) >- DWORD dwFlags; // reserved for future use, must be zero >-} THREADNAME_INFO; >-#pragma pack(pop) >- >-void Thread::initializeCurrentThreadInternal(const char* szThreadName) >-{ >-#if COMPILER(MINGW) >- // FIXME: Implement thread name setting with MingW. >- UNUSED_PARAM(szThreadName); >-#else >- THREADNAME_INFO info; >- info.dwType = 0x1000; >- info.szName = Thread::normalizeThreadName(szThreadName); >- info.dwThreadID = GetCurrentThreadId(); >- info.dwFlags = 0; >- >- __try { >- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), reinterpret_cast<ULONG_PTR*>(&info)); >- } __except (EXCEPTION_CONTINUE_EXECUTION) { >- } >-#endif >- initializeCurrentThreadEvenIfNonWTFCreated(); >-} >- >-void Thread::initializePlatformThreading() >-{ >-} >- >-static unsigned __stdcall wtfThreadEntryPoint(void* data) >-{ >- Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(data)); >- return 0; >-} >- >-bool Thread::establishHandle(NewThreadContext* data) >-{ >- unsigned threadIdentifier = 0; >- HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, data, 0, &threadIdentifier)); >- if (!threadHandle) { >- LOG_ERROR("Failed to create thread at entry point %p with data %p: %ld", wtfThreadEntryPoint, data, errno); >- return false; >- } >- establishPlatformSpecificHandle(threadHandle, threadIdentifier); >- return true; >-} >- >-void Thread::changePriority(int delta) >-{ >- auto locker = holdLock(m_mutex); >- SetThreadPriority(m_handle, THREAD_PRIORITY_NORMAL + delta); >-} >- >-int Thread::waitForCompletion() >-{ >- HANDLE handle; >- { >- auto locker = holdLock(m_mutex); >- handle = m_handle; >- } >- >- DWORD joinResult = WaitForSingleObject(handle, INFINITE); >- if (joinResult == WAIT_FAILED) >- LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >- >- auto locker = holdLock(m_mutex); >- ASSERT(joinableState() == Joinable); >- >- // The thread has already exited, do nothing. >- // The thread hasn't exited yet, so don't clean anything up. Just signal that we've already joined on it so that it will clean up after itself. >- if (!hasExited()) >- didJoin(); >- >- return joinResult; >-} >- >-void Thread::detach() >-{ >- // We follow the pthread semantics: even after the detach is called, >- // we can still perform various operations onto the thread. For example, >- // we can do pthread_kill for the detached thread. The problem in Windows >- // is that closing HANDLE loses the way to do such operations. >- // To do so, we do nothing here in Windows. Original detach's purpose, >- // releasing thread resource when the thread exits, will be achieved by >- // FlsCallback automatically. FlsCallback will call CloseHandle to clean up >- // resource. So in this function, we just mark the thread as detached to >- // avoid calling waitForCompletion for this thread. >- auto locker = holdLock(m_mutex); >- if (!hasExited()) >- didBecomeDetached(); >-} >- >-auto Thread::suspend() -> Expected<void, PlatformSuspendError> >-{ >- RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >- LockHolder locker(globalSuspendLock); >- DWORD result = SuspendThread(m_handle); >- if (result != (DWORD)-1) >- return { }; >- return makeUnexpected(result); >-} >- >-// During resume, suspend or resume should not be executed from the other threads. >-void Thread::resume() >-{ >- LockHolder locker(globalSuspendLock); >- ResumeThread(m_handle); >-} >- >-size_t Thread::getRegisters(PlatformRegisters& registers) >-{ >- LockHolder locker(globalSuspendLock); >- registers.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; >- GetThreadContext(m_handle, ®isters); >- return sizeof(CONTEXT); >-} >- >-Thread& Thread::initializeCurrentTLS() >-{ >- // Not a WTF-created thread, ThreadIdentifier is not established yet. >- Ref<Thread> thread = adoptRef(*new Thread()); >- >- HANDLE handle; >- bool isSuccessful = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS); >- RELEASE_ASSERT(isSuccessful); >- >- thread->establishPlatformSpecificHandle(handle, currentID()); >- thread->initializeInThread(); >- initializeCurrentThreadEvenIfNonWTFCreated(); >- >- return initializeTLS(WTFMove(thread)); >-} >- >-ThreadIdentifier Thread::currentID() >-{ >- return static_cast<ThreadIdentifier>(GetCurrentThreadId()); >-} >- >-void Thread::establishPlatformSpecificHandle(HANDLE handle, ThreadIdentifier threadID) >-{ >- auto locker = holdLock(m_mutex); >- m_handle = handle; >- m_id = threadID; >-} >- >-#define InvalidThread reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef)) >- >-static WordLock threadMapMutex; >- >-static HashMap<ThreadIdentifier, Thread*>& threadMap() >-{ >- static NeverDestroyed<HashMap<ThreadIdentifier, Thread*>> map; >- return map.get(); >-} >- >-void Thread::initializeTLSKey() >-{ >- threadMap(); >- threadSpecificKeyCreate(&s_key, destructTLS); >-} >- >-Thread* Thread::currentDying() >-{ >- ASSERT(s_key != InvalidThreadSpecificKey); >- // After FLS is destroyed, this map offers the value until the second thread exit callback is called. >- auto locker = holdLock(threadMapMutex); >- return threadMap().get(currentID()); >-} >- >-// FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >-RefPtr<Thread> Thread::get(ThreadIdentifier id) >-{ >- auto locker = holdLock(threadMapMutex); >- Thread* thread = threadMap().get(id); >- if (thread) >- return thread; >- return nullptr; >-} >- >-Thread& Thread::initializeTLS(Ref<Thread>&& thread) >-{ >- ASSERT(s_key != InvalidThreadSpecificKey); >- // FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >- auto id = thread->id(); >- // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >- auto& threadInTLS = thread.leakRef(); >- threadSpecificSet(s_key, &threadInTLS); >- { >- auto locker = holdLock(threadMapMutex); >- threadMap().add(id, &threadInTLS); >- } >- return threadInTLS; >-} >- >-void Thread::destructTLS(void* data) >-{ >- if (data == InvalidThread) >- return; >- >- Thread* thread = static_cast<Thread*>(data); >- ASSERT(thread); >- >- // Delay the deallocation of Thread more. >- // It defers Thread deallocation after the other ThreadSpecific values are deallocated. >- static thread_local class ThreadExitCallback { >- public: >- ThreadExitCallback(Thread* thread) >- : m_thread(thread) >- { >- } >- >- ~ThreadExitCallback() >- { >- Thread::destructTLS(m_thread); >- } >- >- private: >- Thread* m_thread; >- } callback(thread); >- >- if (thread->m_isDestroyedOnce) { >- { >- auto locker = holdLock(threadMapMutex); >- ASSERT(threadMap().contains(thread->id())); >- threadMap().remove(thread->id()); >- } >- thread->didExit(); >- thread->deref(); >- >- // Fill the FLS with the non-nullptr value. While FLS destructor won't be called for that, >- // non-nullptr value tells us that we already destructed Thread. This allows us to >- // detect incorrect use of Thread::current() after this point because it will crash. >- threadSpecificSet(s_key, InvalidThread); >- return; >- } >- threadSpecificSet(s_key, InvalidThread); >- thread->m_isDestroyedOnce = true; >-} >- >-Mutex::~Mutex() >-{ >-} >- >-void Mutex::lock() >-{ >- AcquireSRWLockExclusive(&m_mutex); >-} >- >-bool Mutex::tryLock() >-{ >- return TryAcquireSRWLockExclusive(&m_mutex); >-} >- >-void Mutex::unlock() >-{ >- ReleaseSRWLockExclusive(&m_mutex); >-} >- >-// Returns an interval in milliseconds suitable for passing to one of the Win32 wait functions (e.g., ::WaitForSingleObject). >-static DWORD absoluteTimeToWaitTimeoutInterval(WallTime absoluteTime) >-{ >- WallTime currentTime = WallTime::now(); >- >- // Time is in the past - return immediately. >- if (absoluteTime < currentTime) >- return 0; >- >- // Time is too far in the future (and would overflow unsigned long) - wait forever. >- if ((absoluteTime - currentTime) > Seconds::fromMilliseconds(INT_MAX)) >- return INFINITE; >- >- return static_cast<DWORD>((absoluteTime - currentTime).milliseconds()); >-} >- >-ThreadCondition::~ThreadCondition() >-{ >-} >- >-void ThreadCondition::wait(Mutex& mutex) >-{ >- SleepConditionVariableSRW(&m_condition, &mutex.impl(), INFINITE, 0); >-} >- >-bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >-{ >- // https://msdn.microsoft.com/en-us/library/windows/desktop/ms686304(v=vs.85).aspx >- DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); >- if (!interval) { >- // Consider the wait to have timed out, even if our condition has already been signaled, to >- // match the pthreads implementation. >- return false; >- } >- >- if (SleepConditionVariableSRW(&m_condition, &mutex.impl(), interval, 0)) >- return true; >- ASSERT(GetLastError() == ERROR_TIMEOUT); >- return false; >-} >- >-void ThreadCondition::signal() >-{ >- WakeConditionVariable(&m_condition); >-} >- >-void ThreadCondition::broadcast() >-{ >- WakeAllConditionVariable(&m_condition); >-} >- >-// Remove this workaround code when <rdar://problem/31793213> is fixed. >-ThreadIdentifier createThread(ThreadFunction function, void* data, const char* threadName) >-{ >- return Thread::create(threadName, [function, data] { >- function(data); >- })->id(); >-} >- >-int waitForThreadCompletion(ThreadIdentifier threadID) >-{ >- // This function is implemented based on the old Threading implementation. >- // It remains only due to the support library using old Threading APIs and >- // it should not be used in new code. >- ASSERT(threadID); >- >- RefPtr<Thread> thread = Thread::get(threadID); >- if (!thread) { >- LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID); >- return WAIT_FAILED; >- } >- return thread->waitForCompletion(); >- >-} >- >-void Thread::yield() >-{ >- SwitchToThread(); >-} >- >-} // namespace WTF >- >-#endif // OS(WINDOWS) >diff --git a/Source/WTF/wtf/cf/RunLoopTimerCF.cpp b/Source/WTF/wtf/cf/RunLoopTimerCF.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7418fdd3ea27dbf8940502e90d9143b528352a85 >--- /dev/null >+++ b/Source/WTF/wtf/cf/RunLoopTimerCF.cpp >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2009, 2013 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. >+ * 3. Neither the name of Apple 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. >+ */ >+ >+#include "config.h" >+ >+#if PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >+ >+#include <wtf/RunLoopTimer.h> >+ >+#include <wtf/AutodrainedPool.h> >+ >+namespace WTF { >+ >+RunLoopTimerBase::~RunLoopTimerBase() >+{ >+ stop(); >+} >+ >+static void timerFired(CFRunLoopTimerRef, void* context) >+{ >+ // CFRunLoopTimer does not create an NSAutoreleasePool, like NSTimer does. This can lead to >+ // autoreleased objects being pushed into NSAutoreleasePools underneath the run loop, which >+ // are very infrequently drained. Create a new autorelease pool here to give autoreleased objects >+ // a place to collect. >+ AutodrainedPool pool; >+ RunLoopTimerBase* timer = static_cast<RunLoopTimerBase*>(context); >+ timer->fired(); >+} >+ >+void RunLoopTimerBase::start(Seconds nextFireInterval, Seconds repeatInterval) >+{ >+ if (m_timer) >+ CFRunLoopTimerInvalidate(m_timer.get()); >+ CFRunLoopTimerContext context = { 0, this, 0, 0, 0 }; >+ m_timer = adoptCF(CFRunLoopTimerCreate(0, CFAbsoluteTimeGetCurrent() + nextFireInterval.seconds(), repeatInterval.seconds(), 0, 0, timerFired, &context)); >+} >+ >+void RunLoopTimerBase::schedule(const SchedulePair* schedulePair) >+{ >+ ASSERT_ARG(schedulePair, schedulePair); >+ ASSERT_WITH_MESSAGE(m_timer, "Timer must have one of the start functions called before calling schedule()."); >+ CFRunLoopAddTimer(schedulePair->runLoop(), m_timer.get(), schedulePair->mode()); >+} >+ >+void RunLoopTimerBase::schedule(const SchedulePairHashSet& schedulePairs) >+{ >+ SchedulePairHashSet::const_iterator end = schedulePairs.end(); >+ for (SchedulePairHashSet::const_iterator it = schedulePairs.begin(); it != end; ++it) >+ schedule((*it).get()); >+} >+ >+void RunLoopTimerBase::stop() >+{ >+ if (!m_timer) >+ return; >+ CFRunLoopTimerInvalidate(m_timer.get()); >+ m_timer = 0; >+} >+ >+bool RunLoopTimerBase::isActive() const >+{ >+ return m_timer && CFRunLoopTimerIsValid(m_timer.get()); >+} >+ >+} // namespace WTF >+ >+#endif // PLATFORM(COCOA) && HAVE(RUNLOOP_TIMER) >diff --git a/Source/WTF/wtf/cf/SchedulePairCF.cpp b/Source/WTF/wtf/cf/SchedulePairCF.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..46f65c33f00b7da152f80e5268f04730135cca35 >--- /dev/null >+++ b/Source/WTF/wtf/cf/SchedulePairCF.cpp >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2008, 2013 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. >+ * 3. Neither the name of Apple 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. >+ */ >+ >+#include "config.h" >+#include <wtf/SchedulePair.h> >+ >+namespace WTF { >+ >+bool SchedulePair::operator==(const SchedulePair& other) const >+{ >+ if (runLoop() != other.runLoop()) >+ return false; >+ CFStringRef thisMode = mode(); >+ CFStringRef otherMode = other.mode(); >+ if (!thisMode || !otherMode) >+ return thisMode == otherMode; >+ return CFEqual(thisMode, otherMode); >+} >+ >+} // namespace >diff --git a/Source/WTF/wtf/mac/SchedulePairMac.mm b/Source/WTF/wtf/mac/SchedulePairMac.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..62261ad3f9d6a661203bdb1416c318eb2e4ee77a >--- /dev/null >+++ b/Source/WTF/wtf/mac/SchedulePairMac.mm >@@ -0,0 +1,42 @@ >+/* >+ * Copyright (C) 2008, 2013 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. >+ * 3. Neither the name of Apple 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. >+ */ >+ >+#include "config.h" >+#include <wtf/SchedulePair.h> >+ >+namespace WTF { >+ >+SchedulePair::SchedulePair(NSRunLoop* runLoop, CFStringRef mode) >+ : m_nsRunLoop(runLoop) >+ , m_runLoop([runLoop getCFRunLoop]) >+{ >+ if (mode) >+ m_mode = adoptCF(CFStringCreateCopy(0, mode)); >+} >+ >+} // namespace >diff --git a/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e011d6191bfc8483512cf676593324165c77d656 >--- /dev/null >+++ b/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp >@@ -0,0 +1,182 @@ >+/* >+ * Copyright (C) 2010 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. 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 INC. 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. >+ */ >+ >+#include "config.h" >+#include <wtf/OSAllocator.h> >+ >+#include <errno.h> >+#include <sys/mman.h> >+#include <wtf/Assertions.h> >+#include <wtf/PageAllocation.h> >+ >+namespace WTF { >+ >+void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >+{ >+#if OS(LINUX) >+ UNUSED_PARAM(usage); >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+ UNUSED_PARAM(includesGuardPages); >+ >+ void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0); >+ if (result == MAP_FAILED) >+ CRASH(); >+ madvise(result, bytes, MADV_DONTNEED); >+#else >+ void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); >+#if HAVE(MADV_FREE_REUSE) >+ if (result) { >+ // To support the "reserve then commit" model, we have to initially decommit. >+ while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >+ } >+#endif >+ >+#endif >+ >+ return result; >+} >+ >+void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) >+{ >+ // All POSIX reservations start out logically committed. >+ int protection = PROT_READ; >+ if (writable) >+ protection |= PROT_WRITE; >+ if (executable) >+ protection |= PROT_EXEC; >+ >+ int flags = MAP_PRIVATE | MAP_ANON; >+#if OS(DARWIN) >+ if (executable) >+ flags |= MAP_JIT; >+#endif >+ >+#if OS(DARWIN) >+ int fd = usage; >+#else >+ UNUSED_PARAM(usage); >+ int fd = -1; >+#endif >+ >+ void* result = 0; >+#if (OS(DARWIN) && CPU(X86_64)) >+ if (executable) { >+ ASSERT(includesGuardPages); >+ // Cook up an address to allocate at, using the following recipe: >+ // 17 bits of zero, stay in userspace kids. >+ // 26 bits of randomness for ASLR. >+ // 21 bits of zero, at least stay aligned within one level of the pagetables. >+ // >+ // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854), >+ // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus >+ // 2^24, which should put up somewhere in the middle of userspace (in the address range >+ // 0x200000000000 .. 0x5fffffffffff). >+ intptr_t randomLocation = 0; >+ randomLocation = arc4random() & ((1 << 25) - 1); >+ randomLocation += (1 << 24); >+ randomLocation <<= 21; >+ result = reinterpret_cast<void*>(randomLocation); >+ } >+#endif >+ >+ result = mmap(result, bytes, protection, flags, fd, 0); >+ if (result == MAP_FAILED) { >+ if (executable) >+ result = 0; >+ else >+ CRASH(); >+ } >+ if (result && includesGuardPages) { >+ // We use mmap to remap the guardpages rather than using mprotect as >+ // mprotect results in multiple references to the code region. This >+ // breaks the madvise based mechanism we use to return physical memory >+ // to the OS. >+ mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >+ mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0); >+ } >+ return result; >+} >+ >+void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >+{ >+#if OS(LINUX) >+ int protection = PROT_READ; >+ if (writable) >+ protection |= PROT_WRITE; >+ if (executable) >+ protection |= PROT_EXEC; >+ if (mprotect(address, bytes, protection)) >+ CRASH(); >+ madvise(address, bytes, MADV_WILLNEED); >+#elif HAVE(MADV_FREE_REUSE) >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+ while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } >+#else >+ // Non-MADV_FREE_REUSE reservations automatically commit on demand. >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+ UNUSED_PARAM(writable); >+ UNUSED_PARAM(executable); >+#endif >+} >+ >+void OSAllocator::decommit(void* address, size_t bytes) >+{ >+#if OS(LINUX) >+ madvise(address, bytes, MADV_DONTNEED); >+ if (mprotect(address, bytes, PROT_NONE)) >+ CRASH(); >+#elif HAVE(MADV_FREE_REUSE) >+ while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } >+#elif HAVE(MADV_FREE) >+ while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { } >+#elif HAVE(MADV_DONTNEED) >+ while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >+#else >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+#endif >+} >+ >+void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes) >+{ >+#if HAVE(MADV_DONTNEED) >+ while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } >+#else >+ UNUSED_PARAM(address); >+ UNUSED_PARAM(bytes); >+#endif >+} >+ >+void OSAllocator::releaseDecommitted(void* address, size_t bytes) >+{ >+ int result = munmap(address, bytes); >+ if (result == -1) >+ CRASH(); >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 b/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 >new file mode 100644 >index 0000000000000000000000000000000000000000..24fac006c3083e2cd73773d438a36147d09f4e02 >--- /dev/null >+++ b/Source/WTF/wtf/win/CONTRIBUTORS.pthreads-win32 >@@ -0,0 +1,137 @@ >+This is a copy of CONTRIBUTORS file for the Pthreads-win32 library, downloaded >+from http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/CONTRIBUTORS?rev=1.32&cvsroot=pthreads-win32 >+ >+Included here to compliment the Pthreads-win32 license header in ThreadingWin.cpp file. >+WebKit is using derived sources of ThreadCondition code from Pthreads-win32. >+ >+------------------------------------------------------------------------------- >+ >+Contributors (in approximate order of appearance) >+ >+[See also the ChangeLog file where individuals are >+attributed in log entries. Likewise in the FAQ file.] >+ >+Ben Elliston bje at cygnus dot com >+ Initiated the project; >+ setup the project infrastructure (CVS, web page, etc.); >+ early prototype routines. >+Ross Johnson rpj at callisto dot canberra dot edu dot au >+ early prototype routines; >+ ongoing project coordination/maintenance; >+ implementation of spin locks and barriers; >+ various enhancements; >+ bug fixes; >+ documentation; >+ testsuite. >+Robert Colquhoun rjc at trump dot net dot au >+ Early bug fixes. >+John E. Bossom John dot Bossom at cognos dot com >+ Contributed substantial original working implementation; >+ bug fixes; >+ ongoing guidance and standards interpretation. >+Anders Norlander anorland at hem2 dot passagen dot se >+ Early enhancements and runtime checking for supported >+ Win32 routines. >+Tor Lillqvist tml at iki dot fi >+ General enhancements; >+ early bug fixes to condition variables. >+Scott Lightner scott at curriculum dot com >+ Bug fix. >+Kevin Ruland Kevin dot Ruland at anheuser-busch dot com >+ Various bug fixes. >+Mike Russo miker at eai dot com >+ Bug fix. >+Mark E. Armstrong avail at pacbell dot net >+ Bug fixes. >+Lorin Hochstein lmh at xiphos dot ca >+ general bug fixes; bug fixes to condition variables. >+Peter Slacik Peter dot Slacik at tatramed dot sk >+ Bug fixes. >+Mumit Khan khan at xraylith dot wisc dot edu >+ Fixes to work with Mingw32. >+Milan Gardian mg at tatramed dot sk >+ Bug fixes and reports/analyses of obscure problems. >+Aurelio Medina aureliom at crt dot com >+ First implementation of read-write locks. >+Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au >+ Bug fix in condition variables. >+Tristan Savatier tristan at mpegtv dot com >+ WinCE port. >+Erik Hensema erik at hensema dot xs4all dot nl >+ Bug fixes. >+Rich Peters rpeters at micro-magic dot com >+Todd Owen towen at lucidcalm dot dropbear dot id dot au >+ Bug fixes to dll loading. >+Jason Nye jnye at nbnet dot nb dot ca >+ Implementation of async cancelation. >+Fred Forester fforest at eticomm dot net >+Kevin D. Clark kclark at cabletron dot com >+David Baggett dmb at itasoftware dot com >+ Bug fixes. >+Paul Redondo paul at matchvision dot com >+Scott McCaskill scott at 3dfx dot com >+ Bug fixes. >+Jef Gearhart jgearhart at tpssys dot com >+ Bug fix. >+Arthur Kantor akantor at bexusa dot com >+ Mutex enhancements. >+Steven Reddie smr at essemer dot com dot au >+ Bug fix. >+Alexander Terekhov TEREKHOV at de dot ibm dot com >+ Re-implemented and improved read-write locks; >+ (with Louis Thomas) re-implemented and improved >+ condition variables; >+ enhancements to semaphores; >+ enhancements to mutexes; >+ new mutex implementation in 'futex' style; >+ suggested a robust implementation of pthread_once >+ similar to that implemented by V.Kliathcko; >+ system clock change handling re CV timeouts; >+ bug fixes. >+Thomas Pfaff tpfaff at gmx dot net >+ Changes to make C version usable with C++ applications; >+ re-implemented mutex routines to avoid Win32 mutexes >+ and TryEnterCriticalSection; >+ procedure to fix Mingw32 thread-safety issues. >+Franco Bez franco dot bez at gmx dot de >+ procedure to fix Mingw32 thread-safety issues. >+Louis Thomas lthomas at arbitrade dot com >+ (with Alexander Terekhov) re-implemented and improved >+ condition variables. >+David Korn dgk at research dot att dot com >+ Ported to UWIN. >+Phil Frisbie, Jr. phil at hawksoft dot com >+ Bug fix. >+Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de >+ Bug fix. >+prionx at juno dot com prionx at juno dot com >+ Bug fixes. >+Max Woodbury mtew at cds dot duke dot edu >+ POSIX versioning conditionals; >+ reduced namespace pollution; >+ idea to separate routines to reduce statically >+ linked image sizes. >+Rob Fanner rfanner at stonethree dot com >+ Bug fix. >+Michael Johnson michaelj at maine dot rr dot com >+ Bug fix. >+Nicolas Barry boozai at yahoo dot com >+ Bug fixes. >+Piet van Bruggen pietvb at newbridges dot nl >+ Bug fix. >+Makoto Kato raven at oldskool dot jp >+ AMD64 port. >+Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr >+ Contributed the QueueUserAPCEx package which >+ makes preemptive async cancelation possible. >+Will Bryant will dot bryant at ecosm dot com >+ Borland compiler patch and makefile. >+Anuj Goyal anuj dot goyal at gmail dot com >+ Port to Digital Mars compiler. >+Gottlob Frege gottlobfrege at gmail dot com >+ re-implemented pthread_once (version 2) >+ (pthread_once cancellation added by rpj). >+Vladimir Kliatchko vladimir at kliatchko dot com >+ reimplemented pthread_once with the same form >+ as described by A.Terekhov (later version 2); >+ implementation of MCS (Mellor-Crummey/Scott) locks. >\ No newline at end of file >diff --git a/Source/WTF/wtf/win/OSAllocatorWin.cpp b/Source/WTF/wtf/win/OSAllocatorWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b3058133d516e2cf7feb9b693253ea04fafd704a >--- /dev/null >+++ b/Source/WTF/wtf/win/OSAllocatorWin.cpp >@@ -0,0 +1,98 @@ >+/* >+ * Copyright (C) 2010, 2014 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. 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 INC. 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. >+ */ >+ >+#include "config.h" >+#include <wtf/OSAllocator.h> >+ >+#include <windows.h> >+#include <wtf/Assertions.h> >+ >+namespace WTF { >+ >+static inline DWORD protection(bool writable, bool executable) >+{ >+ return executable ? >+ (writable ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ) : >+ (writable ? PAGE_READWRITE : PAGE_READONLY); >+} >+ >+void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool executable, bool) >+{ >+ void* result = VirtualAlloc(0, bytes, MEM_RESERVE, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+ return result; >+} >+ >+void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool) >+{ >+ void* result = VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+ return result; >+} >+ >+void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) >+{ >+ void* result = VirtualAlloc(address, bytes, MEM_COMMIT, protection(writable, executable)); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::decommit(void* address, size_t bytes) >+{ >+ // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >+ // bytes (i.e. dwSize) being 0 when dwFreeType is MEM_DECOMMIT means that we'll >+ // decommit the entire region allocated by VirtualAlloc() instead of decommitting >+ // nothing as we would expect. Hence, we should check if bytes is 0 and handle it >+ // appropriately before calling VirtualFree(). >+ // See: https://bugs.webkit.org/show_bug.cgi?id=121972. >+ if (!bytes) >+ return; >+ // Silence warning about using MEM_DECOMMIT instead of MEM_RELEASE: >+#pragma warning(suppress: 6250) >+ bool result = VirtualFree(address, bytes, MEM_DECOMMIT); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::releaseDecommitted(void* address, size_t bytes) >+{ >+ // See comment in OSAllocator::decommit(). Similarly, when bytes is 0, we >+ // don't want to release anything. So, don't call VirtualFree() below. >+ if (!bytes) >+ return; >+ // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, >+ // dwSize must be 0 if dwFreeType is MEM_RELEASE. >+ bool result = VirtualFree(address, 0, MEM_RELEASE); >+ if (!result) >+ CRASH(); >+} >+ >+void OSAllocator::hintMemoryNotNeededSoon(void*, size_t) >+{ >+} >+ >+} // namespace WTF >diff --git a/Source/WTF/wtf/win/ThreadSpecificWin.cpp b/Source/WTF/wtf/win/ThreadSpecificWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2a8ef32c0af3c6266787fa0e89449656d115001f >--- /dev/null >+++ b/Source/WTF/wtf/win/ThreadSpecificWin.cpp >@@ -0,0 +1,43 @@ >+/* >+ * Copyright (C) 2009 Jian Li <jianli@chromium.org> >+ * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> >+ * >+ * This library is free software; you can redistribute it and/or >+ * modify it under the terms of the GNU Library 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 >+ * Library General Public License for more details. >+ * >+ * You should have received a copy of the GNU Library General Public License >+ * along with this library; see the file COPYING.LIB. If not, write to >+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, >+ * Boston, MA 02110-1301, USA. >+ * >+ */ >+ >+#include "config.h" >+#include <wtf/ThreadSpecific.h> >+ >+#if !USE(PTHREADS) >+ >+namespace WTF { >+ >+long& flsKeyCount() >+{ >+ static long count; >+ return count; >+} >+ >+DWORD* flsKeys() >+{ >+ static DWORD keys[kMaxFlsKeySize]; >+ return keys; >+} >+ >+} // namespace WTF >+ >+#endif // !USE(PTHREADS) >diff --git a/Source/WTF/wtf/win/ThreadingWin.cpp b/Source/WTF/wtf/win/ThreadingWin.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d7734d94732078dd277ed8432cce9dae1c6050fc >--- /dev/null >+++ b/Source/WTF/wtf/win/ThreadingWin.cpp >@@ -0,0 +1,459 @@ >+/* >+ * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2009 Google Inc. All rights reserved. >+ * Copyright (C) 2009 Torch Mobile, 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. >+ * 3. Neither the name of Apple 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. >+ */ >+ >+/* >+ * There are numerous academic and practical works on how to implement pthread_cond_wait/pthread_cond_signal/pthread_cond_broadcast >+ * functions on Win32. Here is one example: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html which is widely credited as a 'starting point' >+ * of modern attempts. There are several more or less proven implementations, one in Boost C++ library (http://www.boost.org) and another >+ * in pthreads-win32 (http://sourceware.org/pthreads-win32/). >+ * >+ * The number of articles and discussions is the evidence of significant difficulties in implementing these primitives correctly. >+ * The brief search of revisions, ChangeLog entries, discussions in comp.programming.threads and other places clearly documents >+ * numerous pitfalls and performance problems the authors had to overcome to arrive to the suitable implementations. >+ * Optimally, WebKit would use one of those supported/tested libraries directly. To roll out our own implementation is impractical, >+ * if even for the lack of sufficient testing. However, a faithful reproduction of the code from one of the popular supported >+ * libraries seems to be a good compromise. >+ * >+ * The early Boost implementation (http://www.boxbackup.org/trac/browser/box/nick/win/lib/win32/boost_1_32_0/libs/thread/src/condition.cpp?rev=30) >+ * is identical to pthreads-win32 (http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32). >+ * Current Boost uses yet another (although seemingly equivalent) algorithm which came from their 'thread rewrite' effort. >+ * >+ * This file includes timedWait/signal/broadcast implementations translated to WebKit coding style from the latest algorithm by >+ * Alexander Terekhov and Louis Thomas, as captured here: http://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/pthread_cond_wait.c?rev=1.10&content-type=text/x-cvsweb-markup&cvsroot=pthreads-win32 >+ * It replaces the implementation of their previous algorithm, also documented in the same source above. >+ * The naming and comments are left very close to original to enable easy cross-check. >+ * >+ * The corresponding Pthreads-win32 License is included below, and CONTRIBUTORS file which it refers to is added to >+ * source directory (as CONTRIBUTORS.pthreads-win32). >+ */ >+ >+/* >+ * Pthreads-win32 - POSIX Threads Library for Win32 >+ * Copyright(C) 1998 John E. Bossom >+ * Copyright(C) 1999,2005 Pthreads-win32 contributors >+ * >+ * Contact Email: rpj@callisto.canberra.edu.au >+ * >+ * The current list of contributors is contained >+ * in the file CONTRIBUTORS included with the source >+ * code distribution. The list can also be seen at the >+ * following World Wide Web location: >+ * http://sources.redhat.com/pthreads-win32/contributors.html >+ * >+ * 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 in the file COPYING.LIB; >+ * if not, write to the Free Software Foundation, Inc., >+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA >+ */ >+ >+#include "config.h" >+#include <wtf/Threading.h> >+ >+#include <errno.h> >+#include <process.h> >+#include <windows.h> >+#include <wtf/HashMap.h> >+#include <wtf/Lock.h> >+#include <wtf/MainThread.h> >+#include <wtf/MathExtras.h> >+#include <wtf/NeverDestroyed.h> >+#include <wtf/ThreadingPrimitives.h> >+ >+namespace WTF { >+ >+static Lock globalSuspendLock; >+ >+Thread::~Thread() >+{ >+ // It is OK because FLSAlloc's callback will be called even before there are some open handles. >+ // This easily ensures that all the thread resources are automatically closed. >+ if (m_handle != INVALID_HANDLE_VALUE) >+ CloseHandle(m_handle); >+} >+ >+void Thread::initializeCurrentThreadEvenIfNonWTFCreated() >+{ >+} >+ >+// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. >+static const DWORD MS_VC_EXCEPTION = 0x406D1388; >+ >+#pragma pack(push, 8) >+typedef struct tagTHREADNAME_INFO { >+ DWORD dwType; // must be 0x1000 >+ LPCSTR szName; // pointer to name (in user addr space) >+ DWORD dwThreadID; // thread ID (-1=caller thread) >+ DWORD dwFlags; // reserved for future use, must be zero >+} THREADNAME_INFO; >+#pragma pack(pop) >+ >+void Thread::initializeCurrentThreadInternal(const char* szThreadName) >+{ >+#if COMPILER(MINGW) >+ // FIXME: Implement thread name setting with MingW. >+ UNUSED_PARAM(szThreadName); >+#else >+ THREADNAME_INFO info; >+ info.dwType = 0x1000; >+ info.szName = Thread::normalizeThreadName(szThreadName); >+ info.dwThreadID = GetCurrentThreadId(); >+ info.dwFlags = 0; >+ >+ __try { >+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), reinterpret_cast<ULONG_PTR*>(&info)); >+ } __except(EXCEPTION_CONTINUE_EXECUTION) { } >+#endif >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+} >+ >+void Thread::initializePlatformThreading() >+{ >+} >+ >+static unsigned __stdcall wtfThreadEntryPoint(void* data) >+{ >+ Thread::entryPoint(reinterpret_cast<Thread::NewThreadContext*>(data)); >+ return 0; >+} >+ >+bool Thread::establishHandle(NewThreadContext* data) >+{ >+ unsigned threadIdentifier = 0; >+ HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, data, 0, &threadIdentifier)); >+ if (!threadHandle) { >+ LOG_ERROR("Failed to create thread at entry point %p with data %p: %ld", wtfThreadEntryPoint, data, errno); >+ return false; >+ } >+ establishPlatformSpecificHandle(threadHandle, threadIdentifier); >+ return true; >+} >+ >+void Thread::changePriority(int delta) >+{ >+ auto locker = holdLock(m_mutex); >+ SetThreadPriority(m_handle, THREAD_PRIORITY_NORMAL + delta); >+} >+ >+int Thread::waitForCompletion() >+{ >+ HANDLE handle; >+ { >+ auto locker = holdLock(m_mutex); >+ handle = m_handle; >+ } >+ >+ DWORD joinResult = WaitForSingleObject(handle, INFINITE); >+ if (joinResult == WAIT_FAILED) >+ LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this); >+ >+ auto locker = holdLock(m_mutex); >+ ASSERT(joinableState() == Joinable); >+ >+ // The thread has already exited, do nothing. >+ // The thread hasn't exited yet, so don't clean anything up. Just signal that we've already joined on it so that it will clean up after itself. >+ if (!hasExited()) >+ didJoin(); >+ >+ return joinResult; >+} >+ >+void Thread::detach() >+{ >+ // We follow the pthread semantics: even after the detach is called, >+ // we can still perform various operations onto the thread. For example, >+ // we can do pthread_kill for the detached thread. The problem in Windows >+ // is that closing HANDLE loses the way to do such operations. >+ // To do so, we do nothing here in Windows. Original detach's purpose, >+ // releasing thread resource when the thread exits, will be achieved by >+ // FlsCallback automatically. FlsCallback will call CloseHandle to clean up >+ // resource. So in this function, we just mark the thread as detached to >+ // avoid calling waitForCompletion for this thread. >+ auto locker = holdLock(m_mutex); >+ if (!hasExited()) >+ didBecomeDetached(); >+} >+ >+auto Thread::suspend() -> Expected<void, PlatformSuspendError> >+{ >+ RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself."); >+ LockHolder locker(globalSuspendLock); >+ DWORD result = SuspendThread(m_handle); >+ if (result != (DWORD)-1) >+ return { }; >+ return makeUnexpected(result); >+} >+ >+// During resume, suspend or resume should not be executed from the other threads. >+void Thread::resume() >+{ >+ LockHolder locker(globalSuspendLock); >+ ResumeThread(m_handle); >+} >+ >+size_t Thread::getRegisters(PlatformRegisters& registers) >+{ >+ LockHolder locker(globalSuspendLock); >+ registers.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; >+ GetThreadContext(m_handle, ®isters); >+ return sizeof(CONTEXT); >+} >+ >+Thread& Thread::initializeCurrentTLS() >+{ >+ // Not a WTF-created thread, ThreadIdentifier is not established yet. >+ Ref<Thread> thread = adoptRef(*new Thread()); >+ >+ HANDLE handle; >+ bool isSuccessful = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS); >+ RELEASE_ASSERT(isSuccessful); >+ >+ thread->establishPlatformSpecificHandle(handle, currentID()); >+ thread->initializeInThread(); >+ initializeCurrentThreadEvenIfNonWTFCreated(); >+ >+ return initializeTLS(WTFMove(thread)); >+} >+ >+ThreadIdentifier Thread::currentID() >+{ >+ return static_cast<ThreadIdentifier>(GetCurrentThreadId()); >+} >+ >+void Thread::establishPlatformSpecificHandle(HANDLE handle, ThreadIdentifier threadID) >+{ >+ auto locker = holdLock(m_mutex); >+ m_handle = handle; >+ m_id = threadID; >+} >+ >+#define InvalidThread reinterpret_cast<Thread*>(static_cast<uintptr_t>(0xbbadbeef)) >+ >+static WordLock threadMapMutex; >+ >+static HashMap<ThreadIdentifier, Thread*>& threadMap() >+{ >+ static NeverDestroyed<HashMap<ThreadIdentifier, Thread*>> map; >+ return map.get(); >+} >+ >+void Thread::initializeTLSKey() >+{ >+ threadMap(); >+ threadSpecificKeyCreate(&s_key, destructTLS); >+} >+ >+Thread* Thread::currentDying() >+{ >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ // After FLS is destroyed, this map offers the value until the second thread exit callback is called. >+ auto locker = holdLock(threadMapMutex); >+ return threadMap().get(currentID()); >+} >+ >+// FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >+RefPtr<Thread> Thread::get(ThreadIdentifier id) >+{ >+ auto locker = holdLock(threadMapMutex); >+ Thread* thread = threadMap().get(id); >+ if (thread) >+ return thread; >+ return nullptr; >+} >+ >+Thread& Thread::initializeTLS(Ref<Thread>&& thread) >+{ >+ ASSERT(s_key != InvalidThreadSpecificKey); >+ // FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed. >+ auto id = thread->id(); >+ // We leak the ref to keep the Thread alive while it is held in TLS. destructTLS will deref it later at thread destruction time. >+ auto& threadInTLS = thread.leakRef(); >+ threadSpecificSet(s_key, &threadInTLS); >+ { >+ auto locker = holdLock(threadMapMutex); >+ threadMap().add(id, &threadInTLS); >+ } >+ return threadInTLS; >+} >+ >+void Thread::destructTLS(void* data) >+{ >+ if (data == InvalidThread) >+ return; >+ >+ Thread* thread = static_cast<Thread*>(data); >+ ASSERT(thread); >+ >+ // Delay the deallocation of Thread more. >+ // It defers Thread deallocation after the other ThreadSpecific values are deallocated. >+ static thread_local class ThreadExitCallback { >+ public: >+ ThreadExitCallback(Thread* thread) >+ : m_thread(thread) >+ { >+ } >+ >+ ~ThreadExitCallback() >+ { >+ Thread::destructTLS(m_thread); >+ } >+ >+ private: >+ Thread* m_thread; >+ } callback(thread); >+ >+ if (thread->m_isDestroyedOnce) { >+ { >+ auto locker = holdLock(threadMapMutex); >+ ASSERT(threadMap().contains(thread->id())); >+ threadMap().remove(thread->id()); >+ } >+ thread->didExit(); >+ thread->deref(); >+ >+ // Fill the FLS with the non-nullptr value. While FLS destructor won't be called for that, >+ // non-nullptr value tells us that we already destructed Thread. This allows us to >+ // detect incorrect use of Thread::current() after this point because it will crash. >+ threadSpecificSet(s_key, InvalidThread); >+ return; >+ } >+ threadSpecificSet(s_key, InvalidThread); >+ thread->m_isDestroyedOnce = true; >+} >+ >+Mutex::~Mutex() >+{ >+} >+ >+void Mutex::lock() >+{ >+ AcquireSRWLockExclusive(&m_mutex); >+} >+ >+bool Mutex::tryLock() >+{ >+ return TryAcquireSRWLockExclusive(&m_mutex); >+} >+ >+void Mutex::unlock() >+{ >+ ReleaseSRWLockExclusive(&m_mutex); >+} >+ >+// Returns an interval in milliseconds suitable for passing to one of the Win32 wait functions (e.g., ::WaitForSingleObject). >+static DWORD absoluteTimeToWaitTimeoutInterval(WallTime absoluteTime) >+{ >+ WallTime currentTime = WallTime::now(); >+ >+ // Time is in the past - return immediately. >+ if (absoluteTime < currentTime) >+ return 0; >+ >+ // Time is too far in the future (and would overflow unsigned long) - wait forever. >+ if ((absoluteTime - currentTime) > Seconds::fromMilliseconds(INT_MAX)) >+ return INFINITE; >+ >+ return static_cast<DWORD>((absoluteTime - currentTime).milliseconds()); >+} >+ >+ThreadCondition::~ThreadCondition() >+{ >+} >+ >+void ThreadCondition::wait(Mutex& mutex) >+{ >+ SleepConditionVariableSRW(&m_condition, &mutex.impl(), INFINITE, 0); >+} >+ >+bool ThreadCondition::timedWait(Mutex& mutex, WallTime absoluteTime) >+{ >+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms686304(v=vs.85).aspx >+ DWORD interval = absoluteTimeToWaitTimeoutInterval(absoluteTime); >+ if (!interval) { >+ // Consider the wait to have timed out, even if our condition has already been signaled, to >+ // match the pthreads implementation. >+ return false; >+ } >+ >+ if (SleepConditionVariableSRW(&m_condition, &mutex.impl(), interval, 0)) >+ return true; >+ ASSERT(GetLastError() == ERROR_TIMEOUT); >+ return false; >+} >+ >+void ThreadCondition::signal() >+{ >+ WakeConditionVariable(&m_condition); >+} >+ >+void ThreadCondition::broadcast() >+{ >+ WakeAllConditionVariable(&m_condition); >+} >+ >+// Remove this workaround code when <rdar://problem/31793213> is fixed. >+ThreadIdentifier createThread(ThreadFunction function, void* data, const char* threadName) >+{ >+ return Thread::create(threadName, [function, data] { >+ function(data); >+ })->id(); >+} >+ >+int waitForThreadCompletion(ThreadIdentifier threadID) >+{ >+ // This function is implemented based on the old Threading implementation. >+ // It remains only due to the support library using old Threading APIs and >+ // it should not be used in new code. >+ ASSERT(threadID); >+ >+ RefPtr<Thread> thread = Thread::get(threadID); >+ if (!thread) { >+ LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID); >+ return WAIT_FAILED; >+ } >+ return thread->waitForCompletion(); >+ >+} >+ >+void Thread::yield() >+{ >+ SwitchToThread(); >+} >+ >+} // namespace WTF
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193929
:
360384
|
360419