unix: add HOST_NAME_MAX - #5531
Open
Yasser-Ameur wants to merge 2 commits into
Open
Yasser-Ameur wants to merge 2 commits into
Yasser-Ameur wants to merge 2 commits into
Conversation
POSIX requires HOST_NAME_MAX in <limits.h> for use with gethostname, and it was missing everywhere except Fuchsia. Added it per family, glibc and uclibc at 64 and the musl-derived and BSD-ish libcs at 255, skipping FreeBSD, NetBSD, DragonFly, Apple, Solaris/illumos and Hurd, which deliberately leave it undefined for sysconf instead. glibc 64: https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/local_lim.h#L93 uclibc-ng 64: https://github.com/kraj/uclibc-ng/blob/f6f9f40cb17ae95610c4fe36f6ee77cfbcf05df1/libc/sysdeps/linux/common/bits/local_lim.h#L93 musl 255: https://git.musl-libc.org/cgit/musl/tree/include/limits.h?id=5e9972eaef08ccf55dabe254ac829a30329793d3#n56 android bionic 255: https://github.com/aosp-mirror/platform_bionic/blob/731631f300090436d7f5df80d50b6275c8c60a93/libc/include/bits/posix_limits.h#L135 openbsd 255: https://github.com/openbsd/src/blob/78e3ccc2aa1724882faaab7fa2366e535f039976/sys/sys/syslimits.h#L76 haiku 255: https://github.com/haiku/haiku/blob/89141b6857474342330f6205850b59435165187b/headers/posix/limits.h#L35 redox 255: https://github.com/redox-os/relibc/blob/381772ec81fced6d055f0f0ba6fa92c7f3256fbb/src/header/limits/mod.rs#L145 emscripten 255: https://github.com/emscripten-core/emscripten/blob/06e8b0d84d8b409b1b5ee59832948877bda6137e/system/lib/libc/musl/include/limits.h#L63 wasi 255: https://github.com/WebAssembly/wasi-libc/blob/06513b9ae0c1b14ca3010924939c007ed27628a1/libc-top-half/musl/include/limits.h#L56 cygwin 255: https://github.com/cygwin/cygwin/blob/00208dc31e790b8c130f32c4a0528c781fc07328/winsup/cygwin/include/cygwin/limits.h#L22
Collaborator
tgross35
requested changes
Sep 17, 2026
Comment on lines
1220
to
1227
| pub const _SC_GETGR_R_SIZE_MAX: c_int = 100; | ||
| pub const _SC_GETPW_R_SIZE_MAX: c_int = 101; | ||
| pub const _SC_LOGIN_NAME_MAX: c_int = 102; | ||
| /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) | ||
| /// for details. | ||
| pub const HOST_NAME_MAX: c_int = 255; | ||
| pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 103; | ||
| pub const _SC_TRACE_NAME_MAX: c_int = 104; |
Member
There was a problem hiding this comment.
Move this to either side of the existing _SC group
Comment on lines
525
to
529
| pub const _SC_HOST_NAME_MAX: c_int = 180; | ||
| /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) | ||
| /// for details. | ||
| pub const HOST_NAME_MAX: c_int = 255; | ||
| pub const _SC_TRACE: c_int = 181; |
Comment on lines
+448
to
+449
| /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) | ||
| /// for details. |
Member
There was a problem hiding this comment.
You can drop these comments, this isn't quite as volatile as other _MAX constants that change every time we get a new one
| GLOB_TILDE | ||
| GLOB_TILDE_CHECK | ||
| HOSTFS_SUPER_MAGIC | ||
| HOST_NAME_MAX |
Member
There was a problem hiding this comment.
Put this in linux.txt rather than linux-gnu and linux-musl since it's present on all environments
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
…emver entry Review cleanups: the OpenBSD and WASI constants sit after their _SC groups instead of inside them, the volatility comments are dropped since this value does not change between releases, and the semver entry lives in linux.txt rather than in both linux-gnu.txt and linux-musl.txt.
Contributor
Author
|
Done: OpenBSD and WASI moved after their @rustbot ready |
tgross35
approved these changes
Sep 17, 2026
Member
|
@rustbot author for squash |
xtqqczze
approved these changes
Sep 17, 2026
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.
Adds
HOST_NAME_MAXwhere the platform's own limits header defines it: 64 for glibc and uclibc-ng, 255 for musl, Android, OpenBSD, Haiku, Redox, Emscripten, WASI and Cygwin. Not added for FreeBSD, NetBSD, DragonFly, Apple, illumos and Hurd, whose headers leave it undefined on purpose (sysconf only). Header sources for each value are in the commit message.ctest passes for x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl, with the constant present in the generated test source for both.
Closes #5511