From: Eric Sunshine Date: Sun, 09 Nov 2014 03:32:08 GMT Subject: Re: [PATCH v2 21/22] mingw32: add uname() Message-ID: In-Reply-To: <1415439595-469-22-git-send-email-pclouds@gmail.com> On Sat, Nov 8, 2014 at 4:39 AM, Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > 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