Skip to content

Implement NSRunLoop #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 16, 2015
Merged

Implement NSRunLoop #133

merged 4 commits into from
Dec 16, 2015

Conversation

kovpas
Copy link
Contributor

@kovpas kovpas commented Dec 11, 2015

addPort and removePort are not implemented because NSPort implementation is missing.

@parkera
Copy link
Contributor

parkera commented Dec 11, 2015

The main issue here is that none of this will work on Linux because the CF code is not yet ported.

@kovpas
Copy link
Contributor Author

kovpas commented Dec 13, 2015

@parkera I think I've got CFRunLoop.c working on ubuntu. Probably better to post it as a separate pull request, though. It's heavily based on CFLite by @nickhutchinson ( https://github.com/nickhutchinson/CFLite/tree/master ). Had to tweak a couple of things, but nothing too complex. Would be great if you could take a look and let me know if I could proceed with pull request.

kovpas/swift-corelibs-foundation@nsrunloop...kovpas:cfrunloop_ubuntu

@parkera
Copy link
Contributor

parkera commented Dec 13, 2015

I think you're on the right track; I had started on something similar, although I used epoll instead.

@parkera
Copy link
Contributor

parkera commented Dec 13, 2015

Since we don't really have a mechanism in our tests for writing C unit tests of CF directly, I think it makes sense to consider this all together so we can verify that it's working.

@kovpas
Copy link
Contributor Author

kovpas commented Dec 13, 2015

@parkera makes sense to treat it as one thing, indeed. I'll update this PR. Also going to add some tests for NSTimer

One thing: for some reason NSRunLoop.swift doesn't compile for me on linux when I use CFRunLoopRunResult:

Foundation/NSRunLoop.swift:75:34: error: type of expression is ambiguous without more context
        return runloopResult == .HandledSource || runloopResult == .TimedOut
                                ~^~~~~~~~~~~~~

Do you have any idea why this could happen and how to fix that? Meanwhile I had to do that:

return runloopResult == 2 || runloopResult == 3

@@ -14,7 +14,7 @@
foundation.GCC_PREFIX_HEADER = 'CoreFoundation/Base.subproj/CoreFoundation_Prefix.h'

if Configuration.current.target.sdk == OSType.Linux:
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX '
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE '
Copy link
Contributor

Choose a reason for hiding this comment

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

This causes a build warning:

[9/175] CompileC: closure/runtime.c
closure/runtime.c:16:9: warning: '__USE_GNU' macro redefined [-Wmacro-redefined]
#define __USE_GNU
        ^
/usr/include/features.h:322:10: note: previous definition is here
# define __USE_GNU      1
         ^
1 warning generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not recommended to define __USE_GNU in code, better to use define _GNU_SOURCE. I just removed this define in closure/runtime.c, as all source files are now compiled with _GNU_SOURCE.

@parkera
Copy link
Contributor

parkera commented Dec 16, 2015

Overall looks really good. I just have a few minor comments for you to address then we'll merge this in. Thanks!

@parkera parkera removed their assignment Dec 16, 2015
@parkera parkera self-assigned this Dec 16, 2015
@parkera parkera merged commit 823fa0f into swiftlang:master Dec 16, 2015
kovpas referenced this pull request Dec 16, 2015
When libdispatch builds properly for linux this will be re-enabled

This reverts commit cefb963.
@kovpas kovpas deleted the nsrunloop branch December 19, 2015 16:00
atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
[clangd] Set correct argv[0] for clangd to fix c++ header search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants