Skip to content

rtapi: provide a Darwin relative nanosleep fallback - #4961

Open
smoe wants to merge 1 commit into
LinuxCNC:masterfrom
smoe:codex/darwin-relative-sleep-upstream
Open

smoe wants to merge 1 commit into
LinuxCNC:masterfrom
smoe:codex/darwin-relative-sleep-upstream

Conversation

@smoe

@smoe smoe commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Use nanosleep for the Darwin fallback, matching the relative waits used by both current callers. Reject nonzero flags with EINVAL rather than defining a fake TIMER_ABSTIME.

Keep the native clock_nanosleep and general fallback branches unchanged. The Darwin branch ignores clock_id and retains nanosleep EINTR behavior; absolute deadlines and realtime scheduling are not provided.

Use nanosleep for the Darwin fallback, matching the relative waits used
by both current callers. Reject nonzero flags with EINVAL rather than
defining a fake TIMER_ABSTIME.

Keep the native clock_nanosleep and general fallback branches unchanged.
The Darwin branch ignores clock_id and retains nanosleep EINTR behavior;
absolute deadlines and realtime scheduling are not provided.
Comment thread src/rtapi/uspace_common.h
Comment on lines +373 to +381
#elif defined(__APPLE__)
/* Darwin provides nanosleep(); this helper's callers use relative waits. */
(void)clock_id;
if(flags != 0)
{
errno = EINVAL;
return -1;
}
return nanosleep(prequest, remain);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be simpler? Or does that give other problems?

@@ -373,6 +373,12 @@ static int rtapi_clock_nanosleep(clockid_t clock_id, int flags,
 #else
     if(flags == 0)
         return nanosleep(prequest, remain);
+#if defined(__APPLE__)
+    else {
+        errno = EINTR;
+        return -1;
+    }
+#endif
     if(flags != TIMER_ABSTIME)
     {
         errno = EINVAL;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants