1 #include "ace/OS_NS_sys_utsname.h"
2 #include "ace/OS_NS_string.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/OS_NS_unistd.h"
5 #include "ace/OS_NS_errno.h"
7 #if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME) && !defined (__RTP__)
8 // for sysBspRev(), sysModel()
9 # include /**/ <sysLib.h>
10 // for kernelVersion()
11 # include /**/ <kernelLib.h>
12 #endif /* ACE_VXWORKS && ACE_LACKS_UNAME */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_OS::uname (ACE_utsname
*name
)
19 ACE_OS_TRACE ("ACE_OS::uname");
20 #if !defined (ACE_LACKS_UNAME)
21 ACE_OSCALL_RETURN (::uname (name
), int, -1);
22 #elif defined (ACE_WIN32)
23 size_t maxnamelen
= sizeof name
->nodename
;
24 ACE_OS::strcpy (name
->sysname
, "Win32");
26 # if defined (ACE_HAS_WIN32_GETVERSION)
27 /* Since MS found it necessary to deprecate these. */
28 # pragma warning(push)
29 # pragma warning(disable:4996)
30 # if defined(__clang__)
31 # pragma clang diagnostic push
32 # pragma clang diagnostic ignored "-Wdeprecated-declarations"
33 # endif /* __clang__ */
34 ACE_TEXT_OSVERSIONINFO vinfo
;
35 vinfo
.dwOSVersionInfoSize
= sizeof(ACE_TEXT_OSVERSIONINFO
);
36 ACE_TEXT_GetVersionEx (&vinfo
);
37 # if defined(__clang__)
38 # pragma clang diagnostic pop
39 # endif /* __clang__ */
44 # if defined (ACE_HAS_PHARLAP)
45 // PharLap doesn't do GetSystemInfo. What's really wanted is the
46 // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
47 // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
48 // that the CPU type values in EK_KERNELINFO have the same values
49 // are the ones defined for SYSTEM_INFO.
50 EK_KERNELINFO ets_kern
;
51 EK_SYSTEMINFO ets_sys
;
52 EtsGetSystemInfo (&ets_kern
, &ets_sys
);
53 sinfo
.wProcessorLevel
= static_cast<WORD
> (ets_kern
.CpuType
);
54 sinfo
.wProcessorArchitecture
= PROCESSOR_ARCHITECTURE_INTEL
;
55 sinfo
.dwProcessorType
= ets_kern
.CpuType
* 100 + 86;
57 ::GetSystemInfo(&sinfo
);
58 # endif /* ACE_HAS_PHARLAP */
60 const char* unknown
= "???";
62 # if defined (ACE_HAS_WIN32_GETVERSION)
64 vinfo
.dwPlatformId
== VER_PLATFORM_WIN32_NT
65 # if defined (VER_PLATFORM_WIN32_CE)
66 || vinfo
.dwPlatformId
== VER_PLATFORM_WIN32_CE
70 // Get information from the two structures
72 if (vinfo
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
73 os
= "Windows NT %d.%d";
75 os
= "Windows CE %d.%d";
76 ACE_OS::snprintf (name
->release
, maxnamelen
,
78 (int) vinfo
.dwMajorVersion
,
79 (int) vinfo
.dwMinorVersion
);
80 ACE_OS::snprintf (name
->version
, maxnamelen
,
82 (int) vinfo
.dwBuildNumber
,
83 ACE_TEXT_ALWAYS_CHAR (vinfo
.szCSDVersion
));
85 // We have to make sure that the size of (processor + subtype)
86 // is not greater than the size of name->machine. So we give
87 // half the space to the processor and half the space to
88 // subtype. The -1 is necessary for because of the space
89 // between processor and subtype in the machine name.
90 int const bufsize
= (sizeof (name
->machine
) / 2) - 1;
91 char processor
[bufsize
] = "Unknown";
92 char subtype
[bufsize
] = "Unknown";
94 WORD arch
= sinfo
.wProcessorArchitecture
;
98 case PROCESSOR_ARCHITECTURE_INTEL
:
99 ACE_OS::strcpy (processor
, "Intel");
100 if (sinfo
.wProcessorLevel
== 3)
101 ACE_OS::strcpy (subtype
, "80386");
102 else if (sinfo
.wProcessorLevel
== 4)
103 ACE_OS::strcpy (subtype
, "80486");
104 else if (sinfo
.wProcessorLevel
== 5)
105 ACE_OS::strcpy (subtype
, "Pentium");
106 else if (sinfo
.wProcessorLevel
== 6)
107 ACE_OS::strcpy (subtype
, "Pentium Pro");
108 else if (sinfo
.wProcessorLevel
== 7) // I'm guessing here
109 ACE_OS::strcpy (subtype
, "Pentium II");
111 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
113 case PROCESSOR_ARCHITECTURE_MIPS
:
114 ACE_OS::strcpy (processor
, "MIPS");
115 if (sinfo
.wProcessorLevel
== 3)
116 ACE_OS::strcpy (subtype
, "R3000");
117 else if (sinfo
.wProcessorLevel
== 4)
118 ACE_OS::strcpy (subtype
, "R4000");
120 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
122 case PROCESSOR_ARCHITECTURE_ALPHA
:
123 ACE_OS::strcpy (processor
, "Alpha");
124 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
126 case PROCESSOR_ARCHITECTURE_PPC
:
127 ACE_OS::strcpy (processor
, "PPC");
128 if (sinfo
.wProcessorLevel
== 1)
129 ACE_OS::strcpy (subtype
, "601");
130 else if (sinfo
.wProcessorLevel
== 3)
131 ACE_OS::strcpy (subtype
, "603");
132 else if (sinfo
.wProcessorLevel
== 4)
133 ACE_OS::strcpy (subtype
, "604");
134 else if (sinfo
.wProcessorLevel
== 6)
135 ACE_OS::strcpy (subtype
, "603+");
136 else if (sinfo
.wProcessorLevel
== 9)
137 ACE_OS::strcpy (subtype
, "804+");
138 else if (sinfo
.wProcessorLevel
== 20)
139 ACE_OS::strcpy (subtype
, "620");
141 # if defined PROCESSOR_ARCHITECTURE_IA64
142 case PROCESSOR_ARCHITECTURE_IA64
:
143 ACE_OS::strcpy (processor
, "Itanium");
144 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
147 # if defined PROCESSOR_ARCHITECTURE_AMD64
148 case PROCESSOR_ARCHITECTURE_AMD64
:
149 ACE_OS::strcpy (processor
, "x64");
150 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
153 # if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
154 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
:
155 ACE_OS::strcpy (processor
, "WOW64");
156 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
159 # if defined PROCESSOR_ARCHITECTURE_ARM
160 case PROCESSOR_ARCHITECTURE_ARM
:
161 ACE_OS::strcpy (processor
, "ARM");
162 ACE_OS::snprintf (subtype
, bufsize
, "%d", sinfo
.wProcessorLevel
);
165 case PROCESSOR_ARCHITECTURE_UNKNOWN
:
167 // @@ We could provide WinCE specific info here. But let's
168 // defer that to some later point.
169 ACE_OS::strcpy (processor
, "Unknown");
172 ACE_OS::snprintf (name
->machine
, maxnamelen
, "%s %s", processor
, subtype
);
174 else if (vinfo
.dwPlatformId
== VER_PLATFORM_WIN32_WINDOWS
)
176 if (vinfo
.dwMajorVersion
== 4 && vinfo
.dwMinorVersion
== 0)
178 ACE_OS::strcpy (name
->release
, "Windows 95");
179 if (vinfo
.szCSDVersion
[1] == ACE_TEXT('C'))
180 ACE_OS::strcat (name
->release
, " OSR2");
182 else if (vinfo
.dwMajorVersion
== 4 && vinfo
.dwMinorVersion
== 10)
184 ACE_OS::strcpy (name
->release
, "Windows 98");
185 if (vinfo
.szCSDVersion
[1] == ACE_TEXT('A'))
186 ACE_OS::strcat (name
->release
, " SE");
188 else if (vinfo
.dwMajorVersion
== 4 && vinfo
.dwMinorVersion
== 90)
190 ACE_OS::strcpy (name
->release
, "Windows Me");
194 ACE_OS::strcpy (name
->release
, unknown
);
197 ACE_OS::snprintf (name
->version
, maxnamelen
, "%d",
198 LOWORD (vinfo
.dwBuildNumber
));
199 if (sinfo
.dwProcessorType
== PROCESSOR_INTEL_386
)
200 ACE_OS::strcpy (name
->machine
, "Intel 80386");
201 else if (sinfo
.dwProcessorType
== PROCESSOR_INTEL_486
)
202 ACE_OS::strcpy (name
->machine
, "Intel 80486");
203 else if (sinfo
.dwProcessorType
== PROCESSOR_INTEL_PENTIUM
)
204 ACE_OS::strcpy (name
->machine
, "Intel Pentium");
206 ACE_OS::strcpy (name
->machine
, unknown
);
209 # endif /* !ACE_HAS_WIN32_GETVERSION */
211 // We don't know what this is!
213 ACE_OS::strcpy (name
->release
, unknown
);
214 ACE_OS::strcpy (name
->version
, unknown
);
215 ACE_OS::strcpy (name
->machine
, unknown
);
218 # if defined (ACE_LACKS_HOSTNAME)
220 # else /* ACE_LACKS_HOSTNAME */
221 return ACE_OS::hostname (name
->nodename
, maxnamelen
);
222 # endif /* ACE_LACKS_HOSTNAME */
224 #elif defined (ACE_VXWORKS) && !defined (__RTP__)
225 size_t const maxnamelen
= sizeof name
->nodename
;
226 ACE_OS::strcpy (name
->sysname
, "VxWorks");
227 ACE_OS::strcpy (name
->release
, kernelVersion());
228 ACE_OS::strcpy (name
->version
, sysBspRev ());
229 ACE_OS::strcpy (name
->machine
, sysModel ());
231 return ACE_OS::hostname (name
->nodename
, maxnamelen
);
232 #elif defined (INTEGRITY)
237 strcpy(name
->sysname
,"INTEGRITY");
238 int status
= gethostname(name
->nodename
,_SYS_NMLN
);
239 strcpy(name
->release
,"4.0");
240 strcpy(name
->version
,"4.0.9");
241 strcpy(name
->machine
,"a standard name");
244 ACE_UNUSED_ARG (name
);
245 ACE_NOTSUP_RETURN (-1);
246 #endif /* ACE_WIN32 */
249 ACE_END_VERSIONED_NAMESPACE_DECL