Repository navigation
include/sys/time.h: Add timespecadd, timespecsub, and timespeccmp - #21115
Merged
Merged
Conversation
<sys/time.h> defines timeradd, timersub, timerclear, timerisset, and timercmp for operations on struct timeval. The BSDs, glibc and musl also provide the corresponding macros for operations on struct timespec: timespecadd, timespecsub, timespecclear, timespecisset, and timespeccmp. This patch adds these convenience macros to <sys/time.h> for improved standard POSIX/BSD compatibility. Assisted-by: Google Gemini Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
requested review from
liuguo09 and
xiaoxiang781216
as code owners
October 29, 2026 10:24
|
xiaoxiang781216
approved these changes
Oct 29, 2026
acassis
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<sys/time.h>defines standard BSD/Linux convenience macrostimeradd,timersub,timerclear,timerisset, andtimercmpfor operations onstruct timeval.Most standard C libraries (glibc, musl, FreeBSD, NetBSD, OpenBSD) provide the corresponding operations for
struct timespec:timespecadd,timespecsub,timespecclear,timespecisset, andtimespeccmp.This patch implements these standard convenience macros in
include/sys/time.hmirroring the existingtimevalimplementations, improving BSD/POSIX portability and compatibility.Impact
timespecarithmetic and comparison macros in<sys/time.h>.Testing
<time.h>is already included ininclude/sys/time.h), and clean compilation.tools/checkpatch.sh: