Re: [PATCH v2 21/22] mingw32: add uname()

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

 



On Sat, Nov 8, 2014 at 4:39 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
> diff --git a/compat/mingw.c b/compat/mingw.c
> index c5c37e5..b817678 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -2128,3 +2128,14 @@ void mingw_startup()
>         /* initialize Unicode console */
>         winansi_init();
>  }
> +
> +int uname(struct utsname *buf)
> +{
> +       DWORD v = GetVersion();
> +       memset(buf, 0, sizeof(*buf));
> +       sprintf(buf->sysname, "Windows");

strcpy() maybe?

> +       sprintf(buf->release, "%u.%u", v & 0xff, (v >> 8) & 0xff);
> +       /* assuming NT variants only.. */
> +       sprintf(buf->version, "%u", (v >> 16) & 0x7fff);
> +       return 0;
> +}
> diff --git a/compat/mingw.h b/compat/mingw.h
> index df0e320..d00ba7a 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -77,6 +77,14 @@ struct itimerval {
>  };
>  #define ITIMER_REAL 0
>
> +struct utsname {
> +       char sysname[16];
> +       char nodename[1];
> +       char release[16];
> +       char version[16];
> +       char machine[1];
> +};
> +
>  /*
>   * sanitize preprocessor namespace polluted by Windows headers defining
>   * macros which collide with git local versions
> @@ -166,6 +174,7 @@ struct passwd *getpwuid(uid_t uid);
>  int setitimer(int type, struct itimerval *in, struct itimerval *out);
>  int sigaction(int sig, struct sigaction *in, struct sigaction *out);
>  int link(const char *oldpath, const char *newpath);
> +int uname(struct utsname *buf);
>
>  /*
>   * replacements of existing functions
> --
> 2.1.0.rc0.78.gc0d8480
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]