getdomainname: Use the system function when possible.
authorBruno Haible <bruno@clisp.org>
Tue, 30 Nov 2010 20:27:21 +0000 (21:27 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 30 Nov 2010 20:27:21 +0000 (21:27 +0100)
commitb4417f755d2a8e39cb2052dbe949cae5d6971faf
tree5d741f2386f8da14ccaf7f9e4c19ca7a5cc6b0b2
parent5500698d4bebe8c204bfeb88673f71240647686a
getdomainname: Use the system function when possible.

* lib/unistd.in.h: Include <netdb.h>, for getdomainname's declaration.
(getdomainname): Replace if needed. Provide the declaration if it is
missing. Don't use _GL_CXXALIAS_SYS_CAST.
* lib/getdomainname.c: Include <limits.h> and <sys/systeminfo.h>.
(getdomainname): When the system has getdomainname, call the system
function. When sysinfo (SI_SRPC_DOMAIN, ...) is possible, use that.
* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Require
gl_HEADER_SYS_SOCKET and gl_HEADER_NETDB. Test whether the function is
found in libnsl. Look for the declaration also in <netdb.h>. Replace
the function if its second argument is of type 'int' or if it is found
in libnsl.
(gl_PREREQ_GETDOMAINNAME): Define HAVE_GETDOMAINNAME. Check for
<sys/systeminfo.h> and sysinfo().
* modules/getdomainname (Depends-on): Add netdb, sys_socket.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
HAVE_DECL_GETDOMAINNAME and REPLACE_GETDOMAINNAME instead of
HAVE_GETDOMAINNAME.
* modules/unistd (Makefile.am): Substitute HAVE_DECL_GETDOMAINNAME and
REPLACE_GETDOMAINNAME instead of HAVE_GETDOMAINNAME.
* doc/glibc-functions/getdomainname.texi: Document the problems with
the getdomainname declaration.
ChangeLog
doc/glibc-functions/getdomainname.texi
lib/getdomainname.c
lib/unistd.in.h
m4/getdomainname.m4
m4/unistd_h.m4
modules/getdomainname
modules/unistd