Commit 5f57e70
authored
Omnibus to implement CFRunLoop with kevent. (#3004)
* [runloop] Set up some symbols for generic code.
CFRunLoop has a recurring abstraction for platform-specific code, but it
is a little leaky. Plug these leaks: ensure `MACH_PORT_NULL` in the
generic, non-platform context is rewritten as `CFPORT_NULL`, and ensure
that `kern_return_t` and `KERN_SUCCESS` are defined properly.
* [runloop] Remind porter these stubs are required.
New platforms must define these types and functions; it is incorrect to
not have #else cases here.
* [runloop] Implement runloop abstraction for BSD.
* [runloop] Ensure timing arithmetic is done in ns.
Fixes SR-14288.
* [runloop] Avoid pthread_main_np on OpenBSD.
During runloop testing, log messages suggest that the runloop thinks the
main thread has exited and certain runloop operations don't actually
proceed. The flag for denoting when the main thread has exited is set in
the thread-specific data destructor `__CFTSDFinalize`.
This function detects whether the thread in question is the main thread
via `pthread_main_np`, and has been observed in debugging this problem
to return 1 on apparently non-main threads on OpenBSD. This obviously
will cause the main thread exited flag to be erroneously set when
non-main threads complete their work and dispose of thread-specific
data.
Instead, use the existing `_CFMainPThread` symbol set in
`__CFInitialize` to determine the main thread. I am not sure whether the
platform `pthread_main_np` is at fault here, but since this workaround
makes the tests pass, let's use it.1 parent 9bc1a18 commit 5f57e70
File tree
3 files changed
+333
-23
lines changed- CoreFoundation
- Base.subproj
- RunLoop.subproj
- Sources/Foundation
3 files changed
+333
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
252 | 255 | | |
| 256 | + | |
253 | 257 | | |
254 | 258 | | |
255 | 259 | | |
| |||
774 | 778 | | |
775 | 779 | | |
776 | 780 | | |
777 | | - | |
| 781 | + | |
778 | 782 | | |
779 | 783 | | |
780 | 784 | | |
| |||
0 commit comments