| 19 | #endif |
| 20 | |
| 21 | int 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 | |
| 68 | int init_recursive_mutex(pthread_mutex_t *m) |
| 69 | { |
no outgoing calls