WebKit Bugzilla
Attachment 343522 Details for
Bug 187009
: Use std::call_once() instead of dispatch_once() in SoftLinking.h
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v1
bug-187009-20180625115507.patch (text/plain), 5.20 KB, created by
David Kilzer (:ddkilzer)
on 2018-06-25 11:55:08 PDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
David Kilzer (:ddkilzer)
Created:
2018-06-25 11:55:08 PDT
Size:
5.20 KB
patch
obsolete
>Subversion Revision: 233151 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 821ead2e8f0c03e004a8fe3a0bdd4690a402eae4..7e172331b4343beae7b0122b20c3fee67d6c496f 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,14 @@ >+2018-06-25 David Kilzer <ddkilzer@apple.com> >+ >+ Use std::call_once() instead of dispatch_once() in SoftLinking.h >+ <https://webkit.org/b/187009> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/cocoa/SoftLinking.h: Switch from dispatch_once() to >+ std::call_once() since it's a lower-level API and there is less >+ that can go wrong. >+ > 2018-06-22 Darin Adler <darin@apple.com> > > [Cocoa] Convert the small bit of Objective-C++ code in WTF to ARC >diff --git a/Source/WTF/wtf/cocoa/SoftLinking.h b/Source/WTF/wtf/cocoa/SoftLinking.h >index 0bccf68518a326f2dbab3a8d582559b55e753c9e..4ff199663ef62899b83808dab80c799a50076761 100644 >--- a/Source/WTF/wtf/cocoa/SoftLinking.h >+++ b/Source/WTF/wtf/cocoa/SoftLinking.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2007, 2008, 2011-2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2007-2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -24,9 +24,10 @@ > > #pragma once > >-#import <wtf/Assertions.h> > #import <dlfcn.h> >+#import <mutex> > #import <objc/runtime.h> >+#import <wtf/Assertions.h> > > #pragma mark - Soft-link macros for use within a single source file > >@@ -306,7 +307,6 @@ > > // See Source/WebCore/platform/cf/CoreMediaSoftLink.{cpp,h} for an example implementation. > >- > #define SOFT_LINK_LIBRARY_FOR_HEADER(functionNamespace, lib) \ > namespace functionNamespace { \ > extern void* lib##Library(bool isOptional = false); \ >@@ -321,8 +321,8 @@ > void* lib##Library(bool isOptional) \ > { \ > static void* library; \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [isOptional] { \ > library = dlopen("/usr/lib/" #lib ".dylib", RTLD_NOW); \ > if (!isOptional) \ > RELEASE_ASSERT_WITH_MESSAGE(library, "%s", dlerror()); \ >@@ -346,8 +346,8 @@ > void* framework##Library(bool isOptional) \ > { \ > static void* frameworkLibrary; \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [isOptional] { \ > frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \ > if (!isOptional) \ > RELEASE_ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \ >@@ -362,8 +362,8 @@ > void* framework##Library(bool isOptional) \ > { \ > static void* frameworkLibrary; \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [isOptional] { \ > frameworkLibrary = dlopen("/System/Library/PrivateFrameworks/" #framework ".framework/" #framework, RTLD_NOW); \ > if (!isOptional) \ > RELEASE_ASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \ >@@ -397,8 +397,8 @@ > \ > static Class init##className() \ > { \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [] { \ > framework##Library(); \ > class##className = objc_getClass(#className); \ > RELEASE_ASSERT(class##className); \ >@@ -425,8 +425,8 @@ > variableType get_##framework##_##variableName() \ > { \ > static variableType constant##framework##variableName; \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [] { \ > void* constant = dlsym(framework##Library(), #variableName); \ > RELEASE_ASSERT_WITH_MESSAGE(constant, "%s", dlerror()); \ > constant##framework##variableName = *static_cast<variableType const *>(constant); \ >@@ -498,8 +498,8 @@ > resultType (*softLink##framework##functionName) parameterDeclarations = init##framework##functionName; \ > static resultType init##framework##functionName parameterDeclarations \ > { \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [] { \ > softLink##framework##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \ > RELEASE_ASSERT_WITH_MESSAGE(softLink##framework##functionName, "%s", dlerror()); \ > }); \ >@@ -565,8 +565,8 @@ > \ > static variableType init##framework##variableName() \ > { \ >- static dispatch_once_t once; \ >- dispatch_once(&once, ^{ \ >+ static std::once_flag flag; \ >+ std::call_once(flag, [] { \ > void** pointer = static_cast<void**>(dlsym(framework##Library(), #variableName)); \ > RELEASE_ASSERT_WITH_MESSAGE(pointer, "%s", dlerror()); \ > pointer##framework##variableName = static_cast<variableType>(*pointer); \
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 187009
:
343522
|
343525
|
343589