bug-gnulib
[Top][All Lists]
Advanced

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

declare sethostname if unistd.h doesn't


From: Ben Walton
Subject: declare sethostname if unistd.h doesn't
Date: Sat, 19 Nov 2011 22:43:49 -0500
User-agent: Sup/git

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.

Thanks
-Ben

>From 0dd943363bbd4d2884b8851ccbd703fee5eb6353 Mon Sep 17 00:00:00 2001
From: Ben Walton <address@hidden>
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 <address@hidden>
---
 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   <address@hidden>
+
+       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  <address@hidden>
 
        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])
 
-- 
1.7.5.4

--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302




reply via email to

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