docs/143472: gethostname(3) references undefined value: HOST_NAME_MAX

Bruce Evans brde at
Sun Feb 13 10:09:36 UTC 2011

On Sat, 12 Feb 2011, Bruce Cran wrote:

> On Saturday 12 February 2011 22:17:16 Garrett Wollman wrote:
>> The Standard uses special typography to indicate these parameters; we
>> should, too.
> Having done further reading on I realised that the brackets do
> indicate that it's a value that can be obtained through sysconf(3).
> However, it's not especially clear to readers unfamiliar with the Standard,
> and has confused people in the past - for example http://www.mail-
> at .  I wonder if there's a way we
> can improve the documentation to make it clear that these values aren't
> necessarily preprocessor definitions?

o Use the braces in the thousands of places that they are needed instead
   of in only a few places.
o Document them in intro.2 if not already.
o Remove the compile-time constant values, especially for things like
   {OPEN_MAX} which were never constant in BSD, so that things break
   properly when variables are misspelled as constants
It would be nauseating to expand {FOO_MAX} in the thousands of places
where the limit might be variable.

> I've attached a patch to sysconf(3) which adds documentation of
> {HOST_NAME_MAX} and others.

The patch also replaces "cpu" by "machine".  But "machine" is similar to
"cpu" and is identical with the CPU name in many contexts, e.g.:
- the MACHINE make variable on i386 systems, er machines, is i386
- for uname(1):
   - uname -m gives the machine name, which is something like i386
   - uname -p gives the machine processor name, which is also something
     like i386
   - uname -n gives the system name, which is normally the host name
So gethostname(2) returns a system name, not a machine name, according
to the terminology of uname(1).  POSIX doesn't use this terminology
for gethostname() however.  The host name can be anything you want,
although other entities may want it to be what they want or what it
was.  Changing it from my fake internet domain name to i386 works here
according to hostname(1).  I didn't keep this setting for long or test
it with other entities.

The details of what uname -n returns are undocumented in in uname(1),
but uname(3) and <sys/utsname.h> says that the struct member `nodename'
contains the "Network [node] name".  POSIX says that `nodename' contains
the "name of this node within an implementation-defined communications
network".  But uname(1) is not required to print the same strings that
struct utsname holds, except as en extension, since there are large
unportabilities in this area.


More information about the freebsd-standards mailing list