JNIEXPORT void JNICALL Java_net_rubygrapefruit_platform_internal_jni_NativeLibraryFunctions_getSystemInfo(JNIEnv *env, jclass target, jobject info, jobject result) { jclass infoClass = env->GetObjectClass(info); OSVERSIONINFOEX versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (GetVersionEx((OSVERSIONINFO*)&versionInfo) == 0) { mark_failed_with_errno(env, "could not get version info", result); return; } SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); jstring arch = NULL; if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { arch = env->NewStringUTF("amd64"); } else if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { arch = env->NewStringUTF("x86"); } else if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) { arch = env->NewStringUTF("ia64"); } else { arch = env->NewStringUTF("unknown"); } jmethodID method = env->GetMethodID(infoClass, "windows", "(IIIZLjava/lang/String;)V"); env->CallVoidMethod(info, method, versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, versionInfo.dwBuildNumber, versionInfo.wProductType == VER_NT_WORKSTATION, arch); }
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem() { SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); return systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64; }
/** @Status Caveat @Notes Only HW_AVAILCPU is supported */ extern "C" int sysctl(const int* name, u_int namelen, void* oldp, size_t* oldlenp, const void* newp, size_t newlen) { if (namelen < 2 || name == nullptr) { errno = EINVAL; return -1; } if (namelen != 2 || name[0] != CTL_HW || name[1] != HW_AVAILCPU) { UNIMPLEMENTED_WITH_MSG("sysctl only supports querying HW_AVAILCPU"); errno = EOPNOTSUPP; return -1; } if (*oldlenp < sizeof(int)) { *oldlenp = sizeof(int); errno = ENOMEM; return -1; } SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); *static_cast<int*>(oldp) = systemInfo.dwNumberOfProcessors; *oldlenp = sizeof(int); return 0; }
NTSTATUS ProcessCore::Init() { // Detect x86 OS SYSTEM_INFO info = {{0}}; GetNativeSystemInfo(&info); if(info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { _native.reset(new x86Native(_hProcess)); } else { // Detect wow64 barrier BOOL wowSrc = FALSE; IsWow64Process(GetCurrentProcess(), &wowSrc); if(wowSrc == TRUE) _native.reset(new NativeWow64(_hProcess)); else _native.reset(new Native(_hProcess)); } // Get DEP info // For native x64 processes DEP is always enabled if(_native->GetWow64Barrier().targetWow64 == false) { _dep = true; } else { DWORD flags = 0; BOOL perm = 0; if(SAFE_CALL(GetProcessDEPPolicy, _hProcess, &flags, &perm)) _dep = (flags & PROCESS_DEP_ENABLE) != 0; } return STATUS_SUCCESS; }
int Engine::GetPrcessorInfo(){ SYSTEM_INFO stInfo; //GetSystemInfo(&stInfo); GetNativeSystemInfo(&stInfo); switch (stInfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL: //printf("Processor Architecture: Intel x86\n"); return 0; break; case PROCESSOR_ARCHITECTURE_IA64: //printf("Processor Type: Intel x64\n"); return 6; break; case PROCESSOR_ARCHITECTURE_AMD64: //printf("Processor Type: AMD 64\n"); return 9; break; default: //printf("Unknown processor architecture\n"); return -1; } }
virtual int load_driver_() { SYSTEM_INFO sys_info; ZeroMemory(&sys_info, sizeof(sys_info)); GetCurrentDirectory(MAX_PATH - 10, driver_filename); GetNativeSystemInfo(&sys_info); switch(sys_info.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: wcscat_s(driver_filename, MAX_PATH, L"\\winpmem_64.sys"); if(GetFileAttributes(driver_filename) == INVALID_FILE_ATTRIBUTES) { std::cout << "ERROR: winpmem_64.sys not found in current directory. Download it from https://volatility.googlecode.com/svn-history/r2813/branches/scudette/tools/windows/winpmem/binaries/winpmem_64.sys ." << std::endl; std::cout << "ERROR: Memory bandwidth statistics will not be available." << std::endl; } break; case PROCESSOR_ARCHITECTURE_INTEL: wcscat_s(driver_filename, MAX_PATH, L"\\winpmem_32.sys"); if(GetFileAttributes(driver_filename) == INVALID_FILE_ATTRIBUTES) { std::cout << "ERROR: winpmem_32.sys not found in current directory. Download it from https://volatility.googlecode.com/svn-history/r2813/branches/scudette/tools/windows/winpmem/binaries/winpmem_32.sys ." << std::endl; std::cout << "ERROR: Memory bandwidth statistics will not be available." << std::endl; } break; default: return -1; } return 1; }
int main(int argc, char *argv[]) { uv_setup_args(argc, argv); // no-op on Windows #else static void lock_low32() { #if defined(_P64) && defined(JL_DEBUG_BUILD) // block usage of the 32-bit address space on win64, to catch pointer cast errors char *const max32addr = (char*)0xffffffffL; SYSTEM_INFO info; MEMORY_BASIC_INFORMATION meminfo; GetNativeSystemInfo(&info); memset(&meminfo, 0, sizeof(meminfo)); meminfo.BaseAddress = info.lpMinimumApplicationAddress; while ((char*)meminfo.BaseAddress < max32addr) { VirtualQuery(meminfo.BaseAddress, &meminfo, sizeof(meminfo)); if (meminfo.State == MEM_FREE) { // reserve all free pages in the first 4GB of memory char *first = (char*)meminfo.BaseAddress; char *last = first + meminfo.RegionSize; char *p; if (last > max32addr) last = max32addr; // adjust first up to the first allocation granularity boundary // adjust last down to the last allocation granularity boundary first = (char*)(((long long)first + info.dwAllocationGranularity - 1) & ~(info.dwAllocationGranularity - 1)); last = (char*)((long long)last & ~(info.dwAllocationGranularity - 1)); if (last != first) { p = VirtualAlloc(first, last - first, MEM_RESERVE, PAGE_NOACCESS); // reserve all memory in between assert(p == first); } } meminfo.BaseAddress += meminfo.RegionSize; } #endif }
WitchSystemInfo::ProcessorArchitecture WitchSystemInfo::architecture() { static WitchSystemInfo::ProcessorArchitecture arch; if(arch) return arch; #if WITCHENGINE_PLATFORM == WITCHENGINE_PLATFORM_WIN32 || WITCHENGINE_PLATFORM == WITCHENGINE_PLATFORM_WIN64 SYSTEM_INFO sysinfo; GetNativeSystemInfo(&sysinfo); if(sysinfo.wProcessorArchitecture == 9) { arch = WitchSystemInfo::PA_AMD64; } else if(sysinfo.wProcessorArchitecture == 6) { arch = WitchSystemInfo::PA_IA64; } else if(sysinfo.wProcessorArchitecture == 0) { arch = WitchSystemInfo::PA_INTEL; } else { arch = WitchSystemInfo::PA_UNKNOWN; } #endif return arch; }
CStdString CSysInfo::GetUAWindowsVersion() { OSVERSIONINFOEX osvi = {}; osvi.dwOSVersionInfoSize = sizeof(osvi); CStdString strVersion = "Windows NT"; if (GetVersionEx((OSVERSIONINFO *)&osvi)) { strVersion += StringUtils::Format(" %d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion); } SYSTEM_INFO si = {}; GetSystemInfo(&si); BOOL bIsWow = FALSE; if (IsWow64Process(GetCurrentProcess(), &bIsWow)) { if (bIsWow) { strVersion.append(";WOW64"); GetNativeSystemInfo(&si); // different function to read the info under Wow } } if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) strVersion.append(";Win64;x64"); else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64) strVersion.append(";Win64;IA64"); return strVersion; }
/// <summary>Identify the windows version</summary> WindowsVersion::WindowsVersion() : Version(OS::Future) { // Prepare ZeroMemory((OSVERSIONINFO*)this, sizeof(OSVERSIONINFO)); dwOSVersionInfoSize = sizeof(OSVERSIONINFO); // Query windows version if (GetVersionEx(this)) { switch (dwMajorVersion) { // [WINDOWS NT 5] Windows 2000 or Windows XP case 5: switch (dwMinorVersion) { case 0: Version = OS::Win2000; break; case 1: Version = OS::WinXP; break; case 2: Version = OS::Server2003; break; } break; // [WINDOWS NT 6] Windows Vista, 7, or newer case 6: switch (dwMinorVersion) { case 0: Version = OS::Vista; break; case 1: Version = OS::Win7; break; default: Version = OS::Future; break; } break; } } // Set name switch (Version) { case OS::Win2000: Name = L"Windows 2000"; break; case OS::WinXP: Name = L"Windows XP"; break; case OS::Server2003: Name = L"Windows Server 2003"; break; case OS::Vista: Name = L"Windows Vista"; break; case OS::Win7: Name = L"Windows 7"; break; case OS::Future: Name = L"Windows Future"; break; } // Set Full name FullName = VString(L"%s %s (v%d.%d)", Name.c_str(), szCSDVersion, dwMajorVersion, dwMinorVersion); // Query architecture SYSTEM_INFO si; GetNativeSystemInfo(&si); switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: Architecture = L"x64"; break; case PROCESSOR_ARCHITECTURE_IA64: Architecture = L"Itanium"; break; case PROCESSOR_ARCHITECTURE_INTEL: Architecture = L"x86"; break; default: case PROCESSOR_ARCHITECTURE_UNKNOWN: Architecture = L"Unknown"; break; } }
/* Create a YAML file describing the image encoded into a null terminated string. Caller will own the memory. */ char *store_metadata_(struct PmemMemoryInfo *info) { SYSTEM_INFO sys_info; struct tm newtime; __time32_t aclock; char time_buffer[32]; errno_t errNum; char *arch = NULL; _time32(&aclock); // Get time in seconds. _gmtime32_s(&newtime, &aclock); // Convert time to struct tm form. // Print local time as a string. errNum = asctime_s(time_buffer, 32, &newtime); if (errNum) { time_buffer[0] = 0; } // Get basic architecture information (Note that we always write ELF64 core // dumps - even on 32 bit platforms). ZeroMemory(&sys_info, sizeof(sys_info)); GetNativeSystemInfo(&sys_info); switch (sys_info.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: arch = "AMD64"; break; case PROCESSOR_ARCHITECTURE_INTEL: arch = "I386"; break; default: arch = "Unknown"; } char *buffer = (char *)malloc(1000); _snprintf_s(buffer, 1000, _TRUNCATE, // A YAML File describing metadata about this image. "# PMEM\n" "---\n" // The start of the YAML file. "acquisition_tool: 'WinPMEM " PMEM_VERSION "'\n" "acquisition_timestamp: %s\n" "CR3: %#llx\n" "NtBuildNumber: %#llx\n" "NtBuildNumberAddr: %#llx\n" "KernBase: %#llx\n" "Arch: %s\n" "...\n", // This is the end of a YAML file. time_buffer, info->CR3.QuadPart, info->NtBuildNumber.QuadPart, info->NtBuildNumberAddr.QuadPart, info->KernBase.QuadPart, arch ); return buffer; };
_WIN32 indicates 64-bit or 32-bit Windows _MSC_VER indicates Microsoft C compiler !WIN_KERNEL_BUILD indicates Windows user-mode */ unsigned int abstraction_cpu_count (
/*** CPU ***/ unsigned vlc_GetCPUCount (void) { SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); return systemInfo.dwNumberOfProcessors; }
int cpu_count() { SYSTEM_INFO si; GetNativeSystemInfo( &si ); return (int)si.dwNumberOfProcessors; }
/// <summary> /// Capture stack frames /// </summary> /// <param name="ip">Current instruction pointer</param> /// <param name="sp">Current stack pointer</param> /// <param name="results">Found frames.</param> /// <param name="depth">Frame depth limit</param> /// <returns>Number of found frames</returns> size_t TraceHook::StackBacktrace( uintptr_t ip, uintptr_t sp, vecStackFrames& results, uintptr_t depth /*= 10 */ ) { SYSTEM_INFO sysinfo = { 0 }; uintptr_t stack_base = (uintptr_t)((PNT_TIB)NtCurrentTeb())->StackBase; GetNativeSystemInfo( &sysinfo ); // Store exception address results.emplace_back( std::make_pair( 0, ip ) ); // Walk stack for (uintptr_t stackPtr = sp; stackPtr < stack_base && results.size() <= depth; stackPtr += sizeof(void*)) { uintptr_t stack_val = *(uintptr_t*)stackPtr; MEMORY_BASIC_INFORMATION meminfo = { 0 }; // Decode value uintptr_t original = stack_val & HIGHEST_BIT_UNSET; // Invalid value if ( original < (uintptr_t)sysinfo.lpMinimumApplicationAddress || original > (uintptr_t)sysinfo.lpMaximumApplicationAddress) { continue; } // Check if memory is executable if (VirtualQuery( (LPVOID)original, &meminfo, sizeof(meminfo) ) != sizeof(meminfo)) continue; if ( meminfo.Protect != PAGE_EXECUTE_READ && meminfo.Protect != PAGE_EXECUTE_WRITECOPY && meminfo.Protect != PAGE_EXECUTE_READWRITE) { continue; } // Detect 'call' instruction for (uintptr_t j = 1; j < 8; j++) { DISASM info = { 0 }; info.EIP = original - j; #ifdef _M_AMD64 info.Archi = 64; #endif if (Disasm( &info ) > 0 && info.Instruction.BranchType == CallType) { results.emplace_back( std::make_pair( stackPtr, stack_val ) ); break; } } } return results.size(); }
int iam32on64 () { SYSTEM_INFO sysinfo_32, sysinfo_64; sysinfo_32.wProcessorArchitecture = 0; sysinfo_64.wProcessorArchitecture = 0; GetNativeSystemInfo (&sysinfo_64); GetSystemInfo (&sysinfo_32); return sysinfo_64.wProcessorArchitecture != sysinfo_32.wProcessorArchitecture && sysinfo_64.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; }
static app_mode_t get_app_mode() { SYSTEM_INFO sys_info; GetNativeSystemInfo(&sys_info); if (sys_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { return MODE_X86; } else if (sys_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { return MODE_X64; } return MODE_UNKNOWN; }
VOID GetSystemCPU(WCHAR *szBuffer) { SYSTEM_INFO archInfo; ISWOW64PROC fnIsWow64Process; BOOL isWow64 = FALSE; /* Find out if the program is running through WOW64 or not. Apparently, IsWow64Process() is not available on all versions of Windows, so the function has to be imported at runtime. If the function cannot be found, then assume the program is not running in WOW64. */ fnIsWow64Process = (ISWOW64PROC)GetProcAddress( GetModuleHandleW(L"kernel32"), "IsWow64Process"); if (fnIsWow64Process != NULL) fnIsWow64Process(GetCurrentProcess(), &isWow64); /* If the program is compiled as 32-bit, but is running in WOW64, it will automatically report as 32-bit regardless of the actual system architecture. It detects whether or not the program is using WOW64 or not, and then uses GetNativeSystemInfo(). If it is, it will properly report the actual system architecture to the user. */ if (isWow64) GetNativeSystemInfo(&archInfo); else GetSystemInfo(&archInfo); /* Now check to see what the system architecture is */ if(archInfo.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_UNKNOWN) { switch(archInfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL: { wsprintfW(szBuffer, L"32-bit"); break; } case PROCESSOR_ARCHITECTURE_AMD64: { wsprintfW(szBuffer, L"64-bit"); break; } case PROCESSOR_ARCHITECTURE_IA64: { wsprintfW(szBuffer, L"Itanium"); break; } case PROCESSOR_ARCHITECTURE_ARM: { wsprintfW(szBuffer, L"ARM"); break; } default:break; } } }
void main() { GetNativeSystemInfo(&sysInfo); // 64bit dectectOS(); // if(sysInfo.dwOemId) {printf("\nOEM ID : %s", sysInfo.dwOemId);} idProcessorArchitecture(); // get CPU ARCHITECTURE printf("\nNumber of Logical Processors : %d", sysInfo.dwNumberOfProcessors); currentSystemMemoryInformation(); }
BOOL is64() { SYSTEM_INFO si; GetNativeSystemInfo(&si); if (si.wProcessorArchitecture && PROCESSOR_ARCHITECTURE_INTEL) return FALSE; else return TRUE; }
bool is64() { SYSTEM_INFO si; GetNativeSystemInfo(&si); if (si.wProcessorArchitecture && PROCESSOR_ARCHITECTURE_INTEL) return false; else return true; }
/******************************************************************************* * * 函 数 名 : GetOSBit * 功能描述 : 取得操作系统位数 * 参数列表 : 无 * 说 明 : * 返回结果 : 如果成功,返回操作系统位数, 否则返回0 * *******************************************************************************/ ULONG GetOSBit(VOID) { SYSTEM_INFO si = {0} ; GetNativeSystemInfo(&si) ; if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) { return 64; } return 32; }
QTCREATOR_UTILS_EXPORT bool is64BitWindowsSystem() { #ifdef Q_OS_WIN SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); return systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64; #else return false; #endif }
static int get_cpu_count() { int core_count = 16; #if HAVE_UNISTD_H && !defined(__OS2__) #if defined(_SC_NPROCESSORS_ONLN) core_count = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(_SC_NPROC_ONLN) core_count = sysconf(_SC_NPROC_ONLN); #endif #elif defined(_WIN32) { #if _WIN32_WINNT >= 0x0501 SYSTEM_INFO sysinfo; GetNativeSystemInfo(&sysinfo); #else PGNSI pGNSI; SYSTEM_INFO sysinfo; /* Call GetNativeSystemInfo if supported or * GetSystemInfo otherwise. */ pGNSI = (PGNSI) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); if (pGNSI != NULL) pGNSI(&sysinfo); else GetSystemInfo(&sysinfo); #endif core_count = sysinfo.dwNumberOfProcessors; } #elif defined(__OS2__) { ULONG proc_id; ULONG status; core_count = 0; for (proc_id = 1; ; proc_id++) { if (DosGetProcessorStatus(proc_id, &status)) break; if (status == PROC_ONLINE) core_count++; } } #else /* other platforms */ #endif return core_count > 0 ? core_count : 1; }
const char * sysapi_condor_arch(void) { SYSTEM_INFO info; GetNativeSystemInfo(&info); if ( info.wProcessorArchitecture >= PROCESSOR_ARCHITECTURE_INTEL && info.wProcessorArchitecture <= PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 ) { return windows_architectures[info.wProcessorArchitecture]; } else { return unknown_architecture; } }
Native::Native( HANDLE hProcess, bool x86OS /*= false*/ ) : _hProcess( hProcess ) { SYSTEM_INFO info = { { 0 } }; GetNativeSystemInfo( &info ); _pageSize = info.dwPageSize; // x86 OS, emulate WOW64 processes if (x86OS) { _wowBarrier.sourceWow64 = true; _wowBarrier.targetWow64 = true; _wowBarrier.type = wow_32_32; _wowBarrier.x86OS = true; } else { BOOL wowSrc = FALSE, wowTgt = FALSE; IsWow64Process( GetCurrentProcess(), &wowSrc ); IsWow64Process( _hProcess, &wowTgt ); _wowBarrier.sourceWow64 = (wowSrc == TRUE); _wowBarrier.targetWow64 = (wowTgt == TRUE); if (wowSrc == TRUE && wowTgt == TRUE) _wowBarrier.type = wow_32_32; else if (wowSrc == FALSE && wowTgt == FALSE) _wowBarrier.type = wow_64_64; else if (wowSrc == TRUE) _wowBarrier.type = wow_32_64; else _wowBarrier.type = wow_64_32; } HMODULE hNtdll = GetModuleHandleW( L"ntdll.dll" ); HMODULE hKernel32 = GetModuleHandleW( L"kernel32.dll" ); DynImport::load( "NtQueryInformationProcess", hNtdll ); DynImport::load( "NtSetInformationProcess", hNtdll ); DynImport::load( "NtQueryInformationThread", hNtdll ); DynImport::load( "NtDuplicateObject", hNtdll ); DynImport::load( "NtQueryObject", hNtdll ); DynImport::load( "NtQuerySection", hNtdll ); DynImport::load( "RtlCreateActivationContext", hNtdll ); DynImport::load( "NtQueryVirtualMemory", hNtdll ); DynImport::load( "NtCreateThreadEx", hNtdll ); DynImport::load( "NtLockVirtualMemory", hNtdll ); DynImport::load( "NtSuspendProcess", hNtdll ); DynImport::load( "NtResumeProcess", hNtdll ); DynImport::load( "Wow64GetThreadContext", hKernel32 ); DynImport::load( "Wow64SetThreadContext", hKernel32 ); DynImport::load( "Wow64SuspendThread", hKernel32 ); }
PerformanceMonitor::PerformanceMonitor(){ HANDLE thisProcessHande = GetCurrentProcess(); SYSTEM_INFO sysInfo; BOOL runningInWow64 = false; IsWow64Process(thisProcessHande, &runningInWow64); if(runningInWow64){ GetNativeSystemInfo(&sysInfo); } else{ GetSystemInfo(&sysInfo); } this->processorsCount = sysInfo.dwNumberOfProcessors; }
/* * Returns 1 if the operating system is a 64-bit version of * Windows. */ int NaClOsIs64BitWindows() { SYSTEM_INFO system_info; GetNativeSystemInfo(&system_info); if (PROCESSOR_ARCHITECTURE_AMD64 == system_info.wProcessorArchitecture) { /* * The installed operating system processor architecture is x86-64. * This assumes the caller already knows it's a supported architecture. */ return 1; } return 0; }
const std::string& CSysInfo::GetKernelCpuFamily(void) { static std::string kernelCpuFamily; if (kernelCpuFamily.empty()) { #ifdef TARGET_WINDOWS SYSTEM_INFO si; GetNativeSystemInfo(&si); if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) kernelCpuFamily = "x86"; else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM) kernelCpuFamily = "ARM"; #elif defined(TARGET_DARWIN) const NXArchInfo* archInfo = NXGetLocalArchInfo(); if (archInfo) { const cpu_type_t cpuType = (archInfo->cputype & ~CPU_ARCH_ABI64); // get CPU family without 64-bit ABI flag if (cpuType == CPU_TYPE_I386) kernelCpuFamily = "x86"; else if (cpuType == CPU_TYPE_ARM) kernelCpuFamily = "ARM"; else if (cpuType == CPU_TYPE_POWERPC) kernelCpuFamily = "PowerPC"; #ifdef CPU_TYPE_MIPS else if (cpuType == CPU_TYPE_MIPS) kernelCpuFamily = "MIPS"; #endif // CPU_TYPE_MIPS } #elif defined(TARGET_POSIX) struct utsname un; if (uname(&un) == 0) { std::string machine(un.machine); if (machine.compare(0, 3, "arm", 3) == 0 || machine.compare(0, 7, "aarch64", 7) == 0) kernelCpuFamily = "ARM"; else if (machine.compare(0, 4, "mips", 4) == 0) kernelCpuFamily = "MIPS"; else if (machine.compare(0, 4, "i686", 4) == 0 || machine == "i386" || machine == "amd64" || machine.compare(0, 3, "x86", 3) == 0) kernelCpuFamily = "x86"; else if (machine.compare(0, 4, "s390", 4) == 0) kernelCpuFamily = "s390"; else if (machine.compare(0, 3, "ppc", 3) == 0 || machine.compare(0, 5, "power", 5) == 0) kernelCpuFamily = "PowerPC"; } #endif if (kernelCpuFamily.empty()) kernelCpuFamily = "unknown CPU family"; } return kernelCpuFamily; }
static void initialize_hardware_concurrency_info () { #if __TBB_WIN8UI_SUPPORT // For these applications processor groups info is unavailable // Setting up a number of processors for one processor group theProcessorGroups[0].numProcs = theProcessorGroups[0].numProcsRunningTotal = std::thread::hardware_concurrency(); #else /* __TBB_WIN8UI_SUPPORT */ dynamic_link( "Kernel32.dll", ProcessorGroupsApiLinkTable, sizeof(ProcessorGroupsApiLinkTable)/sizeof(dynamic_link_descriptor) ); SYSTEM_INFO si; GetNativeSystemInfo(&si); DWORD_PTR pam, sam, m = 1; GetProcessAffinityMask( GetCurrentProcess(), &pam, &sam ); int nproc = 0; for ( size_t i = 0; i < sizeof(DWORD_PTR) * CHAR_BIT; ++i, m <<= 1 ) { if ( pam & m ) ++nproc; } __TBB_ASSERT( nproc <= (int)si.dwNumberOfProcessors, NULL ); // By default setting up a number of processors for one processor group theProcessorGroups[0].numProcs = theProcessorGroups[0].numProcsRunningTotal = nproc; // Setting up processor groups in case the process does not restrict affinity mask and more than one processor group is present if ( nproc == (int)si.dwNumberOfProcessors && TBB_GetActiveProcessorCount ) { // The process does not have restricting affinity mask and multiple processor groups are possible ProcessorGroupInfo::NumGroups = (int)TBB_GetActiveProcessorGroupCount(); __TBB_ASSERT( ProcessorGroupInfo::NumGroups <= MaxProcessorGroups, NULL ); // Fail safety bootstrap. Release versions will limit available concurrency // level, while debug ones would assert. if ( ProcessorGroupInfo::NumGroups > MaxProcessorGroups ) ProcessorGroupInfo::NumGroups = MaxProcessorGroups; if ( ProcessorGroupInfo::NumGroups > 1 ) { TBB_GROUP_AFFINITY ga; if ( TBB_GetThreadGroupAffinity( GetCurrentThread(), &ga ) ) ProcessorGroupInfo::HoleIndex = ga.Group; int nprocs = 0; for ( WORD i = 0; i < ProcessorGroupInfo::NumGroups; ++i ) { ProcessorGroupInfo &pgi = theProcessorGroups[i]; pgi.numProcs = (int)TBB_GetActiveProcessorCount(i); __TBB_ASSERT( pgi.numProcs <= (int)sizeof(DWORD_PTR) * CHAR_BIT, NULL ); pgi.mask = pgi.numProcs == sizeof(DWORD_PTR) * CHAR_BIT ? ~(DWORD_PTR)0 : (DWORD_PTR(1) << pgi.numProcs) - 1; pgi.numProcsRunningTotal = nprocs += pgi.numProcs; } __TBB_ASSERT( nprocs == (int)TBB_GetActiveProcessorCount( TBB_ALL_PROCESSOR_GROUPS ), NULL ); } } #endif /* __TBB_WIN8UI_SUPPORT */ PrintExtraVersionInfo("Processor groups", "%d", ProcessorGroupInfo::NumGroups); if (ProcessorGroupInfo::NumGroups>1) for (int i=0; i<ProcessorGroupInfo::NumGroups; ++i) PrintExtraVersionInfo( "----- Group", "%d: size %d", i, theProcessorGroups[i].numProcs); }