Skip to content

Commit 523dffa

Browse files
seabayleaparkera
authored andcommitted
Use _CFIsMainThread as a shim for pthread_main_np on Linux (#359)
1 parent 1d255b9 commit 523dffa

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ CF_EXPORT void _NS_pthread_setname_np(const char *name);
787787
#endif
788788

789789
#if DEPLOYMENT_TARGET_LINUX
790-
CF_EXPORT Boolean _CFIsMainThread(void);
791790
#define pthread_main_np _CFIsMainThread
792791
#endif
793792

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ CF_PRIVATE CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);
243243

244244
CF_EXPORT void CFLog1(CFLogLevel lev, CFStringRef message);
245245

246+
CF_EXPORT Boolean _CFIsMainThread(void);
247+
246248
_CF_EXPORT_SCOPE_END
247249

248250
#endif /* __COREFOUNDATION_FORSWIFTFOUNDATIONONLY__ */

Foundation/NSOperation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
#if DEPLOYMENT_ENABLE_LIBDISPATCH
1111
import Dispatch
12+
#if os(Linux)
13+
import CoreFoundation
14+
private func pthread_main_np() -> Int32 {
15+
return _CFIsMainThread() ? 1 : 0
16+
}
17+
#endif
1218
#endif
1319

1420
public class NSOperation : NSObject {

0 commit comments

Comments
 (0)