arch/sim: Handle Darwin clock IDs in clock_gettime()#18962
Open
toku-mac wants to merge 1 commit into
Open
Conversation
2 tasks
Add a sim/macOS-specific clock_gettime() override that translates Darwin monotonic clock IDs to NuttX CLOCK_MONOTONIC before delegating to nxclock_gettime(). Make the common clock_gettime() weak so the simulator override can replace it. This fixes a Rust tokio panic on macOS when running hello_rust_cargo. Signed-off-by: Shoji Tokunaga <toku@mac.com>
195a3bc to
c49d064
Compare
Contributor
is it expected to work at all? |
| ****************************************************************************/ | ||
|
|
||
| int clock_gettime(clockid_t clock_id, FAR struct timespec *tp) | ||
| int weak_function clock_gettime(clockid_t clock_id, FAR struct timespec *tp) |
Contributor
There was a problem hiding this comment.
it's wrong to expose the host clock_gettime to nuttx. We should use the same approach as Linux, which do the conversion in arch/sim/posix. what's problem do you hit on macOS?
Contributor
Author
There was a problem hiding this comment.
is it expected to work at all?
it's wrong to expose the host clock_gettime to nuttx. We should use the same approach as Linux, which do the conversion in arch/sim/posix. what's problem do you hit on macOS?
I'll reconsider the implementation method.
Contributor
Author
There was a problem hiding this comment.
- Add
ARCH_HAVE_CLOCKID_TRANSLATEto Kconfig. - Reference this in
sched/clock/clock_gettime.candinclude/nuttx/arch.h. - Add
arch/sim/src/sim/posix/sim_clockid.c.
What do you think about this approach?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes
clock_gettime()compatibility for the macOS simulator whenDarwin-targeted code is linked into NuttX.
The fix adds a sim/macOS-specific
clock_gettime()override that translatesDarwin monotonic clock IDs to NuttX
CLOCK_MONOTONICbefore callingnxclock_gettime().clock_gettime()weak.arch/sim/src/sim/macos/sim_clock_gettime.c.REQUIREDOBJSso the override is included in the final simulator link.Impact
Running
hello_rust_cargowith nsh on macOS should no longer cause a panic.Testing
I confirm that changes are verified on local setup and works as intended:
make, you need apps PR #3501 .Configuration and Build:
Testing logs before change:
Testing logs after change:
PR verification Self-Check