Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CoreFoundation/Base.subproj/CFInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ CF_EXPORT void _NS_pthread_setname_np(const char *name);
#endif

#if DEPLOYMENT_TARGET_LINUX
CF_EXPORT Boolean _CFIsMainThread(void);
#define pthread_main_np _CFIsMainThread
#endif

Expand Down
2 changes: 2 additions & 0 deletions CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ CF_PRIVATE CF_EXPORT char *_Nullable *_Nonnull _CFEnviron(void);

CF_EXPORT void CFLog1(CFLogLevel lev, CFStringRef message);

CF_EXPORT Boolean _CFIsMainThread(void);

_CF_EXPORT_SCOPE_END

#endif /* __COREFOUNDATION_FORSWIFTFOUNDATIONONLY__ */
6 changes: 6 additions & 0 deletions Foundation/NSOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

#if DEPLOYMENT_ENABLE_LIBDISPATCH
import Dispatch
#if os(Linux)
import CoreFoundation
private func pthread_main_np() -> Int32 {
return _CFIsMainThread() ? 1 : 0
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would turn the boolean result of _CFIsMainThread into the Int32 expected by the pthread_main_np stub.

#endif

public class NSOperation : NSObject {
Expand Down