Ensure that sethostname is accounted for within the unistd module. Signed-off-by: Ben Walton <bwal...@artsci.utoronto.ca> --- ChangeLog | 9 +++++++++ lib/unistd.in.h | 25 +++++++++++++++++++++++++ m4/unistd_h.m4 | 7 +++++-- modules/unistd | 3 +++ 4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog index c6cf901..67f7f42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 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. + +2011-12-01 Ben Walton <bwal...@artsci.utoronto.ca> + * lib/sethostname.c (sethostname): New file. Provide sethostname for systems that lack it * m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): New file. Detection of diff --git a/lib/unistd.in.h b/lib/unistd.in.h index f53f34b..d01f68d 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -683,6 +683,31 @@ _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " # 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. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index b4eca68..d3fa586 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -43,8 +43,8 @@ AC_DEFUN([gl_UNISTD_H], fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups gethostname getlogin getlogin_r getpagesize getusershell setusershell endusershell group_member lchown link linkat lseek pipe pipe2 pread pwrite - readlink readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat - usleep]) + readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r + unlink unlinkat usleep]) ]) AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], @@ -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]) @@ -142,6 +144,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) + HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) diff --git a/modules/unistd b/modules/unistd index 0cee9b3..a9160eb 100644 --- a/modules/unistd +++ b/modules/unistd @@ -66,6 +66,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ + -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ @@ -104,6 +105,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -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' \ @@ -115,6 +117,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ + -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ -- 1.7.4.1