@@ -23,15 +23,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
23
23
See comments in porting.h
24
24
*/
25
25
26
- #if defined(linux)
27
- #include < unistd.h>
28
- #elif defined(__APPLE__)
29
- #include < unistd.h>
26
+ #if defined(__APPLE__)
30
27
#include < mach-o/dyld.h>
28
+ #include " CoreFoundation/CoreFoundation.h"
31
29
#elif defined(__FreeBSD__)
32
- #include < unistd.h>
33
30
#include < sys/types.h>
34
31
#include < sys/sysctl.h>
32
+ #elif defined(_WIN32)
33
+ #include < algorithm>
34
+ #endif
35
+ #if !defined(_WIN32)
36
+ #include < unistd.h>
37
+ #include < sys/utsname.h>
35
38
#endif
36
39
37
40
#include " porting.h"
@@ -42,10 +45,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
42
45
#include " util/string.h"
43
46
#include < list>
44
47
45
- #ifdef __APPLE__
46
- #include " CoreFoundation/CoreFoundation.h"
47
- #endif
48
-
49
48
namespace porting
50
49
{
51
50
@@ -284,6 +283,42 @@ bool detectMSVCBuildDir(char *c_path)
284
283
return (removeStringEnd (path, ends) != " " );
285
284
}
286
285
286
+ std::string get_sysinfo ()
287
+ {
288
+ #ifdef _WIN32
289
+ OSVERSIONINFO osvi;
290
+ std::ostringstream oss;
291
+ std::string tmp;
292
+ ZeroMemory (&osvi, sizeof (OSVERSIONINFO));
293
+ osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
294
+ GetVersionEx (&osvi);
295
+ tmp = osvi.szCSDVersion ;
296
+ std::replace (tmp.begin (), tmp.end (), ' ' , ' _' );
297
+
298
+ oss << " Windows/" << osvi.dwMajorVersion << " ."
299
+ << osvi.dwMinorVersion ;
300
+ if (osvi.szCSDVersion [0 ])
301
+ oss << " -" << tmp;
302
+ oss << " " ;
303
+ #ifdef _WIN64
304
+ oss << " x86_64" ;
305
+ #else
306
+ BOOL is64 = FALSE ;
307
+ if (IsWow64Process (GetCurrentProcess (), &is64) && is64)
308
+ oss << " x86_64" ; // 32-bit app on 64-bit OS
309
+ else
310
+ oss << " x86" ;
311
+ #endif
312
+
313
+ return oss.str ();
314
+ #else
315
+ struct utsname osinfo;
316
+ uname (&osinfo);
317
+ return std::string (osinfo.sysname ) + " /"
318
+ + osinfo.release + " " + osinfo.machine ;
319
+ #endif
320
+ }
321
+
287
322
void initializePaths ()
288
323
{
289
324
#if RUN_IN_PLACE
0 commit comments