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  <[email protected]>
> 
>       * 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

Attachment: pgpXfLq4lxgBf.pgp
Description: PGP signature

Reply via email to