MCPcopy Index your code
hub / github.com/git/git / online_cpus

Function online_cpus

thread-utils.c:21–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#endif
20
21int online_cpus(void)
22{
23#ifdef NO_PTHREADS
24 return 1;
25#else
26#ifdef _SC_NPROCESSORS_ONLN
27 long ncpus;
28#endif
29
30#ifdef GIT_WINDOWS_NATIVE
31 SYSTEM_INFO info;
32 GetSystemInfo(&info);
33
34 if ((int)info.dwNumberOfProcessors > 0)
35 return (int)info.dwNumberOfProcessors;
36#elif defined(hpux) || defined(__hpux) || defined(_hpux)
37 struct pst_dynamic psd;
38
39 if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0))
40 return (int)psd.psd_proc_cnt;
41#elif defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU)
42 int mib[2];
43 size_t len;
44 int cpucount;
45
46 mib[0] = CTL_HW;
47# ifdef HW_AVAILCPU
48 mib[1] = HW_AVAILCPU;
49# elif defined(HW_NCPUONLINE)
50 mib[1] = HW_NCPUONLINE;
51# else
52 mib[1] = HW_NCPU;
53# endif /* HW_AVAILCPU */
54 len = sizeof(cpucount);
55 if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
56 return cpucount;
57#endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */
58
59#ifdef _SC_NPROCESSORS_ONLN
60 if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
61 return (int)ncpus;
62#endif
63
64 return 1;
65#endif
66}
67
68int init_recursive_mutex(pthread_mutex_t *m)
69{

Callers 15

hook_config_lookup_allFunction · 0.85
resolve_hook_config_jobsFunction · 0.85
do_read_indexFunction · 0.85
do_write_indexFunction · 0.85
lookup_lazy_paramsFunction · 0.85
cmd__online_cpusFunction · 0.85
testsuiteFunction · 0.85
cmd_grepFunction · 0.85
cmd_index_packFunction · 0.85
git_fetch_configFunction · 0.85

Calls

no outgoing calls

Tested by 2

cmd__online_cpusFunction · 0.68
testsuiteFunction · 0.68