If so, someone familiar with Darwin needs to provide (a tested) darwin specific
proc.c implementation which can be added to libgomp/config/darwin/proc.c
to replace the libgomp/config/posix/proc.c version.

Here is code that does so:

  #include <sys/types.h>
  #include <sys/sysctl.h>

  int main()
  {
    int mib[2] = { CTL_HW, HW_AVAILCPU };
    int result, len;
    len = sizeof (result);
    sysctl (mib, 2, &result, &len, NULL, 0);
    printf ("%d\n", result);
  }

If you need to retrieve the number of processors in the system (i.e. the upper bound to HW_AVAILCPU, because the latter may change if a different power management modes is activated), you should use HW_NCPU instead.

Paolo

Reply via email to