]>
git.ipfire.org Git - thirdparty/git.git/blob - thread-utils.c
2 #include "thread-utils.h"
4 #if defined(hpux) || defined(__hpux) || defined(_hpux)
5 # include <sys/pstat.h>
9 * By doing this in two steps we can at least get
10 * the function to be somewhat coherent, even
11 * with this disgusting nest of #ifdefs.
13 #ifndef _SC_NPROCESSORS_ONLN
14 # ifdef _SC_NPROC_ONLN
15 # define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
16 # elif defined _SC_CRAY_NCPU
17 # define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
23 #ifdef _SC_NPROCESSORS_ONLN
27 #ifdef GIT_WINDOWS_NATIVE
31 if ((int)info
.dwNumberOfProcessors
> 0)
32 return (int)info
.dwNumberOfProcessors
;
33 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
34 struct pst_dynamic psd
;
36 if (!pstat_getdynamic(&psd
, sizeof(psd
), (size_t)1, 0))
37 return (int)psd
.psd_proc_cnt
;
38 #elif defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU)
46 len
= sizeof(cpucount
);
47 if (!sysctl(mib
, 2, &cpucount
, &len
, NULL
, 0))
49 # endif /* HW_AVAILCPU */
51 len
= sizeof(cpucount
);
52 if (!sysctl(mib
, 2, &cpucount
, &len
, NULL
, 0))
54 #endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */
56 #ifdef _SC_NPROCESSORS_ONLN
57 if ((ncpus
= (long)sysconf(_SC_NPROCESSORS_ONLN
)) > 0)
64 int init_recursive_mutex(pthread_mutex_t
*m
)
66 pthread_mutexattr_t a
;
69 ret
= pthread_mutexattr_init(&a
);
71 ret
= pthread_mutexattr_settype(&a
, PTHREAD_MUTEX_RECURSIVE
);
73 ret
= pthread_mutex_init(m
, &a
);
74 pthread_mutexattr_destroy(&a
);