Mercurial > hg > CbC > CbC_gcc
annotate libgo/runtime/getncpu-bsd.c @ 141:ce508c72660f
copy cbc flang in cfgexpand
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 22 Nov 2018 19:44:39 +0900 |
parents | 04ced10e8804 |
children |
rev | line source |
---|---|
111 | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | |
3 // license that can be found in the LICENSE file. | |
4 | |
5 #include <sys/types.h> | |
6 #include <sys/sysctl.h> | |
7 | |
8 #include "runtime.h" | |
9 #include "defs.h" | |
10 | |
11 int32 | |
12 getproccount(void) | |
13 { | |
14 int mib[2], out; | |
15 size_t len; | |
16 | |
17 mib[0] = CTL_HW; | |
18 mib[1] = HW_NCPU; | |
19 len = sizeof(out); | |
20 if(sysctl(mib, 2, &out, &len, NULL, 0) >= 0) | |
21 return (int32)out; | |
22 else | |
23 return 0; | |
24 } |