-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc][darwin] add basic mutex support for darwin #167161
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
Conversation
ExecuteFunctionUnix.cpp which is guarded by this check should reliably work on darwin as it only uses POSIX API - nothing specific to linux.
Fixes: llvm#166059 Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
_Exit(3) is a fairly simple syscall wrapper whereas exit(3) calls atexit-registered functions + whole lot of stuff that require support for sync primitives. Splitting the tests allows testing the former easily (especially for new port projects) Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
Signed-off-by: Shreeyash Pandey <[email protected]>
This patch adds support for clock_gettime for Darwin. Darwin syscall 'gettimeofday' is used to query the time from the system. Many headers in llvm-libc-types, namely clockid_t, struct_timespec, struct_timeval, suseconds_t, time_t_32, time_t_64, are modified to include header guards as Darwin has its own implementation of primitive types.
This patch adds a basic implementation/wrapper for mutex using the underlying os_unfair_lock API that macos provides.
06ec1fd to
6d31260
Compare
|
Thank you for the patch, however, I have a major concern regarding it. I think we should prefer in this case:
This also avoid unaligned behavior across platforms: So, instead of specialize mutex, let's make raw mutex a common library for both linux and darwin, by providing all futex Also, using user space busy loop to implement timed lock is definitely not what we want. There are existing API like the following if you use the futex approach: |
|
Thank you for the detailed review. I agree with you here. I went with os_unfair_lock primarily for simplicity. I'll take your suggestions, and reimplement this with os_sync_wait. |
This patch adds a basic implementation/wrapper for mutex using the underlying
os_unfair_lock API that macos provides.