Skip to content

Commit 7b6aff0

Browse files
pcloudsgitster
authored andcommitted
mingw32: add uname()
Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a3ddcef commit 7b6aff0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

compat/mingw.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,3 +2128,14 @@ void mingw_startup()
21282128
/* initialize Unicode console */
21292129
winansi_init();
21302130
}
2131+
2132+
int uname(struct utsname *buf)
2133+
{
2134+
DWORD v = GetVersion();
2135+
memset(buf, 0, sizeof(*buf));
2136+
strcpy(buf->sysname, "Windows");
2137+
sprintf(buf->release, "%u.%u", v & 0xff, (v >> 8) & 0xff);
2138+
/* assuming NT variants only.. */
2139+
sprintf(buf->version, "%u", (v >> 16) & 0x7fff);
2140+
return 0;
2141+
}

compat/mingw.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ struct itimerval {
7676
};
7777
#define ITIMER_REAL 0
7878

79+
struct utsname {
80+
char sysname[16];
81+
char nodename[1];
82+
char release[16];
83+
char version[16];
84+
char machine[1];
85+
};
86+
7987
/*
8088
* sanitize preprocessor namespace polluted by Windows headers defining
8189
* macros which collide with git local versions
@@ -171,6 +179,7 @@ struct passwd *getpwuid(uid_t uid);
171179
int setitimer(int type, struct itimerval *in, struct itimerval *out);
172180
int sigaction(int sig, struct sigaction *in, struct sigaction *out);
173181
int link(const char *oldpath, const char *newpath);
182+
int uname(struct utsname *buf);
174183

175184
/*
176185
* replacements of existing functions

0 commit comments

Comments
 (0)