[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gethostname

From: Bruno Haible
Subject: Re: gethostname
Date: Tue, 12 Aug 2008 10:26:43 +0200
User-agent: KMail/1.5.4

Sam Steingold asked:
> gnulib/lib/gethostname.c says:
> #ifdef HAVE_UNAME
> # include <sys/utsname.h>
> #endif
> 1. why aren't you testing for HAVE_SYS_UTSNAME_H instead?

All systems that have uname() also have <sys/utsname.h>.
We estimate the probability that a system with <sys/utsname.h> also has uname()
to 99%.

> 2. are there really systems without uname & <sys/utsname.h>, given that these 
> are in posix? 
> http://www.opengroup.org/onlinepubs/009695399/functions/uname.html

Yes, some old systems did not have uname() and <sys/utsname.h>: especially
SunOS 4. But these are not porting targets today any more.

Simon Josefsson wrote:
> I think the right solution here should be to apply the patch below.  If
> there are problems on any system caused by that, the solution to that
> problem should be to create a module for sys/utsname.h and uname.

The gnulib docs (doc/posix-functions/{gethostname,uname}.texi) say that
uname and gethostname are both missing on mingw systems. If your patch
is applied in the current state, it causes a link error on mingw.

Feel free to contribute an uname() substitute, however. With that in place,
your patch can be applied without damage.

> The gethostname module shouldn't depend on such modules, they need to be
> added manually by maintainers who want compatibility with non-POSIX
> systems.

mingw portability is requested quite often, therefore gnulib includes the
dependencies needed for mingw portability. We omit dependencies only for
extremely old systems (e.g. BSD 4.2 - missing memcpy()).

Sam Steingold wrote:
> note that gethostname is just as posix as uname,
> http://www.opengroup.org/onlinepubs/009695399/functions/gethostname.html
> so the gethostname module is only needed for non-posix systems.

Historically, uname came from SysV, and gethostname came from BSD.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]