]>
git.proxmox.com Git - libgit2.git/blob - src/thread-utils.c
2 * Copyright (C) 2009-2012 the libgit2 contributors
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.
8 #include "thread-utils.h"
11 # define WIN32_LEAN_AND_MEAN
13 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
14 # include <sys/pstat.h>
18 * By doing this in two steps we can at least get
19 * the function to be somewhat coherent, even
20 * with this disgusting nest of #ifdefs.
22 #ifndef _SC_NPROCESSORS_ONLN
23 # ifdef _SC_NPROC_ONLN
24 # define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
25 # elif defined _SC_CRAY_NCPU
26 # define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
30 int git_online_cpus(void)
32 #ifdef _SC_NPROCESSORS_ONLN
40 if ((int)info
.dwNumberOfProcessors
> 0)
41 return (int)info
.dwNumberOfProcessors
;
42 #elif defined(hpux) || defined(__hpux) || defined(_hpux)
43 struct pst_dynamic psd
;
45 if (!pstat_getdynamic(&psd
, sizeof(psd
), (size_t)1, 0))
46 return (int)psd
.psd_proc_cnt
;
49 #ifdef _SC_NPROCESSORS_ONLN
50 if ((ncpus
= (long)sysconf(_SC_NPROCESSORS_ONLN
)) > 0)