Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "placeholder constants" #3131

Open
Tracked by #3248
workingjubilee opened this issue Mar 2, 2023 · 3 comments
Open
Tracked by #3248

Remove "placeholder constants" #3131

workingjubilee opened this issue Mar 2, 2023 · 3 comments
Labels
breakage-candidate C-bug Category: bug E-medium E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
Milestone

Comments

@workingjubilee
Copy link
Member

It's common for C APIs to define constant values to denote the "last" value in a set of constants, like ELAST or IPPROTO_MAX. This seems prone to weird bugs, and these constants provide very marginal benefit to Rust programmers. Since we're considering some breakage anyways, we should just remove these values where we are made aware of them.

See:

@JohnTitor
Copy link
Member

👍, before 0.3, I'd like to deprecate these values.

@JohnTitor
Copy link
Member

Noticed that we have a lot of *MAX consts and deprecating manually is quite hard. We could write a script but it can cause a false positive, hmm. For now, I've edited the PR template to mention this concern.

@Amanieu
Copy link
Member

Amanieu commented Mar 15, 2024

An alternative to deleting these placeholder constants would be to still provide them but not make any guarantees about their value moving forward. This means that we would be free to change the value of these constants without it being considered a breaking change.

CI tests should specifically exclude these, although it would be nice to make CI fail only if our value for such constants is lower than the one on the system.

tgross35 pushed a commit to tgross35/rust-libc that referenced this issue Mar 10, 2025
These socket options are currently defined only on macOS and friends,
but they exist on illumos and Solaris as well.

This commit defines these socket options on solarish operating systems.

On Solaris, see the man page [`ip(7P)`].

I'd like to provide a link to the illumos manual pages, but apparently
https://illumos.org/man seems to be impacted by today's AWS outage.

The constants are defined in `/usr/include/netinet/in.h`:

```console
eliza@atrium ~ $ uname -a
SunOS atrium 5.11 helios-2.0.22827 i86pc i386 i86pc
eliza@atrium ~ $ rg 'IP(V6)?_BOUND_IF' /usr/include
/usr/include/netinet/in.h
978:#define   IP_BOUND_IF                0x41    /* bind socket to an ifindex       */
1311:#define  IPV6_BOUND_IF              0x41    /* bind to an ifindex */
```

[`ip(7P)`]: https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html

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

(backport <rust-lang#4287>)
(cherry picked from commit 885148d)
@lucab lucab mentioned this issue Mar 10, 2025
3 tasks
@mvolfik mvolfik mentioned this issue Mar 27, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakage-candidate C-bug Category: bug E-medium E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
Projects
None yet
Development

No branches or pull requests

4 participants