runtime: nr_cpus()
parent
a280e98d7f
commit
52c2fa44b8
|
@ -1686,7 +1686,7 @@ fn (p mut Parser) bterm() string {
|
||||||
|
|
||||||
// also called on *, &, @, . (enum)
|
// also called on *, &, @, . (enum)
|
||||||
fn (p mut Parser) name_expr() string {
|
fn (p mut Parser) name_expr() string {
|
||||||
//println('n')
|
//println('n')
|
||||||
p.has_immutable_field = false
|
p.has_immutable_field = false
|
||||||
p.is_const_literal = false
|
p.is_const_literal = false
|
||||||
ph := p.cgen.add_placeholder()
|
ph := p.cgen.add_placeholder()
|
||||||
|
|
|
@ -31,7 +31,6 @@ struct VargAccess {
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
enum NameCategory {
|
enum NameCategory {
|
||||||
constant
|
constant
|
||||||
mod
|
mod
|
||||||
|
@ -41,8 +40,8 @@ enum NameCategory {
|
||||||
|
|
||||||
struct Name {
|
struct Name {
|
||||||
cat NameCategory
|
cat NameCategory
|
||||||
|
idx int // e.g. typ := types[name.idx]
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
struct GenTable {
|
struct GenTable {
|
||||||
fn_name string
|
fn_name string
|
||||||
|
|
|
@ -35,7 +35,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
fn new_hashmap(planned_nr_items int) hashmap {
|
fn new_hashmap(planned_nr_items int) hashmap {
|
||||||
mut cap := planned_nr_items * 3
|
mut cap := planned_nr_items * 5
|
||||||
if cap < min_cap {
|
if cap < min_cap {
|
||||||
cap = min_cap
|
cap = min_cap
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ pub fn (m &map) keys() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (m map) get(key string, out voidptr) bool {
|
fn (m map) get(key string, out voidptr) bool {
|
||||||
//println('g')
|
println('g')
|
||||||
if m.root == 0 {
|
if m.root == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||||
|
// Use of this source code is governed by an MIT license
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
module runtime
|
||||||
|
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
|
fn C.get_nprocs() int
|
||||||
|
|
||||||
|
pub fn nr_cpus() int {
|
||||||
|
return C.get_nprocs()
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
import runtime
|
||||||
|
|
||||||
|
fn test_nr_cpus() {
|
||||||
|
nr_cpus := runtime.nr_cpus()
|
||||||
|
println(nr_cpus)
|
||||||
|
assert nr_cpus > 0
|
||||||
|
}
|
Loading…
Reference in New Issue