Skip to content

Commit

Permalink
Cygwin: uname: add host machine tag to sysname.
Browse files Browse the repository at this point in the history
If the Cygwin dll's architecture is different from the host system's
architecture, append an additional tag that indicates the host system
architecture (the Cygwin dll's architecture is already indicated in
machine).

Signed-off-by: Jeremy Drake <[email protected]>
  • Loading branch information
jeremyd2019 committed Nov 29, 2024
1 parent 38139ae commit b92714e
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions winsup/cygwin/uname.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,34 @@ uname_x (struct utsname *name)
{
char buf[NI_MAXHOST + 1] ATTRIBUTE_NONSTRING;
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
int n;

memset (name, 0, sizeof (*name));
/* sysname */
const char* sysname = get_sysname();
__small_sprintf (name->sysname, "%s_%s-%u%s",
sysname,
wincap.osname (), wincap.build_number (),
wincap.is_wow64 () ? "-WOW64" : "");
n = __small_sprintf (name->sysname, "%s_%s-%u",
sysname,
wincap.osname (), wincap.build_number ());
if (wincap.host_machine () != wincap.cygwin_machine ())
{
switch (wincap.host_machine ())
{
case IMAGE_FILE_MACHINE_AMD64:
/* special case for backwards compatibility */
if (wincap.cygwin_machine () == IMAGE_FILE_MACHINE_I386)
n = stpcpy (name->sysname + n, "-WOW64") - name->sysname;
else
n = stpcpy (name->sysname + n, "-x64") - name->sysname;
break;
case IMAGE_FILE_MACHINE_ARM64:
n = stpcpy (name->sysname + n, "-ARM64") - name->sysname;
break;
default:
n += __small_sprintf (name->sysname + n, "-%04y",
(int) wincap.host_machine ());
break;
}
}
/* nodename */
memset (buf, 0, sizeof buf);
cygwin_gethostname (buf, sizeof buf - 1);
Expand Down

0 comments on commit b92714e

Please sign in to comment.