[PATCH] D58110: Support fiber API on macOS
Yuri Per via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 14 09:20:53 PST 2019
yuri added a comment.
In D58110#1396514 <https://reviews.llvm.org/D58110#1396514>, @kubamracek wrote:
> For the pragma diagnostic push/ignore stuff, we might be better off just redeclaring the function ourselves without including `ucontext.h`.
For tsan_interceptors_mac.cc it can be done. For me such solution is more ugly than usage of #define and #pragma; but if you insist on it, I can do such change.
For tests it is bad idea because test should use API the same way as real-world clients. I moved declarations to the separate header. Now code looks better.
> TBH, I'm not sure if there's a lot of value in supporting swapcontext on Darwin, as they are very likely broken when using many system libraries.
- QEMU is an important projected user of fiber API and it actually use swapcontext.
- We need to test fiber API somehow and swapcontext is the only portable way to do it.
PS. I want to explain why swapcontext interceptor is required on macOS and not on Linux.
__tsan_switch_to_fiber is called immediately before or after context switch.
Actual context switch code should not introduce memory dependancies; otherwise false positive races can be reported.
On Linux swapcontext implementation does not call any intercepted function, so condition is fulfilled.
On macOS we have to intercept swapcontext and disable interceptors inside it in order to achieve the same effect.
CHANGES SINCE LAST ACTION
More information about the llvm-commits