Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / OS_NS_sys_utsname.cpp
blob8d4da8dbddd846810a9e1a9898653961b20b6633
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
16 int
17 ACE_OS::uname (ACE_utsname *name)
19 ACE_OS_TRACE ("ACE_OS::uname");
20 #if !defined (ACE_LACKS_UNAME)
21 return ::uname (name);
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__ */
40 # pragma warning(pop)
41 # endif
43 SYSTEM_INFO sinfo;
44 ::GetSystemInfo(&sinfo);
46 const char* unknown = "???";
48 # if defined (ACE_HAS_WIN32_GETVERSION)
49 if (
50 vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
51 # if defined (VER_PLATFORM_WIN32_CE)
52 || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
53 # endif
56 // Get information from the two structures
57 const char *os = 0;
58 if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
59 os = "Windows NT %d.%d";
60 else
61 os = "Windows CE %d.%d";
62 ACE_OS::snprintf (name->release, maxnamelen,
63 os,
64 (int) vinfo.dwMajorVersion,
65 (int) vinfo.dwMinorVersion);
66 ACE_OS::snprintf (name->version, maxnamelen,
67 "Build %d %s",
68 (int) vinfo.dwBuildNumber,
69 ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
71 // We have to make sure that the size of (processor + subtype)
72 // is not greater than the size of name->machine. So we give
73 // half the space to the processor and half the space to
74 // subtype. The -1 is necessary for because of the space
75 // between processor and subtype in the machine name.
76 int const bufsize = (sizeof (name->machine) / 2) - 1;
77 char processor[bufsize] = "Unknown";
78 char subtype[bufsize] = "Unknown";
80 WORD arch = sinfo.wProcessorArchitecture;
82 switch (arch)
84 case PROCESSOR_ARCHITECTURE_INTEL:
85 ACE_OS::strcpy (processor, "Intel");
86 if (sinfo.wProcessorLevel == 3)
87 ACE_OS::strcpy (subtype, "80386");
88 else if (sinfo.wProcessorLevel == 4)
89 ACE_OS::strcpy (subtype, "80486");
90 else if (sinfo.wProcessorLevel == 5)
91 ACE_OS::strcpy (subtype, "Pentium");
92 else if (sinfo.wProcessorLevel == 6)
93 ACE_OS::strcpy (subtype, "Pentium Pro");
94 else if (sinfo.wProcessorLevel == 7) // I'm guessing here
95 ACE_OS::strcpy (subtype, "Pentium II");
96 else
97 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
98 break;
99 case PROCESSOR_ARCHITECTURE_MIPS:
100 ACE_OS::strcpy (processor, "MIPS");
101 if (sinfo.wProcessorLevel == 3)
102 ACE_OS::strcpy (subtype, "R3000");
103 else if (sinfo.wProcessorLevel == 4)
104 ACE_OS::strcpy (subtype, "R4000");
105 else
106 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
107 break;
108 case PROCESSOR_ARCHITECTURE_ALPHA:
109 ACE_OS::strcpy (processor, "Alpha");
110 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
111 break;
112 case PROCESSOR_ARCHITECTURE_PPC:
113 ACE_OS::strcpy (processor, "PPC");
114 if (sinfo.wProcessorLevel == 1)
115 ACE_OS::strcpy (subtype, "601");
116 else if (sinfo.wProcessorLevel == 3)
117 ACE_OS::strcpy (subtype, "603");
118 else if (sinfo.wProcessorLevel == 4)
119 ACE_OS::strcpy (subtype, "604");
120 else if (sinfo.wProcessorLevel == 6)
121 ACE_OS::strcpy (subtype, "603+");
122 else if (sinfo.wProcessorLevel == 9)
123 ACE_OS::strcpy (subtype, "804+");
124 else if (sinfo.wProcessorLevel == 20)
125 ACE_OS::strcpy (subtype, "620");
126 break;
127 # if defined PROCESSOR_ARCHITECTURE_IA64
128 case PROCESSOR_ARCHITECTURE_IA64:
129 ACE_OS::strcpy (processor, "Itanium");
130 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
131 break;
132 # endif
133 # if defined PROCESSOR_ARCHITECTURE_AMD64
134 case PROCESSOR_ARCHITECTURE_AMD64:
135 ACE_OS::strcpy (processor, "x64");
136 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
137 break;
138 # endif
139 # if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
140 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
141 ACE_OS::strcpy (processor, "WOW64");
142 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
143 break;
144 # endif
145 # if defined PROCESSOR_ARCHITECTURE_ARM
146 case PROCESSOR_ARCHITECTURE_ARM:
147 ACE_OS::strcpy (processor, "ARM");
148 ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
149 break;
150 # endif
151 case PROCESSOR_ARCHITECTURE_UNKNOWN:
152 default:
153 ACE_OS::strcpy (processor, "Unknown");
154 break;
156 ACE_OS::snprintf (name->machine, maxnamelen, "%s %s", processor, subtype);
158 else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
160 if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
162 ACE_OS::strcpy (name->release, "Windows 95");
163 if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
164 ACE_OS::strcat (name->release, " OSR2");
166 else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
168 ACE_OS::strcpy (name->release, "Windows 98");
169 if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
170 ACE_OS::strcat (name->release, " SE");
172 else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
174 ACE_OS::strcpy (name->release, "Windows Me");
176 else
178 ACE_OS::strcpy (name->release, unknown);
181 ACE_OS::snprintf (name->version, maxnamelen, "%d",
182 LOWORD (vinfo.dwBuildNumber));
183 if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
184 ACE_OS::strcpy (name->machine, "Intel 80386");
185 else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
186 ACE_OS::strcpy (name->machine, "Intel 80486");
187 else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
188 ACE_OS::strcpy (name->machine, "Intel Pentium");
189 else
190 ACE_OS::strcpy (name->machine, unknown);
192 else
193 # endif /* !ACE_HAS_WIN32_GETVERSION */
195 // We don't know what this is!
197 ACE_OS::strcpy (name->release, unknown);
198 ACE_OS::strcpy (name->version, unknown);
199 ACE_OS::strcpy (name->machine, unknown);
202 # if defined (ACE_LACKS_HOSTNAME)
203 return 0;
204 # else /* ACE_LACKS_HOSTNAME */
205 return ACE_OS::hostname (name->nodename, maxnamelen);
206 # endif /* ACE_LACKS_HOSTNAME */
208 #elif defined (ACE_VXWORKS) && !defined (__RTP__)
209 size_t const maxnamelen = sizeof name->nodename;
210 ACE_OS::strcpy (name->sysname, "VxWorks");
211 ACE_OS::strcpy (name->release, kernelVersion());
212 ACE_OS::strcpy (name->version, sysBspRev ());
213 ACE_OS::strcpy (name->machine, sysModel ());
215 return ACE_OS::hostname (name->nodename, maxnamelen);
216 #elif defined (INTEGRITY)
217 if(!name) {
218 errno = EFAULT;
219 return -1;
221 strcpy(name->sysname,"INTEGRITY");
222 int status = gethostname(name->nodename,_SYS_NMLN);
223 strcpy(name->release,"4.0");
224 strcpy(name->version,"4.0.9");
225 strcpy(name->machine,"a standard name");
226 return status;
227 #else
228 ACE_UNUSED_ARG (name);
229 ACE_NOTSUP_RETURN (-1);
230 #endif /* ACE_WIN32 */
233 ACE_END_VERSIONED_NAMESPACE_DECL