Ben Walton wrote: > Ensure that sethostname is accounted for within the unistd module.
Thanks, I'm applying this patch as well. > 2011-12-01 Ben Walton <bwal...@artsci.utoronto.ca> > > + * lib/unistd.in.h: Integrate the SETHOSTNAME preprocessor handling > + into the unistd.h header. > + * m4/unistd_h.m4: Setup the autoconf handling for the SETHOSTNAME > + preprocessor directives. > + * modules/unistd: Setup the Makefile substitutions of the > + SETHOSTNAME preprocessor directives. I removed the extra spaces, for consistency with other ChangeLog entries. > +#if @GNULIB_SETHOSTNAME@ > +/* Set the host name of the machine. > + The host name may or may not be fully qualified. > + > + Put LEN bytes of NAME into the host name. > + Return 0 if successful, otherwise, set errno and return -1 > + > + Platforms with no ability to set the hostname return -1 and set > + errno = ENOSYS. */ > +# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ This preprocessor directive line has too much indentation. > +#elif defined GNULIB_POSIXCHECK > +# undef gethostname Should be sethostname, not gethostname. > +# if HAVE_RAW_DECL_GETHOSTNAME Likewise. > +_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " > + "use gnulib module sethostname for portability"); Also, in this file, the chunks are ordered alphabetically according to the function name. I don't like this, but that's the way it is now. > @@ -95,6 +95,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], > GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) > GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) > GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) > + GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME]) > GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) > GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) > GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) > @@ -131,6 +132,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], > HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) > HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) > HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) > + HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) > HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) > HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) > HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) Here the lists are apparently sorted alphabetically as well. 'sethostname' ought to come before 'sleep'. > -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ > -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ > -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ > + -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ > -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ > -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ > -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ Likewise. The complete set of tweaks that I'm adding: 2011-12-03 Bruno Haible <br...@clisp.org> Tweak last commit. * lib/unistd.in.h (sethostname): Keep declarations in alphabetic order. Fix preprocessor directives indentation. Fix typos. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Keep alphabetic order. * modules/unistd (Makefile): Likewise. --- lib/unistd.in.h.orig Sat Dec 3 14:19:50 2011 +++ lib/unistd.in.h Sat Dec 3 14:17:26 2011 @@ -683,31 +683,6 @@ # endif #endif -#if @GNULIB_SETHOSTNAME@ -/* Set the host name of the machine. - The host name may or may not be fully qualified. - - Put LEN bytes of NAME into the host name. - Return 0 if successful, otherwise, set errno and return -1 - - Platforms with no ability to set the hostname return -1 and set - errno = ENOSYS. */ -# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ -_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) - _GL_ARG_NONNULL ((1))); -# endif -/* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5 - and FreeBSD 6.4 the second parameter is int. On Solaris 11 - 2011-10, the first parameter is not const. */ -_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); -_GL_CXXALIASWARN (sethostname); -#elif defined GNULIB_POSIXCHECK -# undef gethostname -# if HAVE_RAW_DECL_GETHOSTNAME -_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " - "use gnulib module sethostname for portability"); -# endif -#endif #if @GNULIB_GETHOSTNAME@ /* Return the standard host name of the machine. @@ -1292,6 +1267,33 @@ # endif #endif + +#if @GNULIB_SETHOSTNAME@ +/* Set the host name of the machine. + The host name may or may not be fully qualified. + + Put LEN bytes of NAME into the host name. + Return 0 if successful, otherwise, set errno and return -1. + + Platforms with no ability to set the hostname return -1 and set + errno = ENOSYS. */ +# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ +_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) + _GL_ARG_NONNULL ((1))); +# endif +/* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5 + and FreeBSD 6.4 the second parameter is int. On Solaris 11 + 2011-10, the first parameter is not const. */ +_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +_GL_CXXALIASWARN (sethostname); +#elif defined GNULIB_POSIXCHECK +# undef sethostname +# if HAVE_RAW_DECL_SETHOSTNAME +_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " + "use gnulib module sethostname for portability"); +# endif +#endif + #if @GNULIB_SLEEP@ /* Pause the execution of the current thread for N seconds. --- m4/unistd_h.m4.orig Sat Dec 3 14:19:50 2011 +++ m4/unistd_h.m4 Sat Dec 3 14:18:24 2011 @@ -94,8 +94,8 @@ GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) - GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME]) + GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) @@ -131,8 +131,8 @@ HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) - HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) + HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) --- modules/unistd.orig Sat Dec 3 14:19:50 2011 +++ modules/unistd Sat Dec 3 14:19:22 2011 @@ -104,8 +104,8 @@ -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ - -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \ + -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -- In memoriam Rudolf Slánský <http://en.wikipedia.org/wiki/Rudolf_Slánský>