]>
git.proxmox.com Git - libgit2.git/blob - src/thread-utils.c
e5ec6a843f89e9ac09fb100f5157f308b0b45c83
2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
9 #include "thread-utils.h"
12 #ifndef WIN32_LEAN_AND_MEAN
13 # define WIN32_LEAN_AND_MEAN
16 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
17 # include <sys/pstat.h>
21 * By doing this in two steps we can at least get
22 * the function to be somewhat coherent, even
23 * with this disgusting nest of #ifdefs.
25 #ifndef _SC_NPROCESSORS_ONLN
26 # ifdef _SC_NPROC_ONLN
27 # define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
28 # elif defined _SC_CRAY_NCPU
29 # define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
33 int git_online_cpus(void)
35 #ifdef _SC_NPROCESSORS_ONLN
43 if ((int)info
.dwNumberOfProcessors
> 0)
44 return (int)info
.dwNumberOfProcessors
;
45 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
46 struct pst_dynamic psd
;
48 if (!pstat_getdynamic(&psd
, sizeof(psd
), (size_t)1, 0))
49 return (int)psd
.psd_proc_cnt
;
52 #ifdef _SC_NPROCESSORS_ONLN
53 if ((ncpus
= (long)sysconf(_SC_NPROCESSORS_ONLN
)) > 0)