VirtualBox

Changeset 7362 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Mar 7, 2008 1:34:06 PM (17 years ago)
Author:
vboxsync
Message:

quick adaption of system-win.cpp into mp-win.cpp.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/mp-win.cpp

    r7354 r7362  
    11/* $Id$ */
    22/** @file
    3  * innotek Portable Runtime - System, Win32.
     3 * innotek Portable Runtime - Multiprocessor, Windows.
    44 */
    55
     
    3131#define LOG_GROUP RTLOGGROUP_SYSTEM
    3232#include <Windows.h>
    33 #include <iprt/system.h>
     33#include <iprt/mp.h>
     34#include <iprt/cpuset.h>
    3435#include <iprt/assert.h>
    3536
    3637
     38/** @todo RTmpCpuId(). */
    3739
    38 RTDECL(unsigned) RTSystemProcessorGetCount(void)
     40RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
    3941{
    40     SYSTEM_INFO SysInfo;
    41 
    42     GetSystemInfo(&SysInfo);
    43 
    44     unsigned cCpus = (unsigned)SysInfo.dwNumberOfProcessors;
    45     Assert((DWORD)cCpus == SysInfo.dwNumberOfProcessors);
    46     return cCpus;
     42    return idCpu < MAXIMUM_PROCESSORS ? idCpu : -1;
    4743}
    4844
    4945
    50 RTDECL(uint64_t) RTSystemProcessorGetActiveMask(void)
     46RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
     47{
     48    return (unsigned)iCpu < MAXIMUM_PROCESSORS ? iCpu : NIL_RTCPUID;
     49}
     50
     51
     52RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
     53{
     54    return MAXIMUM_PROCESSORS - 1;
     55}
     56
     57
     58RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
     59{
     60    RTCPUSET Set;
     61    return RTCpuSetIsMember(RTMpGetOnlineSet(&Set), idCpu);
     62}
     63
     64
     65RTDECL(bool) RTMpDoesCpuExist(RTCPUID idCpu)
     66{
     67    RTCPUSET Set;
     68    return RTCpuSetIsMember(RTMpGetSet(&Set), idCpu);
     69}
     70
     71
     72RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
     73{
     74    RTCPUID idCpu = RTMpGetCount();
     75    RTCpuSetEmpty(pSet);
     76    while (idCpu-- > 0)
     77        RTCpuSetAdd(pSet, idCpu);
     78    return pSet;
     79}
     80
     81
     82RTDECL(RTCPUID) RTMpGetCount(void)
    5183{
    5284    SYSTEM_INFO SysInfo;
    53 
    5485    GetSystemInfo(&SysInfo);
    55 
    56     return SysInfo.dwActiveProcessorMask;
     86    Assert((RTCPUID)SysInfo.dwNumberOfProcessors == SysInfo.dwNumberOfProcessors);
     87    return SysInfo.dwNumberOfProcessors;
    5788}
    5889
     90
     91RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
     92{
     93    SYSTEM_INFO SysInfo;
     94    GetSystemInfo(&SysInfo);
     95    return RTCpuSetFromU64(pSet, SysInfo.dwActiveProcessorMask);
     96}
     97
     98
     99RTDECL(RTCPUID) RTMpGetOnlineCount(void)
     100{
     101    RTCPUSET Set;
     102    RTMpGetOnlineSet(&Set);
     103    return RTCpuSetCount(&Set);
     104}
     105
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette