[swift-corelibs-dev] Use of pthread_main_np() in NSOperation

Tony Parker anthony.parker at apple.com
Tue May 10 14:34:11 CDT 2016


Since CF is really an implementation detail of Foundation for corelibs, let’s use the CF implementation for Foundation.

- Tony

> On May 10, 2016, at 12:10 PM, Chris Bailey via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> 
> NSOperation.swift currently makes a call to pthread_main_np() on line 536. This causes a compilation failure on Linux as there isn't an implementation of pthread_main_np() in Glibc. 
> 
> There's few ways of fixing this. Before I go ahead and implement one of them, I'd like to get some input on what we thing is the best approach. 
> 
> The most obvious approach would be to leverage the shim we've added to CoreFoundation already. We implemented pthread_main_np() using the following function in CFPlatform.c: 
> Boolean _CFIsMainThread(void) { 
>     return syscall(SYS_gettid) == getpid(); 
> } 
> This is only available internally to CF, but could be exposed to Foundation, either as _CFIsMainThread() or as pthread_main_np(). 
> 
> Other options would be to expose the pthread_main_np() shim that's in Dispatch already (again internally), or to add it to the Glibc overlay so its available globally. 
> 
> Any thoughts on the best approach? 
> 
> Chris_______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160510/f4f18319/attachment.html>


More information about the swift-corelibs-dev mailing list