refactor: deprecate *COUNT consts fitting #3131#5121
Open
dybucc wants to merge 1 commit into
Open
Conversation
Collaborator
These constants were already part of prior deprecation efforts in rust-lang#3620, though this was not completed. Alongside the work and comments there, a few other constants have been researched and marked for deprecation. The accompnying PR contains sources to upstream kernels/libraries with reasoning as to why some constants were deprecated and others weren't.
d36f780 to
70cd6ca
Compare
*COUNT consts fitting rust-lang/libc#3131
*COUNT consts fitting rust-lang/libc#3131*COUNT consts fitting #3131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Constants matching the
*COUNTnaming scheme, and whose purpose fits that of a "delimitter" valuehave been deprecated as part of the deprecation efforts stemming from #3131.
This patch continues deprecation of symbols matching one of the most common suffixes in identifiers
for constants whose value fits that of a "limit." The changes here follow from those in
#3620, with the recommended fixes by Amanieu (not pinging for now.)
This is a follow up PR to #5120.
Notes
A few of the constants I couldn't decide on under
mach/host_info.handsys/attr.hin Apple'sdistribution of the XNU kernel have been deprecated as per prior work by Lilit0x and comments by
Amanieu in #3620.
I couldn't pinpoint where was the
DLFO_STRUCT_HAS_EH_COUNTconstant declared and used in the GNUHurd upstream repo, so I haven't been able to make any decisions there.
Sources
Haiku sources showing how the
B_MEDIA_STALE_CHANGE_COUNTis not the type of constant wewould want to deprecate. The code upstream itself does not seem to use it as a delimitter value,
as can be seen in the second search result of the below reference.
https://github.com/search?q=repo%3Ahaiku%2Fhaiku%20B_MEDIA_STALE_CHANGE_COUNT&type=code
DragonFly BSD sources showing how the
CPUCTL_CPUID_COUNTconstant is not one we would wantto deprecate, even though it may seem like it could be deprecated (because it appears as a
*COUNTsymbol after a bunch of other symbols.) This constant is actually used for literal CPUcounts in
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/dev/misc/cpuctl/cpuctl.c#L145.
https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/cpuctl.h#L62
OpenBSD sources showing how the
KERN_TTYCOUNTis actually used as a counter for TTY devices andnot for other constants (just another enum-like "variant".) This does not qualify it for
deprecation.
https://github.com/search?q=repo%3Aopenbsd%2Fsrc%20KERN_TTYCOUNT&type=code
OpenBSD sources showing how the
KERN_EVCOUNTis used as an event counter (with use akin to thatof the above list item.) This does not qualify it for deprecation.
https://github.com/search?q=repo%3Aopenbsd%2Fsrc%20KERN_EVCOUNT&type=code
NetBSD sources showing how the
DCCP_OPT_NDP_COUNTconstant is used as just a regular constant(not meant for deprecation.)
https://github.com/NetBSD/src/blob/d28519920c966c62fedd65ccc0dbd8b628401da5/sys/netinet/dccp.h#L177
Linux sources showing how the
TIOCGICOUNTconstant seems to be used not as a counter for othersymbols but as (possibly runtime) interrumpt counter (not meant to be deprecated.)
https://github.com/torvalds/linux/blob/eb3f4b7426cfd2b79d65b7d37155480b32259a11/include/uapi/asm-generic/ioctls.h#L99
FreeBSD sources showing how the
IFMIB_IFCOUNTconstant is promptly liable to upstream changes asit denotes the number of configured interfaces.
https://github.com/freebsd/freebsd-src/blob/f9f46294d6af2a937afa74938bd4bb6826cbb921/sys/net/if_mib.h#L60
XNU kernel sources showing how the
RTV_HOPCOUNTis not the type of constant we would want todeprecate. It seems to be more of an enum "variant" among other similar constants.
https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/net/route.h#L228
Illumos sources showing that the
IPV6_MINHOPCOUNTis not dependent of other source code chagnes(and thus does not require deprecation.)
https://github.com/illumos/illumos-gate/blob/7124a0cccb6ebf2bcffdab36f9bdf8fe4c23d77f/usr/src/uts/common/netinet/in.h#L1309
L4RE sources showing how the
SIOCGIFCOUNTconstant is more of an enum "variant" among othervalues, and thus not a targe of these deprecation efforts.
https://github.com/search?q=repo%3Akernkonzept%2Fl4re-core%20SIOCGIFCOUNT&type=code
Illumos sources showing how the
LGRP_RSRC_COUNTconstant is meant to count the number ofresource types, which for the time being are the two constants below it.
https://github.com/search?q=repo%3Aillumos%2Fillumos-gate%20LGRP_RSRC_COUNT&type=code
Linux sources mentioning that the constants declared prior to the
NFNL_SUBSYS_COUNTsymbol couldhave been in an enumeration where the last value is the current "limit."
https://github.com/search?q=repo%3Atorvalds%2Flinux%20NFNL_SUBSYS_COUNT&type=code
Android sources replicating similar behavior as in Linux.
https://cs.android.com/search?q=NFNL_SUBSYS_COUNT&sq=&ss=android%2Fplatform%2Fsuperproject
Checklist
libc-test/semverhave been updated*LASTor*MAXareincluded (see #3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI