Add support for Windows CE and various non-x86 CPU types.
authorPaolo Bonzini <bonzini@gnu.org>
Sat, 3 Oct 2009 17:53:31 +0000 (19:53 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Oct 2009 17:53:31 +0000 (19:53 +0200)
ChangeLog
lib/uname.c

index e747ef6..2d8cf65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-03  Paolo Bonzini  <bonzini@gnu.org>
+           Bruno Haible  <bruno@clisp.org>
+
+       * lib/uname.c (VER_PLATFORM_WIN32_CE, PROCESSOR_ARCHITECTURE_AMD64,
+       PROCESSOR_ARCHITECTURE_IA32_ON_WIN64): Define fallbacks.
+       (uname): Add support for Windows CE and various non-x86 CPU types.
+
 2009-10-03  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool (func_create_testdir): Conditionally emit AM_PROG_CC_C_O
index 7a0ce32..70ebb95 100644 (file)
 #include <unistd.h>
 #include <windows.h>
 
-/* Mingw headers don't have latest processor codes.  */
+/* Mingw headers don't have all the platform codes.  */
+#ifndef VER_PLATFORM_WIN32_CE
+# define VER_PLATFORM_WIN32_CE 3
+#endif
+
+/* Some headers don't have all the processor architecture codes.  */
+#ifndef PROCESSOR_ARCHITECTURE_AMD64
+# define PROCESSOR_ARCHITECTURE_AMD64 9
+#endif
+#ifndef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
+# define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
+#endif
+
+/* Mingw headers don't have the latest processor codes.  */
 #ifndef PROCESSOR_AMD_X8664
 # define PROCESSOR_AMD_X8664 8664
 #endif
@@ -51,6 +64,11 @@ uname (struct utsname *buf)
       /* Windows NT or newer.  */
       super_version = "NT";
     }
+  else if (version.dwPlatformId == VER_PLATFORM_WIN32_CE)
+    {
+      /* Windows CE or Embedded CE.  */
+      super_version = "CE";
+    }
   else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
     {
       /* Windows 95/98/ME.  */
@@ -138,6 +156,13 @@ uname (struct utsname *buf)
       else
        strcpy (buf->release, "Windows");
     }
+  else if (version.dwPlatformId == VER_PLATFORM_WIN32_CE)
+    {
+      /* Windows CE or Embedded CE.  */
+      sprintf (buf->release, "Windows CE %u.%u",
+              (unsigned int) version.dwMajorVersion,
+              (unsigned int) version.dwMinorVersion);
+    }
   else
     {
       /* Windows 95/98/ME.  */
@@ -150,11 +175,12 @@ uname (struct utsname *buf)
     SYSTEM_INFO info;
 
     GetSystemInfo (&info);
-    /* Check for Windows NT, since the info.wProcessorLevel is
+    /* Check for Windows NT or CE, since the info.wProcessorLevel is
        garbage on Windows 95. */
-    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT)
+    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT
+       || version.dwPlatformId == VER_PLATFORM_WIN32_CE)
       {
-       /* Windows NT or newer.  */
+       /* Windows NT or newer, or Windows CE or Embedded CE.  */
        switch (info.wProcessorArchitecture)
          {
          case PROCESSOR_ARCHITECTURE_AMD64:
@@ -169,6 +195,25 @@ uname (struct utsname *buf)
              buf->machine[1] =
                '0' + (info.wProcessorLevel <= 6 ? info.wProcessorLevel : 6);
            break;
+         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+           strcpy (buf->machine, "i686");
+           break;
+         case PROCESSOR_ARCHITECTURE_MIPS:
+           strcpy (buf->machine, "mips");
+           break;
+         case PROCESSOR_ARCHITECTURE_ALPHA:
+         case PROCESSOR_ARCHITECTURE_ALPHA64:
+           strcpy (buf->machine, "alpha");
+           break;
+         case PROCESSOR_ARCHITECTURE_PPC:
+           strcpy (buf->machine, "powerpc");
+           break;
+         case PROCESSOR_ARCHITECTURE_SHX:
+           strcpy (buf->machine, "sh");
+           break;
+         case PROCESSOR_ARCHITECTURE_ARM:
+           strcpy (buf->machine, "arm");
+           break;
          default:
            strcpy (buf->machine, "unknown");
            break;