Is there a C API function that will give me the number of CPUs/cores on Mac OS X? Ideally, it should be something that just works across all flavors of OS X. (I really know nothing about Mac OS. This is for a library I’m working on that needs to support OS X.)
Share
You can use
sysctlbyname()with e.g.machdep.cpu.core_count. Do asysctl -afrom the command line to see what might be useful to you.