From 702c54a39c051aeba54d0207c0e58adcf7544750 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 18 Oct 2023 15:26:30 -0700 Subject: [PATCH] Add documentation for how to do the equivalent of `gethostname`. (#880) Add documentation showing how to get the `gethostname` value using `uname`. --- src/system.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/system.rs b/src/system.rs index 068d23717..8efe3cd68 100644 --- a/src/system.rs +++ b/src/system.rs @@ -20,6 +20,8 @@ pub use backend::system::types::Sysinfo; /// `uname()`—Returns high-level information about the runtime OS and /// hardware. /// +/// For `gethostname()`, use [`Uname::nodename`] on the result. +/// /// # References /// - [POSIX] /// - [Linux] @@ -40,6 +42,7 @@ pub use backend::system::types::Sysinfo; /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=uname§ion=3 /// [illumos]: https://illumos.org/man/2/uname /// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Platform-Type.html +#[doc(alias = "gethostname")] #[inline] pub fn uname() -> Uname { Uname(backend::system::syscalls::uname()) @@ -61,6 +64,8 @@ impl Uname { /// This is intended to be a network name, however it's unable to convey /// information about hosts that have multiple names, or any information /// about where the names are visible. + /// + /// This corresponds to the `gethostname` value. #[inline] pub fn nodename(&self) -> &CStr { Self::to_cstr(self.0.nodename.as_ptr().cast())