Skip to content
Commit 821c1424 authored by Chris Friedt's avatar Chris Friedt Committed by Maureen Helm
Browse files

posix: sysconf: declare sysconf macro values more reliably

The `sysconf()` implementation in Zephyr can be macro-based or
library-based. Both approaches use the same set of runtime-invariant
definitions in `sys/sysconf.h`.

These were previously fine, as long as POSIX limits were
guaranteed to be defined. However, some C libraries omit definitions
for runtime-invariants values and instead force the application to
query values via `sysconf()`.

The specification formally supports that approach [1]. Normally,
definitions are allowed to do so "on specific implementations where the
corresponding value is equal to or greater than the stated minimum, but
is unspecified." In practice, that is not always the case, but we need
to be able to compile `sysconf()` anyway.

Notable constants that are missing in Picolibc or Newlib include:

- AIO_LISTIO_MAX
- AIO_MAX
- AIO_PRIO_DELTA_MAX
- CHILD_MAX
- DELAYTIMER_MAX
- HOST_NAME_MAX
- IOV_MAX
- LOGIN_NAME_MAX
- MQ_OPEN_MAX
- MQ_PRIO_MAX
- OPEN_MAX
- PAGESIZE
- PAGE_SIZE
- PTHREAD_DESTRUCTOR_ITERATIONS
- PTHREAD_KEYS_MAX
- PTHREAD_THREADS_MAX
- RTSIG_MAX
- SEM_NSEMS_MAX
- SEM_VALUE_MAX
- SIGQUEUE_MAX
- SS_REPL_MAX
- STREAM_MAX
- SYMLOOP_MAX
- TIMER_MAX
- TTY_NAME_MAX

For greater portability, define those values using

1. a Kconfig-derived definition,
2. a symbolic minimum value (required by the spec), or
3. a numeric minimum value (if the required symbolic minimum is missing).

[1]
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html



Signed-off-by: default avatarChris Friedt <cfriedt@tenstorrent.com>
parent ef7c4dc3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment