[libc-commits] [libc] [libc] Fix pause build on riscv32 via ppoll wrapper (PR #231959)

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Thu Oct 15 08:50:58 PDT 2026


================
@@ -39,19 +39,19 @@ LIBC_INLINE ErrorOr<int> ppoll(struct pollfd *fds, nfds_t nfds,
   // signals. NSIG is the signal count, so NSIG / 8 gives the byte size.
   const size_t SIGSETSIZE = NSIG / 8;
 
-#if defined(SYS_ppoll_time64)
-  static_assert(
-      sizeof(time_t) == sizeof(int64_t),
-      "SYS_ppoll_time64 requires struct timespec with 64-bit members.");
-  return syscall_checked<int>(SYS_ppoll_time64, fds, nfds, tmo_p, sigmask,
-                              SIGSETSIZE);
-#elif defined(SYS_ppoll)
+#if defined(SYS_ppoll)
   static_assert(
       sizeof(timespec::tv_nsec) == sizeof(long),
       "This legacy syscall fallback is only safe on platforms where tv_nsec "
       "matches the register size (long). It is unsafe on 32-bit platforms "
       "with 64-bit tv_nsec.");
   return syscall_checked<int>(SYS_ppoll, fds, nfds, tmo_p, sigmask, SIGSETSIZE);
+#elif defined(SYS_ppoll_time64)
----------------
mikhailramalho wrote:

SGTM, I came up with the following not very pretty code:
```
#if defined(SYS_ppoll_time64)
  if constexpr (sizeof(time_t) == sizeof(int64_t))
    return syscall_checked<int>(SYS_ppoll_time64, fds, nfds, tmo_p, sigmask, SIGSETSIZE);
#endif

#if defined(SYS_ppoll)
  if constexpr (sizeof(time_t) == sizeof(long))
    return syscall_checked<int>(SYS_ppoll, fds, nfds, tmo_p, sigmask, SIGSETSIZE);
#endif

  return Error(ENOSYS);
```
WDYT?

https://github.com/llvm/llvm-project/pull/231959


More information about the libc-commits mailing list