@@ -40,6 +40,14 @@ __BEGIN_DECLS
4040DISPATCH_SWIFT3_UNAVAILABLE ("Use lazily initialized globals instead" )
4141typedef long dispatch_once_t ;
4242
43+ #if defined(__x86_64__ ) || defined(__i386__ ) || defined(__s390x__ )
44+ #define DISPATCH_ONCE_INLINE_FASTPATH 1
45+ #elif defined(__APPLE__ )
46+ #define DISPATCH_ONCE_INLINE_FASTPATH 1
47+ #else
48+ #define DISPATCH_ONCE_INLINE_FASTPATH 0
49+ #endif
50+
4351/*!
4452 * @function dispatch_once
4553 *
6573dispatch_once (dispatch_once_t * predicate ,
6674 DISPATCH_NOESCAPE dispatch_block_t block );
6775
76+ #if DISPATCH_ONCE_INLINE_FASTPATH
6877DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
6978DISPATCH_SWIFT3_UNAVAILABLE ("Use lazily initialized globals instead" )
7079void
@@ -81,6 +90,7 @@ _dispatch_once(dispatch_once_t *predicate,
8190#undef dispatch_once
8291#define dispatch_once _dispatch_once
8392#endif
93+ #endif // DISPATCH_ONCE_INLINE_FASTPATH
8494
8595API_AVAILABLE (macos (10.6 ), ios (4.0 ))
8696DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
8999dispatch_once_f (dispatch_once_t * predicate , void * _Nullable context ,
90100 dispatch_function_t function );
91101
102+ #if DISPATCH_ONCE_INLINE_FASTPATH
92103DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL1 DISPATCH_NONNULL3
93104DISPATCH_NOTHROW
94105DISPATCH_SWIFT3_UNAVAILABLE ("Use lazily initialized globals instead" )
@@ -105,6 +116,7 @@ _dispatch_once_f(dispatch_once_t *predicate, void *_Nullable context,
105116}
106117#undef dispatch_once_f
107118#define dispatch_once_f _dispatch_once_f
119+ #endif // DISPATCH_ONCE_INLINE_FASTPATH
108120
109121__END_DECLS
110122
0 commit comments