xiaoxiang781216 commented on code in PR #18331:
URL: https://github.com/apache/nuttx/pull/18331#discussion_r2758567966


##########
arch/sim/src/sim/posix/sim_hosttime.c:
##########
@@ -119,19 +133,36 @@ void host_sleepuntil(uint64_t nsec)
 
 int host_settimer(uint64_t nsec)
 {
-  struct itimerspec tspec =
-    {
-      0
-    };
+#ifdef NUTTX_DARWIN
+  /* macOS implementation using setitimer() */
+
+  struct itimerval it;
+  uint64_t usec = nsec / 1000;
+
+  it.it_value.tv_sec  = usec / 1000000;
+  it.it_value.tv_usec = usec % 1000000;
+
+  /* One-shot timer */
+  it.it_interval.tv_sec  = 0;
+  it.it_interval.tv_usec = 0;
+
+  return setitimer(ITIMER_REAL, &it, NULL);

Review Comment:
   why not use setitimer on Linux too? https://linux.die.net/man/2/setitimer



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to