diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-06-21 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:59:19 +0500 |
| commit | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch) | |
| tree | fe5e17420300b715021a76328444088d32047963 /CPP/Windows/SystemInfo.cpp | |
| parent | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff) | |
| download | 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.gz 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.tar.bz2 7zip-5b39dc76f1bc82f941d5c800ab9f34407a06b53a.zip | |
23.0123.01
Diffstat (limited to 'CPP/Windows/SystemInfo.cpp')
| -rw-r--r-- | CPP/Windows/SystemInfo.cpp | 291 |
1 files changed, 198 insertions, 93 deletions
diff --git a/CPP/Windows/SystemInfo.cpp b/CPP/Windows/SystemInfo.cpp index d882a8e..6bafc80 100644 --- a/CPP/Windows/SystemInfo.cpp +++ b/CPP/Windows/SystemInfo.cpp | |||
| @@ -102,38 +102,44 @@ static void PrintHex(AString &s, UInt64 v) | |||
| 102 | 102 | ||
| 103 | #ifdef MY_CPU_X86_OR_AMD64 | 103 | #ifdef MY_CPU_X86_OR_AMD64 |
| 104 | 104 | ||
| 105 | Z7_NO_INLINE | ||
| 105 | static void PrintCpuChars(AString &s, UInt32 v) | 106 | static void PrintCpuChars(AString &s, UInt32 v) |
| 106 | { | 107 | { |
| 107 | for (int j = 0; j < 4; j++) | 108 | for (unsigned j = 0; j < 4; j++) |
| 108 | { | 109 | { |
| 109 | Byte b = (Byte)(v & 0xFF); | 110 | Byte b = (Byte)(v & 0xFF); |
| 110 | v >>= 8; | 111 | v >>= 8; |
| 111 | if (b == 0) | 112 | if (b == 0) |
| 112 | break; | 113 | break; |
| 113 | s += (char)b; | 114 | if (b >= 0x20 && b <= 0x7f) |
| 115 | s += (char)b; | ||
| 116 | else | ||
| 117 | { | ||
| 118 | s += '['; | ||
| 119 | char temp[16]; | ||
| 120 | ConvertUInt32ToHex(b, temp); | ||
| 121 | s += temp; | ||
| 122 | s += ']'; | ||
| 123 | } | ||
| 114 | } | 124 | } |
| 115 | } | 125 | } |
| 116 | 126 | ||
| 117 | 127 | ||
| 118 | static void x86cpuid_to_String(const Cx86cpuid &c, AString &s, AString &ver) | 128 | static void x86cpuid_to_String(AString &s) |
| 119 | { | 129 | { |
| 120 | s.Empty(); | 130 | s.Empty(); |
| 121 | 131 | ||
| 122 | UInt32 maxFunc2 = 0; | 132 | UInt32 a[4]; |
| 123 | UInt32 t[3]; | 133 | // cpuid was called already. So we don't check for cpuid availability here |
| 134 | z7_x86_cpuid(a, 0x80000000); | ||
| 124 | 135 | ||
| 125 | MyCPUID(0x80000000, &maxFunc2, &t[0], &t[1], &t[2]); | 136 | if (a[0] >= 0x80000004) // if (maxFunc2 >= hi+4) the full name is available |
| 126 | |||
| 127 | bool fullNameIsAvail = (maxFunc2 >= 0x80000004); | ||
| 128 | |||
| 129 | if (fullNameIsAvail) | ||
| 130 | { | 137 | { |
| 131 | for (unsigned i = 0; i < 3; i++) | 138 | for (unsigned i = 0; i < 3; i++) |
| 132 | { | 139 | { |
| 133 | UInt32 d[4] = { 0 }; | 140 | z7_x86_cpuid(a, 0x80000002 + i); |
| 134 | MyCPUID(0x80000002 + i, &d[0], &d[1], &d[2], &d[3]); | ||
| 135 | for (unsigned j = 0; j < 4; j++) | 141 | for (unsigned j = 0; j < 4; j++) |
| 136 | PrintCpuChars(s, d[j]); | 142 | PrintCpuChars(s, a[j]); |
| 137 | } | 143 | } |
| 138 | } | 144 | } |
| 139 | 145 | ||
| @@ -141,16 +147,14 @@ static void x86cpuid_to_String(const Cx86cpuid &c, AString &s, AString &ver) | |||
| 141 | 147 | ||
| 142 | if (s.IsEmpty()) | 148 | if (s.IsEmpty()) |
| 143 | { | 149 | { |
| 144 | for (int i = 0; i < 3; i++) | 150 | z7_x86_cpuid(a, 0); |
| 145 | PrintCpuChars(s, c.vendor[i]); | 151 | for (unsigned i = 1; i < 4; i++) |
| 152 | { | ||
| 153 | const unsigned j = (i ^ (i >> 1)); | ||
| 154 | PrintCpuChars(s, a[j]); | ||
| 155 | } | ||
| 146 | s.Trim(); | 156 | s.Trim(); |
| 147 | } | 157 | } |
| 148 | |||
| 149 | { | ||
| 150 | char temp[32]; | ||
| 151 | ConvertUInt32ToHex(c.ver, temp); | ||
| 152 | ver += temp; | ||
| 153 | } | ||
| 154 | } | 158 | } |
| 155 | 159 | ||
| 156 | /* | 160 | /* |
| @@ -184,7 +188,7 @@ static void x86cpuid_all_to_String(AString &s) | |||
| 184 | { | 188 | { |
| 185 | char temp[32]; | 189 | char temp[32]; |
| 186 | ConvertUInt32ToHex8Digits(d[i], temp); | 190 | ConvertUInt32ToHex8Digits(d[i], temp); |
| 187 | s += " "; | 191 | s.Add_Space(); |
| 188 | s += temp; | 192 | s += temp; |
| 189 | } | 193 | } |
| 190 | } | 194 | } |
| @@ -215,12 +219,12 @@ static const char * const k_PROCESSOR_ARCHITECTURE[] = | |||
| 215 | , "ARM32_ON_WIN64" | 219 | , "ARM32_ON_WIN64" |
| 216 | }; | 220 | }; |
| 217 | 221 | ||
| 218 | #define MY__PROCESSOR_ARCHITECTURE_INTEL 0 | 222 | #define Z7_WIN_PROCESSOR_ARCHITECTURE_INTEL 0 |
| 219 | #define MY__PROCESSOR_ARCHITECTURE_AMD64 9 | 223 | #define Z7_WIN_PROCESSOR_ARCHITECTURE_AMD64 9 |
| 220 | 224 | ||
| 221 | 225 | ||
| 222 | #define MY__PROCESSOR_INTEL_PENTIUM 586 | 226 | #define Z7_WIN_PROCESSOR_INTEL_PENTIUM 586 |
| 223 | #define MY__PROCESSOR_AMD_X8664 8664 | 227 | #define Z7_WIN_PROCESSOR_AMD_X8664 8664 |
| 224 | 228 | ||
| 225 | /* | 229 | /* |
| 226 | static const CUInt32PCharPair k_PROCESSOR[] = | 230 | static const CUInt32PCharPair k_PROCESSOR[] = |
| @@ -303,19 +307,20 @@ static const char * const k_PF[] = | |||
| 303 | #endif | 307 | #endif |
| 304 | 308 | ||
| 305 | 309 | ||
| 306 | #ifdef _WIN32 | 310 | static void PrintPage(AString &s, UInt64 v) |
| 307 | |||
| 308 | static void PrintPage(AString &s, UInt32 v) | ||
| 309 | { | 311 | { |
| 310 | if ((v & 0x3FF) == 0) | 312 | const char *t = "B"; |
| 313 | if ((v & 0x3ff) == 0) | ||
| 311 | { | 314 | { |
| 312 | s.Add_UInt32(v >> 10); | 315 | v >>= 10; |
| 313 | s += "K"; | 316 | t = "KB"; |
| 314 | } | 317 | } |
| 315 | else | 318 | s.Add_UInt64(v); |
| 316 | s.Add_UInt32(v >> 10); | 319 | s += t; |
| 317 | } | 320 | } |
| 318 | 321 | ||
| 322 | #ifdef _WIN32 | ||
| 323 | |||
| 319 | static AString TypeToString2(const char * const table[], unsigned num, UInt32 value) | 324 | static AString TypeToString2(const char * const table[], unsigned num, UInt32 value) |
| 320 | { | 325 | { |
| 321 | char sz[16]; | 326 | char sz[16]; |
| @@ -330,7 +335,7 @@ static AString TypeToString2(const char * const table[], unsigned num, UInt32 va | |||
| 330 | return (AString)p; | 335 | return (AString)p; |
| 331 | } | 336 | } |
| 332 | 337 | ||
| 333 | // #if defined(_7ZIP_LARGE_PAGES) || defined(_WIN32) | 338 | // #if defined(Z7_LARGE_PAGES) || defined(_WIN32) |
| 334 | // #ifdef _WIN32 | 339 | // #ifdef _WIN32 |
| 335 | void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v) | 340 | void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v) |
| 336 | { | 341 | { |
| @@ -342,32 +347,32 @@ void PrintSize_KMGT_Or_Hex(AString &s, UInt64 v) | |||
| 342 | }}}} | 347 | }}}} |
| 343 | else | 348 | else |
| 344 | { | 349 | { |
| 350 | // s += "0x"; | ||
| 345 | PrintHex(s, v); | 351 | PrintHex(s, v); |
| 346 | return; | 352 | return; |
| 347 | } | 353 | } |
| 348 | char temp[32]; | 354 | s.Add_UInt64(v); |
| 349 | ConvertUInt64ToString(v, temp); | ||
| 350 | s += temp; | ||
| 351 | if (c) | 355 | if (c) |
| 352 | s += c; | 356 | s += c; |
| 357 | s += 'B'; | ||
| 353 | } | 358 | } |
| 354 | // #endif | 359 | // #endif |
| 355 | // #endif | 360 | // #endif |
| 356 | 361 | ||
| 357 | static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si) | 362 | static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si) |
| 358 | { | 363 | { |
| 359 | s += TypeToString2(k_PROCESSOR_ARCHITECTURE, ARRAY_SIZE(k_PROCESSOR_ARCHITECTURE), si.wProcessorArchitecture); | 364 | s += TypeToString2(k_PROCESSOR_ARCHITECTURE, Z7_ARRAY_SIZE(k_PROCESSOR_ARCHITECTURE), si.wProcessorArchitecture); |
| 360 | 365 | ||
| 361 | if (!( (si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_INTEL && si.dwProcessorType == MY__PROCESSOR_INTEL_PENTIUM) | 366 | if (!( (si.wProcessorArchitecture == Z7_WIN_PROCESSOR_ARCHITECTURE_INTEL && si.dwProcessorType == Z7_WIN_PROCESSOR_INTEL_PENTIUM) |
| 362 | || (si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_AMD64 && si.dwProcessorType == MY__PROCESSOR_AMD_X8664))) | 367 | || (si.wProcessorArchitecture == Z7_WIN_PROCESSOR_ARCHITECTURE_AMD64 && si.dwProcessorType == Z7_WIN_PROCESSOR_AMD_X8664))) |
| 363 | { | 368 | { |
| 364 | s += " "; | 369 | s.Add_Space(); |
| 365 | // s += TypePairToString(k_PROCESSOR, ARRAY_SIZE(k_PROCESSOR), si.dwProcessorType); | 370 | // s += TypePairToString(k_PROCESSOR, Z7_ARRAY_SIZE(k_PROCESSOR), si.dwProcessorType); |
| 366 | s.Add_UInt32(si.dwProcessorType); | 371 | s.Add_UInt32(si.dwProcessorType); |
| 367 | } | 372 | } |
| 368 | s += " "; | 373 | s.Add_Space(); |
| 369 | PrintHex(s, si.wProcessorLevel); | 374 | PrintHex(s, si.wProcessorLevel); |
| 370 | s += "."; | 375 | s.Add_Dot(); |
| 371 | PrintHex(s, si.wProcessorRevision); | 376 | PrintHex(s, si.wProcessorRevision); |
| 372 | if ((UInt64)si.dwActiveProcessorMask + 1 != ((UInt64)1 << si.dwNumberOfProcessors)) | 377 | if ((UInt64)si.dwActiveProcessorMask + 1 != ((UInt64)1 << si.dwNumberOfProcessors)) |
| 373 | if ((UInt64)si.dwActiveProcessorMask + 1 != 0 || si.dwNumberOfProcessors != sizeof(UInt64) * 8) | 378 | if ((UInt64)si.dwActiveProcessorMask + 1 != 0 || si.dwNumberOfProcessors != sizeof(UInt64) * 8) |
| @@ -387,9 +392,9 @@ static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si) | |||
| 387 | s += " gran:"; | 392 | s += " gran:"; |
| 388 | PrintPage(s, si.dwAllocationGranularity); | 393 | PrintPage(s, si.dwAllocationGranularity); |
| 389 | } | 394 | } |
| 390 | s += " "; | 395 | s.Add_Space(); |
| 391 | 396 | ||
| 392 | DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress; | 397 | const DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress; |
| 393 | UInt64 maxSize = (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1; | 398 | UInt64 maxSize = (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1; |
| 394 | const UInt32 kReserveSize = ((UInt32)1 << 16); | 399 | const UInt32 kReserveSize = ((UInt32)1 << 16); |
| 395 | if (minAdd != kReserveSize) | 400 | if (minAdd != kReserveSize) |
| @@ -419,7 +424,7 @@ static void Add_sysctlbyname_to_String(const char *name, AString &s) | |||
| 419 | { | 424 | { |
| 420 | size_t bufSize = 256; | 425 | size_t bufSize = 256; |
| 421 | char buf[256]; | 426 | char buf[256]; |
| 422 | if (My_sysctlbyname_Get(name, &buf, &bufSize) == 0) | 427 | if (z7_sysctlbyname_Get(name, &buf, &bufSize) == 0) |
| 423 | s += buf; | 428 | s += buf; |
| 424 | } | 429 | } |
| 425 | #endif | 430 | #endif |
| @@ -440,12 +445,14 @@ void GetSysInfo(AString &s1, AString &s2) | |||
| 440 | } | 445 | } |
| 441 | 446 | ||
| 442 | #if !defined(_WIN64) && !defined(UNDER_CE) | 447 | #if !defined(_WIN64) && !defined(UNDER_CE) |
| 443 | Func_GetNativeSystemInfo fn_GetNativeSystemInfo = (Func_GetNativeSystemInfo)(void *)GetProcAddress( | 448 | const |
| 444 | GetModuleHandleA("kernel32.dll"), "GetNativeSystemInfo"); | 449 | Func_GetNativeSystemInfo fn = Z7_GET_PROC_ADDRESS( |
| 445 | if (fn_GetNativeSystemInfo) | 450 | Func_GetNativeSystemInfo, GetModuleHandleA("kernel32.dll"), |
| 451 | "GetNativeSystemInfo"); | ||
| 452 | if (fn) | ||
| 446 | { | 453 | { |
| 447 | SYSTEM_INFO si2; | 454 | SYSTEM_INFO si2; |
| 448 | fn_GetNativeSystemInfo(&si2); | 455 | fn(&si2); |
| 449 | // if (memcmp(&si, &si2, sizeof(si)) != 0) | 456 | // if (memcmp(&si, &si2, sizeof(si)) != 0) |
| 450 | { | 457 | { |
| 451 | // s += " - "; | 458 | // s += " - "; |
| @@ -500,18 +507,20 @@ void CCpuName::Fill() | |||
| 500 | 507 | ||
| 501 | #ifdef MY_CPU_X86_OR_AMD64 | 508 | #ifdef MY_CPU_X86_OR_AMD64 |
| 502 | { | 509 | { |
| 503 | Cx86cpuid cpuid; | 510 | #if !defined(MY_CPU_AMD64) |
| 504 | if (x86cpuid_CheckAndRead(&cpuid)) | 511 | if (!z7_x86_cpuid_GetMaxFunc()) |
| 505 | { | 512 | s += "x86"; |
| 506 | x86cpuid_to_String(cpuid, s, Revision); | ||
| 507 | } | ||
| 508 | else | 513 | else |
| 509 | { | ||
| 510 | #ifdef MY_CPU_AMD64 | ||
| 511 | s += "x64"; | ||
| 512 | #else | ||
| 513 | s += "x86"; | ||
| 514 | #endif | 514 | #endif |
| 515 | { | ||
| 516 | x86cpuid_to_String(s); | ||
| 517 | { | ||
| 518 | UInt32 a[4]; | ||
| 519 | z7_x86_cpuid(a, 1); | ||
| 520 | char temp[16]; | ||
| 521 | ConvertUInt32ToHex(a[0], temp); | ||
| 522 | Revision += temp; | ||
| 523 | } | ||
| 515 | } | 524 | } |
| 516 | } | 525 | } |
| 517 | #elif defined(__APPLE__) | 526 | #elif defined(__APPLE__) |
| @@ -534,12 +543,12 @@ void CCpuName::Fill() | |||
| 534 | { | 543 | { |
| 535 | AString s2; | 544 | AString s2; |
| 536 | UInt32 v = 0; | 545 | UInt32 v = 0; |
| 537 | if (My_sysctlbyname_Get_UInt32("machdep.cpu.core_count", &v) == 0) | 546 | if (z7_sysctlbyname_Get_UInt32("machdep.cpu.core_count", &v) == 0) |
| 538 | { | 547 | { |
| 539 | s2.Add_UInt32(v); | 548 | s2.Add_UInt32(v); |
| 540 | s2 += 'C'; | 549 | s2 += 'C'; |
| 541 | } | 550 | } |
| 542 | if (My_sysctlbyname_Get_UInt32("machdep.cpu.thread_count", &v) == 0) | 551 | if (z7_sysctlbyname_Get_UInt32("machdep.cpu.thread_count", &v) == 0) |
| 543 | { | 552 | { |
| 544 | s2.Add_UInt32(v); | 553 | s2.Add_UInt32(v); |
| 545 | s2 += 'T'; | 554 | s2 += 'T'; |
| @@ -561,7 +570,7 @@ void CCpuName::Fill() | |||
| 561 | LONG res[2]; | 570 | LONG res[2]; |
| 562 | CByteBuffer bufs[2]; | 571 | CByteBuffer bufs[2]; |
| 563 | { | 572 | { |
| 564 | for (int i = 0; i < 2; i++) | 573 | for (unsigned i = 0; i < 2; i++) |
| 565 | { | 574 | { |
| 566 | UInt32 size = 0; | 575 | UInt32 size = 0; |
| 567 | res[i] = key.QueryValue(i == 0 ? | 576 | res[i] = key.QueryValue(i == 0 ? |
| @@ -574,7 +583,7 @@ void CCpuName::Fill() | |||
| 574 | } | 583 | } |
| 575 | if (res[0] == ERROR_SUCCESS || res[1] == ERROR_SUCCESS) | 584 | if (res[0] == ERROR_SUCCESS || res[1] == ERROR_SUCCESS) |
| 576 | { | 585 | { |
| 577 | for (int i = 0; i < 2; i++) | 586 | for (unsigned i = 0; i < 2; i++) |
| 578 | { | 587 | { |
| 579 | if (i == 1) | 588 | if (i == 1) |
| 580 | Microcode += "->"; | 589 | Microcode += "->"; |
| @@ -598,7 +607,7 @@ void CCpuName::Fill() | |||
| 598 | #endif | 607 | #endif |
| 599 | 608 | ||
| 600 | 609 | ||
| 601 | #ifdef _7ZIP_LARGE_PAGES | 610 | #ifdef Z7_LARGE_PAGES |
| 602 | Add_LargePages_String(LargePages); | 611 | Add_LargePages_String(LargePages); |
| 603 | #endif | 612 | #endif |
| 604 | } | 613 | } |
| @@ -608,7 +617,7 @@ void AddCpuFeatures(AString &s) | |||
| 608 | { | 617 | { |
| 609 | #ifdef _WIN32 | 618 | #ifdef _WIN32 |
| 610 | // const unsigned kNumFeatures_Extra = 32; // we check also for unknown features | 619 | // const unsigned kNumFeatures_Extra = 32; // we check also for unknown features |
| 611 | // const unsigned kNumFeatures = ARRAY_SIZE(k_PF) + kNumFeatures_Extra; | 620 | // const unsigned kNumFeatures = Z7_ARRAY_SIZE(k_PF) + kNumFeatures_Extra; |
| 612 | const unsigned kNumFeatures = 64; | 621 | const unsigned kNumFeatures = 64; |
| 613 | UInt64 flags = 0; | 622 | UInt64 flags = 0; |
| 614 | for (unsigned i = 0; i < kNumFeatures; i++) | 623 | for (unsigned i = 0; i < kNumFeatures; i++) |
| @@ -617,7 +626,7 @@ void AddCpuFeatures(AString &s) | |||
| 617 | { | 626 | { |
| 618 | flags += (UInt64)1 << i; | 627 | flags += (UInt64)1 << i; |
| 619 | // s.Add_Space_if_NotEmpty(); | 628 | // s.Add_Space_if_NotEmpty(); |
| 620 | // s += TypeToString2(k_PF, ARRAY_SIZE(k_PF), i); | 629 | // s += TypeToString2(k_PF, Z7_ARRAY_SIZE(k_PF), i); |
| 621 | } | 630 | } |
| 622 | } | 631 | } |
| 623 | s.Add_OptSpaced("f:"); | 632 | s.Add_OptSpaced("f:"); |
| @@ -626,11 +635,10 @@ void AddCpuFeatures(AString &s) | |||
| 626 | #elif defined(__APPLE__) | 635 | #elif defined(__APPLE__) |
| 627 | { | 636 | { |
| 628 | UInt32 v = 0; | 637 | UInt32 v = 0; |
| 629 | if (My_sysctlbyname_Get_UInt32("hw.pagesize", &v) == 0) | 638 | if (z7_sysctlbyname_Get_UInt32("hw.pagesize", &v) == 0) |
| 630 | { | 639 | { |
| 631 | s += "PageSize:"; | 640 | s.Add_OptSpaced("PageSize:"); |
| 632 | s.Add_UInt32(v >> 10); | 641 | PrintPage(s, v); |
| 633 | s += "KB"; | ||
| 634 | } | 642 | } |
| 635 | } | 643 | } |
| 636 | 644 | ||
| @@ -639,10 +647,8 @@ void AddCpuFeatures(AString &s) | |||
| 639 | const long v = sysconf(_SC_PAGESIZE); | 647 | const long v = sysconf(_SC_PAGESIZE); |
| 640 | if (v != -1) | 648 | if (v != -1) |
| 641 | { | 649 | { |
| 642 | s.Add_Space_if_NotEmpty(); | 650 | s.Add_OptSpaced("PageSize:"); |
| 643 | s += "PageSize:"; | 651 | PrintPage(s, (unsigned long)v); |
| 644 | s.Add_UInt32((UInt32)(v >> 10)); | ||
| 645 | s += "KB"; | ||
| 646 | } | 652 | } |
| 647 | 653 | ||
| 648 | #if !defined(_AIX) | 654 | #if !defined(_AIX) |
| @@ -659,11 +665,11 @@ void AddCpuFeatures(AString &s) | |||
| 659 | const int pos = s2.Find('['); | 665 | const int pos = s2.Find('['); |
| 660 | if (pos >= 0) | 666 | if (pos >= 0) |
| 661 | { | 667 | { |
| 662 | const int pos2 = s2.Find(']', pos + 1); | 668 | const int pos2 = s2.Find(']', (unsigned)pos + 1); |
| 663 | if (pos2 >= 0) | 669 | if (pos2 >= 0) |
| 664 | { | 670 | { |
| 665 | s2.DeleteFrom(pos2); | 671 | s2.DeleteFrom((unsigned)pos2); |
| 666 | s2.DeleteFrontal(pos + 1); | 672 | s2.DeleteFrontal((unsigned)pos + 1); |
| 667 | } | 673 | } |
| 668 | } | 674 | } |
| 669 | s += s2; | 675 | s += s2; |
| @@ -722,10 +728,13 @@ EXTERN_C_END | |||
| 722 | 728 | ||
| 723 | static BOOL My_RtlGetVersion(OSVERSIONINFOEXW *vi) | 729 | static BOOL My_RtlGetVersion(OSVERSIONINFOEXW *vi) |
| 724 | { | 730 | { |
| 725 | HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); | 731 | const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll"); |
| 726 | if (!ntdll) | 732 | if (!ntdll) |
| 727 | return FALSE; | 733 | return FALSE; |
| 728 | Func_RtlGetVersion func = (Func_RtlGetVersion)(void *)GetProcAddress(ntdll, "RtlGetVersion"); | 734 | const |
| 735 | Func_RtlGetVersion func = Z7_GET_PROC_ADDRESS( | ||
| 736 | Func_RtlGetVersion, ntdll, | ||
| 737 | "RtlGetVersion"); | ||
| 729 | if (!func) | 738 | if (!func) |
| 730 | return FALSE; | 739 | return FALSE; |
| 731 | func(vi); | 740 | func(vi); |
| @@ -752,18 +761,18 @@ void GetOsInfoText(AString &sRes) | |||
| 752 | s += "Windows"; | 761 | s += "Windows"; |
| 753 | if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT) | 762 | if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT) |
| 754 | s.Add_UInt32(vi.dwPlatformId); | 763 | s.Add_UInt32(vi.dwPlatformId); |
| 755 | s += " "; s.Add_UInt32(vi.dwMajorVersion); | 764 | s.Add_Space(); s.Add_UInt32(vi.dwMajorVersion); |
| 756 | s += "."; s.Add_UInt32(vi.dwMinorVersion); | 765 | s.Add_Dot(); s.Add_UInt32(vi.dwMinorVersion); |
| 757 | s += " "; s.Add_UInt32(vi.dwBuildNumber); | 766 | s.Add_Space(); s.Add_UInt32(vi.dwBuildNumber); |
| 758 | 767 | ||
| 759 | if (vi.wServicePackMajor != 0 || vi.wServicePackMinor != 0) | 768 | if (vi.wServicePackMajor != 0 || vi.wServicePackMinor != 0) |
| 760 | { | 769 | { |
| 761 | s += " SP:"; s.Add_UInt32(vi.wServicePackMajor); | 770 | s += " SP:"; s.Add_UInt32(vi.wServicePackMajor); |
| 762 | s += "."; s.Add_UInt32(vi.wServicePackMinor); | 771 | s.Add_Dot(); s.Add_UInt32(vi.wServicePackMinor); |
| 763 | } | 772 | } |
| 764 | // s += " Suite:"; PrintHex(s, vi.wSuiteMask); | 773 | // s += " Suite:"; PrintHex(s, vi.wSuiteMask); |
| 765 | // s += " Type:"; s.Add_UInt32(vi.wProductType); | 774 | // s += " Type:"; s.Add_UInt32(vi.wProductType); |
| 766 | // s += " "; s += GetOemString(vi.szCSDVersion); | 775 | // s.Add_Space(); s += GetOemString(vi.szCSDVersion); |
| 767 | } | 776 | } |
| 768 | /* | 777 | /* |
| 769 | { | 778 | { |
| @@ -793,6 +802,17 @@ void GetOsInfoText(AString &sRes) | |||
| 793 | #endif // _WIN32 | 802 | #endif // _WIN32 |
| 794 | 803 | ||
| 795 | sRes += s; | 804 | sRes += s; |
| 805 | #ifdef MY_CPU_X86_OR_AMD64 | ||
| 806 | { | ||
| 807 | AString s2; | ||
| 808 | GetVirtCpuid(s2); | ||
| 809 | if (!s2.IsEmpty()) | ||
| 810 | { | ||
| 811 | sRes += " : "; | ||
| 812 | sRes += s2; | ||
| 813 | } | ||
| 814 | } | ||
| 815 | #endif | ||
| 796 | } | 816 | } |
| 797 | 817 | ||
| 798 | 818 | ||
| @@ -875,6 +895,61 @@ void GetCpuName_MultiLine(AString &s) | |||
| 875 | } | 895 | } |
| 876 | } | 896 | } |
| 877 | 897 | ||
| 898 | |||
| 899 | #ifdef MY_CPU_X86_OR_AMD64 | ||
| 900 | |||
| 901 | void GetVirtCpuid(AString &s) | ||
| 902 | { | ||
| 903 | const UInt32 kHv = 0x40000000; | ||
| 904 | |||
| 905 | Z7_IF_X86_CPUID_SUPPORTED | ||
| 906 | { | ||
| 907 | UInt32 a[4]; | ||
| 908 | z7_x86_cpuid(a, kHv); | ||
| 909 | |||
| 910 | if (a[0] < kHv || a[0] >= kHv + (1 << 16)) | ||
| 911 | return; | ||
| 912 | { | ||
| 913 | { | ||
| 914 | for (unsigned j = 1; j < 4; j++) | ||
| 915 | PrintCpuChars(s, a[j]); | ||
| 916 | } | ||
| 917 | } | ||
| 918 | if (a[0] >= kHv + 1) | ||
| 919 | { | ||
| 920 | UInt32 d[4]; | ||
| 921 | z7_x86_cpuid(d, kHv + 1); | ||
| 922 | s += " : "; | ||
| 923 | PrintCpuChars(s, d[0]); | ||
| 924 | if (a[0] >= kHv + 2) | ||
| 925 | { | ||
| 926 | z7_x86_cpuid(d, kHv + 2); | ||
| 927 | s += " : "; | ||
| 928 | s.Add_UInt32(d[1] >> 16); | ||
| 929 | s.Add_Dot(); s.Add_UInt32(d[1] & 0xffff); | ||
| 930 | s.Add_Dot(); s.Add_UInt32(d[0]); | ||
| 931 | s.Add_Dot(); s.Add_UInt32(d[2]); | ||
| 932 | s.Add_Dot(); s.Add_UInt32(d[3] >> 24); | ||
| 933 | s.Add_Dot(); s.Add_UInt32(d[3] & 0xffffff); | ||
| 934 | } | ||
| 935 | /* | ||
| 936 | if (a[0] >= kHv + 5) | ||
| 937 | { | ||
| 938 | z7_x86_cpuid(d, kHv + 5); | ||
| 939 | s += " : "; | ||
| 940 | s.Add_UInt32(d[0]); | ||
| 941 | s += "p"; | ||
| 942 | s.Add_UInt32(d[1]); | ||
| 943 | s += "t"; | ||
| 944 | } | ||
| 945 | */ | ||
| 946 | } | ||
| 947 | } | ||
| 948 | } | ||
| 949 | |||
| 950 | #endif | ||
| 951 | |||
| 952 | |||
| 878 | void GetCompiler(AString &s) | 953 | void GetCompiler(AString &s) |
| 879 | { | 954 | { |
| 880 | #ifdef __VERSION__ | 955 | #ifdef __VERSION__ |
| @@ -884,28 +959,28 @@ void GetCompiler(AString &s) | |||
| 884 | #ifdef __GNUC__ | 959 | #ifdef __GNUC__ |
| 885 | s += " GCC "; | 960 | s += " GCC "; |
| 886 | s.Add_UInt32(__GNUC__); | 961 | s.Add_UInt32(__GNUC__); |
| 887 | s += '.'; | 962 | s.Add_Dot(); |
| 888 | s.Add_UInt32(__GNUC_MINOR__); | 963 | s.Add_UInt32(__GNUC_MINOR__); |
| 889 | s += '.'; | 964 | s.Add_Dot(); |
| 890 | s.Add_UInt32(__GNUC_PATCHLEVEL__); | 965 | s.Add_UInt32(__GNUC_PATCHLEVEL__); |
| 891 | #endif | 966 | #endif |
| 892 | 967 | ||
| 893 | #ifdef __clang__ | 968 | #ifdef __clang__ |
| 894 | s += " CLANG "; | 969 | s += " CLANG "; |
| 895 | s.Add_UInt32(__clang_major__); | 970 | s.Add_UInt32(__clang_major__); |
| 896 | s += '.'; | 971 | s.Add_Dot(); |
| 897 | s.Add_UInt32(__clang_minor__); | 972 | s.Add_UInt32(__clang_minor__); |
| 898 | #endif | 973 | #endif |
| 899 | 974 | ||
| 900 | #ifdef __xlC__ | 975 | #ifdef __xlC__ |
| 901 | s += " XLC "; | 976 | s += " XLC "; |
| 902 | s.Add_UInt32(__xlC__ >> 8); | 977 | s.Add_UInt32(__xlC__ >> 8); |
| 903 | s += '.'; | 978 | s.Add_Dot(); |
| 904 | s.Add_UInt32(__xlC__ & 0xFF); | 979 | s.Add_UInt32(__xlC__ & 0xFF); |
| 905 | #ifdef __xlC_ver__ | 980 | #ifdef __xlC_ver__ |
| 906 | s += '.'; | 981 | s.Add_Dot(); |
| 907 | s.Add_UInt32(__xlC_ver__ >> 8); | 982 | s.Add_UInt32(__xlC_ver__ >> 8); |
| 908 | s += '.'; | 983 | s.Add_Dot(); |
| 909 | s.Add_UInt32(__xlC_ver__ & 0xFF); | 984 | s.Add_UInt32(__xlC_ver__ & 0xFF); |
| 910 | #endif | 985 | #endif |
| 911 | #endif | 986 | #endif |
| @@ -914,4 +989,34 @@ void GetCompiler(AString &s) | |||
| 914 | s += " MSC "; | 989 | s += " MSC "; |
| 915 | s.Add_UInt32(_MSC_VER); | 990 | s.Add_UInt32(_MSC_VER); |
| 916 | #endif | 991 | #endif |
| 992 | |||
| 993 | #if defined(__AVX2__) | ||
| 994 | #define MY_CPU_COMPILE_ISA "AVX2" | ||
| 995 | #elif defined(__AVX__) | ||
| 996 | #define MY_CPU_COMPILE_ISA "AVX" | ||
| 997 | #elif defined(__SSE2__) | ||
| 998 | #define MY_CPU_COMPILE_ISA "SSE2" | ||
| 999 | #elif defined(_M_IX86_FP) && (_M_IX86_FP >= 2) | ||
| 1000 | #define MY_CPU_COMPILE_ISA "SSE2" | ||
| 1001 | #elif defined(__SSE__) | ||
| 1002 | #define MY_CPU_COMPILE_ISA "SSE" | ||
| 1003 | #elif defined(_M_IX86_FP) && (_M_IX86_FP >= 1) | ||
| 1004 | #define MY_CPU_COMPILE_ISA "SSE" | ||
| 1005 | #elif defined(__i686__) | ||
| 1006 | #define MY_CPU_COMPILE_ISA "i686" | ||
| 1007 | #elif defined(__i586__) | ||
| 1008 | #define MY_CPU_COMPILE_ISA "i586" | ||
| 1009 | #elif defined(__i486__) | ||
| 1010 | #define MY_CPU_COMPILE_ISA "i486" | ||
| 1011 | #elif defined(__i386__) | ||
| 1012 | #define MY_CPU_COMPILE_ISA "i386" | ||
| 1013 | #elif defined(_M_IX86_FP) | ||
| 1014 | #define MY_CPU_COMPILE_ISA "IA32" | ||
| 1015 | #endif | ||
| 1016 | |||
| 1017 | |||
| 1018 | #ifdef MY_CPU_COMPILE_ISA | ||
| 1019 | s += ':'; | ||
| 1020 | s.Add_OptSpaced(MY_CPU_COMPILE_ISA); | ||
| 1021 | #endif | ||
| 917 | } | 1022 | } |
