sim: posix: add platform-specific timer handling for macOS and Linux#18331
sim: posix: add platform-specific timer handling for macOS and Linux#18331aditya0yadav wants to merge 4 commits intoapache:masterfrom
Conversation
|
Hi @aditya0yadav , I converted PR into draft. @FelipeMdeO @lupyuen @aviralgarg05 What do you think? |
| it.it_interval.tv_sec = 0; | ||
| it.it_interval.tv_usec = 0; | ||
|
|
||
| return setitimer(ITIMER_REAL, &it, NULL); |
There was a problem hiding this comment.
why not use setitimer on Linux too? https://linux.die.net/man/2/setitimer
There was a problem hiding this comment.
Because linux has a better api : timer_create() + timer_settime()
in macos , we have to use that time_create exist but unreliable and uncompleted and time_settime() is not properly supported
There was a problem hiding this comment.
it's better to go the same code path if we can, so don't need double the test effort.
There was a problem hiding this comment.
@xiaoxiang781216 Ok i will do that
Any suggestion about linker
for to use sim in macos , we need to disable the gcov
There was a problem hiding this comment.
@xiaoxiang781216 now set timer is being shared bet linux and macOS
|
please remove the merge commit ! |
Hi @simbit18, thanks for tagging me, the core approach of using |
and remove the use of #define _POSIX_C_SOURCE 200809L
| @@ -1,5 +1,7 @@ | |||
| /**************************************************************************** | |||
| * arch/sim/src/sim/posix/sim_hosttime.c | |||
| * arch/sim/src/sim/win/sim_hosttime.c | |||
There was a problem hiding this comment.
@simbit18
by mistake i copied license header from win folder
|
@aviralgarg05 I’ve removed the #define _POSIX_C_SOURCE 200809L in macOS and Ubuntu-based code spaces and it’s working properly. Mind taking a look? |
|
@simbit18 One more thing, what should we do with the linker in macOS? Every time I have to disable the configuration toolchain related to Gcov. Any suggestions? |
Thanks for the update @aditya0yadav, I checked the latest changes, the approach looks correct. There might be an issue with the |
|
Thanks for the review, @aviralgarg05.
I will look into it .
|
A long time ago, it was possible to build sim:nsh for Linux, macOS, and Windows . Of course, this is just my opinion! :) |
I think is makes sense, maybe using git bisect it could be possible to identify which symbols cases the breaking and open an issue to track it. |
|
Hi @raiden00pl, The changes in this PR cause errors in sim:citest. Can you check it? |
|
@simbit18 @aditya0yadav sim/citest is broken, NTFC detects that device is broken at init or doesn't boot at all. When I run binary from this PR, NSH is not functional and it stucks on NSH prompt (not sure what is this init error and if it's realted):
probably not everyone knows about it, but you can download built binaries directly from CI:
|
|
with this PR |
|
@raiden00pl, thank you very much. |
I just want to check if I’m understanding correctly: The linker issue seems to happen only on macOS, not on Linux. On Linux, it works fine and uses Gcov as expected, but on macOS, I always have to disable the Gcov-related toolchain in the configuration. If I wanted to find the specific symbol that is causing the linker to fail, doing a git bisect over 2–4 years of changes seems impractical because there’s been too much change in the repository. One idea I had is to use Docker with Linux to build NuttX, since Linux doesn’t hit the macOS linker problem. But of course, that wouldn’t reproduce the macOS-specific issue. Do you have any suggestions on how to approach this efficiently for macOS? |
|
Hello all,
Sorry for late reply.
I am very busy during this week but this weekend I will be available to
help. Let me try execute de bisec and find the valid commit.
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
…On Thu, 5 Feb 2026 at 19:04 Aditya Yadav ***@***.***> wrote:
*aditya0yadav* left a comment (apache/nuttx#18331)
<#18331 (comment)>
@simbit18 <https://github.com/simbit18> One more thing, what should we do
with the linker in macOS? I know it will work perfectly with Linux but not
with macOS.
Every time I have to disable the configuration toolchain related to Gcov.
Any suggestions?
A long time ago, it was possible to build sim:nsh for Linux, macOS, and
Windows . Currently, it does not work on macOS and Windows with
MSYS2/Cygwin (the latest version I was able to build and test was 10.2
<https://github.com/simbit18/nuttx-msys2>), so I personally think it is
right to restore the build by modifying the defconfig file.
Of course, this is just my opinion! :)
I think is makes sense, maybe using git bisect it could be possible to
identify which symbols cases the breaking and open an issue to track it.
I just want to check if I’m understanding correctly:
@simbit18 <https://github.com/simbit18> @acassis
<https://github.com/acassis>
The linker issue seems to happen only on macOS, not on Linux. On Linux, it
works fine and uses Gcov as expected, but on macOS, I always have to
disable the Gcov-related toolchain in the configuration.
If I wanted to find the specific symbol that is causing the linker to
fail, doing a git bisect over 2–4 years of changes seems impractical
because there’s been too much change in the repository.
One idea I had is to use Docker with Linux to build NuttX, since Linux
doesn’t hit the macOS linker problem. But of course, that wouldn’t
reproduce the macOS-specific issue.
Do you have any suggestions on how to approach this efficiently for macOS?
—
Reply to this email directly, view it on GitHub
<#18331 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADNC5ZRBKU6VDMZIY5VHU634KO47NAVCNFSM6AAAAACTY7CVNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQNJWGUZDMOBSHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|



PLEASE DONT MERGE THIS PR
Summary
This change updates the POSIX simulator host timer implementation to
handle platform differences between macOS (Darwin) and Linux.
macOS does not provide full support for POSIX timers such as
timer_create()andtimer_settime(). To address this, the simulatornow uses
setitimer()on macOS while retaining POSIX timers withabsolute-time scheduling on Linux and other POSIX systems.
The platform selection is handled via the
NUTTX_DARWINmacro, keepingthe simulator core logic unchanged while improving portability and
correctness on macOS.
Impact
Testing
Tested on macOS (Darwin):
SIGALRMand simulatorscheduling behaves as expected.
Linux testing:
Since this change affects host timer handling, additional testing on
Linux systems would be valuable before merging.
If anyone is able to test this change on a Linux PC and confirm that the
POSIX simulator builds and runs correctly, that feedback and any logs
would be greatly appreciated.
One more thing ,
For supporting macos, multiple things need to be done like docs and linker too .