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).
---
You may well want me to remove some cases from the switch ;)

 winsup/cygwin/uname.cc | 44 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index dd4160189c..40030fba16 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -24,6 +24,49 @@ extern "C" int getdomainname (char *__name, size_t __len);
 #define ATTRIBUTE_NONSTRING
 #endif

+static int
+append_host_suffix (char * buf)
+{
+  USHORT host = wincap.host_machine ();
+  USHORT cygwin = wincap.current_module_machine ();
+  int n = 0;
+  if (host != cygwin)
+    {
+      switch (host)
+       {
+         case IMAGE_FILE_MACHINE_AMD64:
+           /* special case for backwards compatibility */
+           if (cygwin == IMAGE_FILE_MACHINE_I386)
+             {
+               strcpy (buf, "-WOW64");
+               n = 6;
+             }
+           else
+             {
+               strcpy (buf, "-x64");
+               n = 4;
+             }
+           break;
+         case IMAGE_FILE_MACHINE_I386:
+           strcpy (buf, "-x86");
+           n = 4;
+           break;
+         case IMAGE_FILE_MACHINE_ARMNT:
+           strcpy (buf, "-ARM");
+           n = 4;
+           break;
+         case IMAGE_FILE_MACHINE_ARM64:
+           strcpy (buf, "-ARM64");
+           n = 6;
+           break;
+         default:
+           n = __small_sprintf (buf, "-%04y", host);
+           break;
+       }
+    }
+  return n;
+}
+
 /* uname: POSIX 4.4.1.1 */

 /* New entrypoint for applications since API 335 */
@@ -38,6 +81,7 @@ uname_x (struct utsname *name)
       /* sysname */
       __small_sprintf (name->sysname, "CYGWIN_%s-%u",
                       wincap.osname (), wincap.build_number ());
+      append_host_suffix (name->sysname + n);
       /* nodename */
       memset (buf, 0, sizeof buf);
       cygwin_gethostname (buf, sizeof buf - 1);
-- 
2.47.0.windows.2

Reply via email to