Skip to content

Commit

Permalink
mingw32: add uname()
Browse files Browse the repository at this point in the history
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Mar 12, 2015
1 parent a3ddcef commit 7b6aff0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
strcpy(buf->sysname, "Windows");
sprintf(buf->release, "%u.%u", v & 0xff, (v >> 8) & 0xff);
/* assuming NT variants only.. */
sprintf(buf->version, "%u", (v >> 16) & 0x7fff);
return 0;
}
9 changes: 9 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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
Expand Down Expand Up @@ -171,6 +179,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
Expand Down

0 comments on commit 7b6aff0

Please sign in to comment.