Ben Walton <bwal...@artsci.utoronto.ca> writes: > Hi All, > > When testing the pending release of inetutils on solaris 9/10, I > discovered that sethostname isn't declared in unistd.h on Solaris. > The following patch adds handling for this although I'm not positive > that it's the best way to do it. At the very least it's a starting > point for discussing the best way to add the required support. > > Based on the 'not corrected by' section in > glibc-functions/sethostname.texi, I was tempted to make this a > separate module but decided not to go that far yet. If that's the > better or more proper solution, I don't mind resubmitting. > > Comments and criticisms are welcomed.
Have you tested that it resolves the portability issue? If so that is great. My man page says Solaris uses this prototype: int sethostname(char *name, int namelen); however possibly int and size_t have the same size on all Solaris 8 and 9 architectures? In any case, I support installing this if it does something useful on at least some (Solaris) machine, since the current situation does not appear to work on any (Solaris) machine. /Simon > Thanks > -Ben > > From 0dd943363bbd4d2884b8851ccbd703fee5eb6353 Mon Sep 17 00:00:00 2001 > From: Ben Walton <bwal...@artsci.utoronto.ca> > Date: Sat, 19 Nov 2011 23:13:08 +0100 > Subject: [PATCH] unistd: declare sethostname when required > > * m4/unistd_h.m4 (gl_UNISTD_H): Check for missing sethostname > declaration > * lib/unistd.in.h: Define sethostname if the function is available but > the prototype isn't. > > Signed-off-by: Ben Walton <bwal...@artsci.utoronto.ca> > --- > ChangeLog | 8 ++++++++ > doc/glibc-functions/sethostname.texi | 2 ++ > lib/unistd.in.h | 4 ++++ > m4/unistd_h.m4 | 6 ++++++ > 4 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 8725c92..aeaeb00 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,11 @@ > +2011-11-19 Ben Walton <bwal...@artsci.utoronto.ca> > + > + unistd: declare sethostname when required > + * m4/unistd_h.m4 (gl_UNISTD_H): Check for missing sethostname > + declaration > + * lib/unistd.in.h: Define sethostname if the function is > + available but the prototype isn't. > + > 2011-11-19 Bruno Haible <br...@clisp.org> > > Depend on module fcntl-h when AT_FDCWD is used. > diff --git a/doc/glibc-functions/sethostname.texi > b/doc/glibc-functions/sethostname.texi > index 64c4548..88d2ed8 100644 > --- a/doc/glibc-functions/sethostname.texi > +++ b/doc/glibc-functions/sethostname.texi > @@ -6,6 +6,8 @@ Gnulib module: --- > > Portability problems fixed by Gnulib: > @itemize > +Some platforms provide the function but not the prototype: > +Solaris 9 and 10. > @end itemize > > Portability problems not fixed by Gnulib: > diff --git a/lib/unistd.in.h b/lib/unistd.in.h > index f53f34b..057eaab 100644 > --- a/lib/unistd.in.h > +++ b/lib/unistd.in.h > @@ -683,6 +683,10 @@ _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " > # endif > #endif > > +#if HAVE_SETHOSTNAME && !HAVE_DECL_SETHOSTNAME > +_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) > + _GL_ARG_NONNULL ((1))); > +#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 57c8094..8b5cf6f 100644 > --- a/m4/unistd_h.m4 > +++ b/m4/unistd_h.m4 > @@ -21,6 +21,12 @@ AC_DEFUN([gl_UNISTD_H], > fi > AC_SUBST([HAVE_UNISTD_H]) > > + dnl Ensure there is a prototype for sethostname > + AC_CHECK_DECLS([sethostname]) > + dnl Detect the function too as we don't need the prototype if the function > + dnl isn't available. > + AC_CHECK_FUNCS([sethostname]) > + > dnl Ensure the type pid_t gets defined. > AC_REQUIRE([AC_TYPE_PID_T])