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
26 #ifdef _SC_NPROCESSORS_ONLN
30 #ifdef GIT_WINDOWS_NATIVE
34 if ((int)info.dwNumberOfProcessors > 0)
35 return (int)info.dwNumberOfProcessors;
36 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
37 struct pst_dynamic psd;
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)
49 len = sizeof(cpucount);
50 if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
52 # endif /* HW_AVAILCPU */
54 len = sizeof(cpucount);
55 if (!sysctl(mib, 2, &cpucount, &len, NULL, 0))
57 #endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */
59 #ifdef _SC_NPROCESSORS_ONLN
60 if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
68 int init_recursive_mutex(pthread_mutex_t *m)
71 pthread_mutexattr_t a;
74 ret = pthread_mutexattr_init(&a);
76 ret = pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE);
78 ret = pthread_mutex_init(m, &a);
79 pthread_mutexattr_destroy(&a);
88 int dummy_pthread_create(pthread_t *pthread, const void *attr,
89 void *(*fn)(void *), void *data)
94 * The main purpose of this function is to break compiler's
95 * flow analysis and avoid -Wunused-variable false warnings.
100 int dummy_pthread_init(void *data)
105 * The main purpose of this function is to break compiler's
106 * flow analysis or it may realize that functions like
107 * pthread_mutex_init() is no-op, which means the (static)
108 * variable is not used/initialized at all and trigger
114 int dummy_pthread_join(pthread_t pthread, void **retval)
119 * The main purpose of this function is to break compiler's
120 * flow analysis and avoid -Wunused-variable false warnings.