Skip to content

unix: add SSIZE_MAX constant for unix targets#5166

Open
telcharr wants to merge 1 commit into
rust-lang:mainfrom
telcharr:feature/ssize-max
Open

unix: add SSIZE_MAX constant for unix targets#5166
telcharr wants to merge 1 commit into
rust-lang:mainfrom
telcharr:feature/ssize-max

Conversation

@telcharr

@telcharr telcharr commented Jun 13, 2026

Copy link
Copy Markdown

Closes #1504

Description

Adds the POSIX SSIZE_MAX constant at the unix level. Defined as ssize_t::MAX, since ssize_t is isize on all unix targets making it correct on 32-bit, 64-bit, and x32 without any cfg. Binding the named constant is still worth it for discoverability and parity with the C API.

This is a fixed POSIX type limit, not a *MAX enumeration sentinel of the kind #3131 targets, so it's not a placeholder constant.

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

@rustbot label +stable-nominated

@rustbot rustbot added S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jun 13, 2026
@tgross35

Copy link
Copy Markdown
Contributor

We don't have numeric limits constants for other types, e.g. there is no SIZE_MAX or LONG_MAX on most platforms. Any reason ssize_t::MAX doesn't work?

@tgross35

Copy link
Copy Markdown
Contributor

@rustbot author for clarification

@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@telcharr

telcharr commented Jun 19, 2026

Copy link
Copy Markdown
Author

ssize_t::MAX does work. This is really just for parity with the C API rather than a functional gap. The only thing that nudged me towards it was that INT_MIN/INT_MAX are already at the unix level, so there seemed to be some precedent. Though those look like the only type-limit constants there, so if they're more of a holdover than something you want to extend, happy to close this. Your call.

@telcharr

Copy link
Copy Markdown
Author

@rustbot ready

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

Labels

S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose SSIZE_MAX to enable safe/portable read and write system calls

3 participants