Skip to content

Use Picolibc clock IDs in H2 POSIX time support - #92

Open
quic-k wants to merge 1 commit into
masterfrom
pico-clock
Open

Use Picolibc clock IDs in H2 POSIX time support#92
quic-k wants to merge 1 commit into
masterfrom
pico-clock

Conversation

@quic-k

@quic-k quic-k commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untested Mark untested PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant