VirtualBox

Changeset 11243 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 8, 2008 1:19:14 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34320
Message:

iprt/RTMpGetCount-posix: Avoid using _SC_NPROCESSORS_ONLN.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/RTMpGetCount-posix.cpp

    r8245 r11243  
    4444RTDECL(RTCPUID) RTMpGetCount(void)
    4545{
    46     int cCpus; NOREF(cCpus);
    47 
    4846    /*
    4947     * The sysconf way (linux and others).
    5048     */
    51 #ifdef _SC_NPROCESSORS_ONLN
    52     cCpus = sysconf(_SC_NPROCESSORS_ONLN);
    53     if (cCpus >= 1)
    54         return cCpus;
     49#if defined(_SC_NPROCESSORS_MAX) || defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN)
     50    int cCpusSC = -1;
     51# ifdef _SC_NPROCESSORS_MAX
     52    int cMax = sysconf(_SC_NPROCESSORS_MAX);
     53    cCpusSC = RT_MAX(cCpusSC, cMax);
     54# endif
     55# ifdef _SC_NPROCESSORS_CONF
     56    int cConf = sysconf(_SC_NPROCESSORS_CONF);
     57    cCpusSC = RT_MAX(cCpusSC, cConf);
     58# endif
     59# ifdef _SC_NPROCESSORS_ONLN
     60    int cOnln = sysconf(_SC_NPROCESSORS_ONLN);
     61    cCpusSC = RT_MAX(cCpusSC, cOnln);
     62# endif
     63    Assert(cCpusSC > 0);
     64    if (cCpusSC > 0)
     65        return cCpusSC;
    5566#endif
    5667
     
    6273    aiMib[0] = CTL_HW;
    6374    aiMib[1] = HW_NCPU;
    64     cCpus = -1;
     75    int cCpus = -1;
    6576    size_t cb = sizeof(cCpus);
    66     int rc = sysctl(aiMib, ELEMENTS(aiMib), &cCpus, &cb, NULL, 0);
     77    int rc = sysctl(aiMib, RT_ELEMENTS(aiMib), &cCpus, &cb, NULL, 0);
    6778    if (rc != -1 && cCpus >= 1)
    6879        return cCpus;
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