Skip to content

refactor: deprecate *MAX constants fitting #3131#5122

Open
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:_max-deprecation
Open

refactor: deprecate *MAX constants fitting #3131#5122
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:_max-deprecation

Conversation

@dybucc
Copy link
Copy Markdown
Contributor

@dybucc dybucc commented May 29, 2026

Description

Constants matching the *MAX naming scheme and whose purpose is that of denoting a limit among
other symbols have been deprecated in this patch. This stems from the deprecation efforts in #3131.

This is a follow up PR to #5120.

Notes

All of the sysconf constants have been ignored here because they themselves do not indicate value
that is a limit. Those constants, prefixed by _SC_, are meant to be issued to the sysconf()
library function, such that the actual limit is returned. The same applies to _PC_-prefixed
constants, which analogously apply to the pathconf() library routine. All of these limits are
supposed to be declared in limits.h by the target system's implementaion. Ofttimes, these are
actually meant to set a limit with respect to some system configuration, that is at least as large
as the POSIX-defined limit. I would like to ping here @JohnTitor (following from his comments on
[1]) and @tgross35, because I don't think these should be deprecated, but I could be wrong. Yes,
as per Chapter 11 of The Linux Programming Interface, these values can change at runtime (the most
concerning being the runtime increasable values), but I haven't been able to find out exactly which
of all constants that have a POSIX-defined limit should be deprecated. Should I just go for all of
those that are not classified as runtime invariant values?

Reading through the latest POSIX.1.2024 specification, it mentions in the limits.h file that there
is no guarantee that values that are not explicitly runtime invariant be read straight from the
limits.h macro definition without incurring possible runtime modifications [2]. It then goes on
to say that applications wishing for maximum portability ought use one of the afore-mentioned
library routines, among others. Considering setrlimit is itself used to change some of those
limits, I am lead to believe I should deprecate all constants that can be fetched by issuing one of
the _SC- or _PC-prefixed constants to sysconf or pathconf (or, for that matter,
fpathconf.) This, of course, should exempt those constants that are known to be runtime invariant.
The issue here lies in that it may very well be that some target system implementation we expose
through the libc crate does not necessarily adopt POSIX-compliance in this respect. Should I then
abide by the POSIX standard and call it a day? One example where this can lead to conflict is that
the TMP_MAX symbol was retired in Issue 6 of the spec, but that constant is still prevalent in a
number of the target systems we expose a C interface to. But this symbol predates even SUSv3, and
can only be found documented in SUSv2 [3]. Should we just follow the same path as we did with time
and file offset types, and go for the modern alternative? A different issue related to compliance is
the fact that some target environments allow modifying what are meant to be runtime invariant
values. This can be seen in NetBSD's implementation of sysctl, where AIO_LISTIO_MAX nor
AIO_MAX are not meant to be changeable, but [4] states they are.

I couldn't get a hold of the QNX sources. I got past their whole sign up and SDK request, but I once
I got to downloading the actual package from the so called QNX Software Development Center, the
binary would not launch. I tried in both Linux and Windows virtual machines, but I had no luck. No
constants that were not already specified in POSIX as not being runtime invariant have been modified
from their current state.

Also, the below notes on each source I've looked into contain some constants for which I have been,
for the time being, unable to decide on their deprecation for reasons outside those mentioned above.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@dybucc dybucc changed the title refactor: deprecate *MAX constants fitting rust-lang/libc#3131 refactor: deprecate *MAX constants fitting rust-lang/libc#3131 May 29, 2026
@dybucc dybucc changed the title refactor: deprecate *MAX constants fitting rust-lang/libc#3131 refactor: deprecate *MAX constants fitting #3131 May 29, 2026
@dybucc dybucc force-pushed the _max-deprecation branch 11 times, most recently from 5ee0951 to 3bc30cb Compare May 30, 2026 10:15
@dybucc dybucc marked this pull request as ready for review May 30, 2026 16:19
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2026

Some changes occurred in an Android module

cc @maurer

Some changes occurred in an OpenBSD module

cc @semarie

Some changes occurred in a NetBSD-like module

cc @semarie

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

These constants, beyond their naming scehem, have been deemed to be a
hindrance to the SemVer breakage guarantees that follows `libc`. This
stems from the deprecation efforts in rust-lang#3131.

More information about background knowledge on the decision to deprecate
each constant can be found in the accompanying PR.
@dybucc dybucc force-pushed the _max-deprecation branch from cb9c814 to 0141e49 Compare June 4, 2026 07:09
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 4, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants