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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2012 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 #include <sys/types.h>
kono
parents:
diff changeset
6 #include <sys/sysctl.h>
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 #include "runtime.h"
kono
parents:
diff changeset
9 #include "defs.h"
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 int32
kono
parents:
diff changeset
12 getproccount(void)
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 int mib[2], out;
kono
parents:
diff changeset
15 size_t len;
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 mib[0] = CTL_HW;
kono
parents:
diff changeset
18 mib[1] = HW_NCPU;
kono
parents:
diff changeset
19 len = sizeof(out);
kono
parents:
diff changeset
20 if(sysctl(mib, 2, &out, &len, NULL, 0) >= 0)
kono
parents:
diff changeset
21 return (int32)out;
kono
parents:
diff changeset
22 else
kono
parents:
diff changeset
23 return 0;
kono
parents:
diff changeset
24 }