Skip to content

include: expose clock constants to POSIX.1b consumers - #68

Open
mihawk-99 wants to merge 1 commit into
ps5-payload-dev:masterfrom
mihawk-99:fix-posix-clock-visibility
Open

mihawk-99 wants to merge 1 commit into
ps5-payload-dev:masterfrom
mihawk-99:fix-posix-clock-visibility

Conversation

@mihawk-99

Copy link
Copy Markdown
Contributor

Code that selects _POSIX_C_SOURCE=199309L can see clock_gettime() in this SDK's <time.h>, but cannot use CLOCK_REALTIME: the constants are hidden until 200112. TIMER_ABSTIME has the same mismatch.

This showed up while porting code using libretro-common's threading helpers. Lowering the two visibility guards to 199309 lets those consumers compile without changing their feature-test macros. The numeric values and function declarations stay the same.

Current FreeBSD uses the same visibility level for these constants. In particular, its broader clock visibility is a compatibility choice; this PR does not claim every clock in the block was introduced in POSIX.1b.

Validation

Cross-compiled with Clang 23.1.1 targeting x86_64-sie-ps5. The following source fails against upstream and compiles with this change:

#define _POSIX_C_SOURCE 199309L
#include <time.h>

int clocks[] = {CLOCK_REALTIME, CLOCK_MONOTONIC, TIMER_ABSTIME};
int (*get_time)(clockid_t, struct timespec *) = clock_gettime;

From the repository root, save it as /tmp/sdk-clock-visibility.c and run:

clang -target x86_64-sie-ps5 -isystem include/freebsd \
    -fsyntax-only /tmp/sdk-clock-visibility.c

Also checked 199506L (fixed), 200112L, 200809L, and the default feature level (still compile), and 199209L (the constants remain hidden). This is a compile-time header fix; no console run was needed.

Code selecting _POSIX_C_SOURCE=199309L can see clock_gettime, but cannot use CLOCK_REALTIME or TIMER_ABSTIME from time.h. Lower the constant visibility guards to match the API declarations and current FreeBSD compatibility behavior.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant