| 478 | } |
| 479 | |
| 480 | unsigned int getNumberOfLogicalThreads() |
| 481 | { |
| 482 | static int nThreads = -1; |
| 483 | if (nThreads != -1) return nThreads; |
| 484 | |
| 485 | typedef WORD (WINAPI *GetActiveProcessorGroupCountFunc)(); |
| 486 | typedef DWORD (WINAPI *GetActiveProcessorCountFunc)(WORD); |
| 487 | HMODULE hlib = LoadLibrary("Kernel32"); |
| 488 | GetActiveProcessorGroupCountFunc pGetActiveProcessorGroupCount = (GetActiveProcessorGroupCountFunc)GetProcAddress(hlib, "GetActiveProcessorGroupCount"); |
| 489 | GetActiveProcessorCountFunc pGetActiveProcessorCount = (GetActiveProcessorCountFunc) GetProcAddress(hlib, "GetActiveProcessorCount"); |
| 490 | |
| 491 | if (pGetActiveProcessorGroupCount && pGetActiveProcessorCount) |
| 492 | { |
| 493 | int groups = pGetActiveProcessorGroupCount(); |
| 494 | int totalProcessors = 0; |
| 495 | for (int i = 0; i < groups; i++) |
| 496 | totalProcessors += pGetActiveProcessorCount(i); |
| 497 | nThreads = totalProcessors; |
| 498 | } |
| 499 | else |
| 500 | { |
| 501 | SYSTEM_INFO sysinfo; |
| 502 | GetSystemInfo(&sysinfo); |
| 503 | nThreads = sysinfo.dwNumberOfProcessors; |
| 504 | } |
| 505 | assert(nThreads); |
| 506 | return nThreads; |
| 507 | } |
| 508 | |
| 509 | int getTerminalWidth() |
| 510 | { |
no outgoing calls
no test coverage detected