3 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007 Red Hat, Inc.
5 Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com
6 Rewritten by Geoffrey Noer of Cygnus Solutions, noer@cygnus.com
8 This file is part of Cygwin.
10 This software is a copyrighted work licensed under the terms of the
11 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 #include <sys/utsname.h>
16 #include "cygwin_version.h"
19 /* uname: POSIX 4.4.1.1 */
21 uname (struct utsname *name)
26 if (efault.faulted (EFAULT))
29 char *snp = strstr (cygwin_version.dll_build_date, "SNP");
31 memset (name, 0, sizeof (*name));
32 __small_sprintf (name->sysname, "CYGWIN_%s", wincap.osname ());
35 /* Recognition of the real 64 bit CPU inside of a WOW64 system, irritates
36 build systems which think the native system is a 64 bit system. Since
37 we're actually running in a 32 bit environment, it looks more correct
38 just to use the CPU info given by WOW64. */
39 if (wincap.is_wow64 ())
40 GetNativeSystemInfo (&sysinfo);
43 /* But it seems ok to add a hint to the sysname, that we're running under
44 WOW64. This might give an early clue if somebody encounters problems. */
45 if (wincap.is_wow64 ())
46 strncat (name->sysname, "-WOW64",
47 sizeof name->sysname - strlen (name->sysname) - 1);
49 GetSystemInfo (&sysinfo);
52 cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1);
54 /* Cygwin dll release */
55 __small_sprintf (name->release, "%d.%d.%d%s(%d.%d/%d/%d)",
56 cygwin_version.dll_major / 1000,
57 cygwin_version.dll_major % 1000,
58 cygwin_version.dll_minor,
60 cygwin_version.api_major,
61 cygwin_version.api_minor,
62 cygwin_version.shared_data,
63 cygwin_version.mount_registry);
65 /* Cygwin "version" aka build date */
66 strcpy (name->version, cygwin_version.dll_build_date);
68 name->version[snp - cygwin_version.dll_build_date] = '\0';
71 switch (sysinfo.wProcessorArchitecture)
73 case PROCESSOR_ARCHITECTURE_INTEL:
75 if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
77 else if (sysinfo.wProcessorLevel > 9) /* P4 */
80 ptype = sysinfo.wProcessorLevel;
81 __small_sprintf (name->machine, "i%d86", ptype);
83 case PROCESSOR_ARCHITECTURE_IA64:
84 strcpy (name->machine, "ia64");
86 case PROCESSOR_ARCHITECTURE_AMD64:
87 strcpy (name->machine, "x86_64");
89 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
90 strcpy (name->machine, "ia32-win64");
92 case PROCESSOR_ARCHITECTURE_ALPHA:
93 strcpy (name->machine, "alpha");
95 case PROCESSOR_ARCHITECTURE_MIPS:
96 strcpy (name->machine, "mips");
99 strcpy (name->machine, "unknown");