[PATCH] Hide sethostname() in unistd.h
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Jun 16 17:45:00 GMT 2015
On Jun 16 18:27, Christian Franke wrote:
> Found during an experimental build of busybox:
>
> The sethostname() prototype in /usr/include/sys/unistd.h is enabled also on
> Cygwin.
> It should be disabled because Cygwin does not provide this function.
>
> Christian
>
> 2015-06-16 Christian Franke <franke@computer.org>
>
> * libc/include/sys/unistd.h (sethostname): Hide prototype on Cygwin.
>
> diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
> index eb26921..6131b5c 100644
> --- a/newlib/libc/include/sys/unistd.h
> +++ b/newlib/libc/include/sys/unistd.h
> @@ -169,7 +169,7 @@ int _EXFUN(setgid, (gid_t __gid ));
> #if defined(__CYGWIN__)
> int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
> #endif
> -#if __BSD_VISIBLE || (defined(_XOPEN_SOURCE) && __XSI_VISIBLE < 500)
> +#if !defined(__CYGWIN__) && (__BSD_VISIBLE || (defined(_XOPEN_SOURCE) && __XSI_VISIBLE < 500))
> int _EXFUN(sethostname, (const char *, size_t));
> #endif
> int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
What about implementing sethostname instead?
extern "C" int
sethostname (const char *name, size_t len)
{
WCHAR wname[MAX_COMPUTERNAME_LENGTH + 1];
sys_mbstowcs (wname, MAX_COMPUTERNAME_LENGTH + 1, name, len);
if (!SetComputerNameEx (ComputerNamePhysicalDnsHostname, wname))
{
__seterrno ();
return -1;
}
return 0;
}
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20150616/626eb903/attachment.sig>
More information about the Cygwin-patches
mailing list