Skip to content

[libc] Fix setitimer build when full_build=OFF #149665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2025

Conversation

mikhailramalho
Copy link
Member

When we pull the headers from the system, we might get a suseconds_t that's a long long, so add a cast to prevent a implicit conversion error.

When we pull the headers from the system, we might get a suseconds_t
that's a long long, so add a cast to prevent a implicit conversion
error.
@llvmbot
Copy link
Member

llvmbot commented Jul 19, 2025

@llvm/pr-subscribers-libc

Author: Mikhail R. Gadelha (mikhailramalho)

Changes

When we pull the headers from the system, we might get a suseconds_t that's a long long, so add a cast to prevent a implicit conversion error.


Full diff: https://github.com/llvm/llvm-project/pull/149665.diff

1 Files Affected:

  • (modified) libc/src/sys/time/linux/setitimer.cpp (+2-2)
diff --git a/libc/src/sys/time/linux/setitimer.cpp b/libc/src/sys/time/linux/setitimer.cpp
index 1de0d43297760..fb163586e30d9 100644
--- a/libc/src/sys/time/linux/setitimer.cpp
+++ b/libc/src/sys/time/linux/setitimer.cpp
@@ -22,9 +22,9 @@ LLVM_LIBC_FUNCTION(int, setitimer,
     // There is no SYS_setitimer_time64 call, so we can't use time_t directly,
     // and need to convert it to long first.
     long new_value32[4] = {static_cast<long>(new_value->it_interval.tv_sec),
-                           new_value->it_interval.tv_usec,
+                           static_cast<long>(new_value->it_interval.tv_usec),
                            static_cast<long>(new_value->it_value.tv_sec),
-                           new_value->it_value.tv_usec};
+                           static_cast<long>(new_value->it_value.tv_usec)};
     long old_value32[4];
 
     ret = LIBC_NAMESPACE::syscall_impl<long>(SYS_setitimer, which, new_value32,

mikhailramalho added a commit to mikhailramalho/llvm-project that referenced this pull request Jul 19, 2025
Same as PR llvm#149665: we might pull a header from host where tv_nsec is
not a long, so compilation would fail with an implicit conversion error.
@mikhailramalho mikhailramalho merged commit 4d76ff9 into llvm:main Jul 19, 2025
21 checks passed
@mikhailramalho mikhailramalho deleted the libc-fix-setitimer branch July 19, 2025 19:03
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
When we pull the headers from the system, we might get a suseconds_t
that's a long long, so add a cast to prevent a implicit conversion
error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants