Use Picolibc clock IDs in H2 POSIX time support - #92
Open
quic-k wants to merge 1 commit into
Open
Conversation
posix_time.h defined its own CLOCK_* macros (0/1/2/3) from the Dinkumware libc, but Picolibc uses 1/2/3/4. Callers and the implementation disagreed: clock_gettime(CLOCK_MONOTONIC) returned EINVAL and CLOCK_REALTIME took the wrong branch. Under Picolibc, take the clock IDs, clockid_t, struct timespec, and declarations from libc. Detect Picolibc via <picolibc.h> since __PICOLIBC__ is not compiler-predefined, and declare the CPU-time and monotonic clock capabilities this target omits so all four IDs are exposed. The existing declarations are kept for the legacy libc. Also compile libs/posix with --target=hexagon-h2-elf --cstdlib=picolibc when PICOLIBC=1, matching syscall/wrapper and locks. Without it posix_time.ref.c is still built against the legacy IDs, so the header change alone does not fix dispatch. Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
quic-k
requested review from
andreykarpenko-qc and
Bryan Bayerdorffer (bryanb-h2)
August 6, 2026 12:52
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.
posix_time.h defined its own CLOCK_* macros (0/1/2/3) from the Dinkumware libc, but Picolibc uses 1/2/3/4. Callers and the implementation disagreed: clock_gettime(CLOCK_MONOTONIC) returned EINVAL and CLOCK_REALTIME took the wrong branch.
Under Picolibc, take the clock IDs, clockid_t, struct timespec, and declarations from libc. Detect Picolibc via <picolibc.h> since PICOLIBC is not compiler-predefined, and declare the CPU-time and monotonic clock capabilities this target omits so all four IDs are exposed. The existing declarations are kept for the legacy libc.
Also compile libs/posix with --target=hexagon-h2-elf --cstdlib=picolibc when PICOLIBC=1, matching syscall/wrapper and locks. Without it posix_time.ref.c is still built against the legacy IDs, so the header change alone does not fix dispatch.