VirtualBox

Changeset 16354 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 28, 2009 11:52:28 PM (16 years ago)
Author:
vboxsync
Message:

mp-r0drv-darwin.cpp, the-darwin-kernel.h: ml_get_max_cpus() isn't available on darwin/AMD64, so try sysctlbyname(hw.ncpu) instead.

Location:
trunk/src/VBox/Runtime/r0drv/darwin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/mp-r0drv-darwin.cpp

    r16328 r16354  
    4444
    4545
     46/*******************************************************************************
     47*   Global Variables                                                           *
     48*******************************************************************************/
     49static int32_t volatile g_cMaxCpus = -1;
     50
     51
     52static int rtMpDarwinInitMaxCpus(void)
     53{
     54    int32_t cCpus = -1;
     55#ifdef RT_ARCH_AMD64
     56    size_t  oldLen = sizeof(cCpus);
     57    int rc = sysctlbyname("hw.ncpu", &cCpus, &oldLen, NULL, NULL);
     58    if (rc)
     59    {
     60        printf("IPRT: sysctlbyname(hw.ncpu) failed with rc=%d!\n", rc);
     61        cCpus = MY_DARWIN_MAX_CPUS;
     62    }
     63#else
     64    cCpus = ml_get_max_cpus();
     65#endif
     66
     67    ASMAtomicWriteS32(&g_cMaxCpus, cCpus);
     68    return cCpus;
     69}
     70
     71
    4672DECLINLINE(int) rtMpDarwinMaxCpus(void)
    4773{
    48     return ml_get_max_cpus();
     74    int cCpus = g_cMaxCpus;
     75    if (RT_UNLIKELY(cCpus <= 0))
     76        return rtMpDarwinInitMaxCpus();
     77    return cCpus;
    4978}
    5079
  • trunk/src/VBox/Runtime/r0drv/darwin/the-darwin-kernel.h

    r16330 r16354  
    6363#endif
    6464#include <libkern/libkern.h>
     65#include <libkern/sysctl.h>
    6566#include <mach/thread_act.h>
    6667#include <mach/vm_map.h>
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