diff --git a/vlib/runtime/runtime.v b/vlib/runtime/runtime.v index 842a54487b..7777c00615 100644 --- a/vlib/runtime/runtime.v +++ b/vlib/runtime/runtime.v @@ -1,13 +1 @@ -// 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 - -fn C.get_nprocs() int - -pub fn nr_cpus() int { - return C.get_nprocs() -} diff --git a/vlib/runtime/runtime_lin.v b/vlib/runtime/runtime_lin.v new file mode 100644 index 0000000000..842a54487b --- /dev/null +++ b/vlib/runtime/runtime_lin.v @@ -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 + +fn C.get_nprocs() int + +pub fn nr_cpus() int { + return C.get_nprocs() +} diff --git a/vlib/runtime/runtime_mac.v b/vlib/runtime/runtime_mac.v new file mode 100644 index 0000000000..7345c63217 --- /dev/null +++ b/vlib/runtime/runtime_mac.v @@ -0,0 +1,5 @@ +module runtime + +pub fn nr_cpus() int { + return 0 +} diff --git a/vlib/runtime/runtime_test.v b/vlib/runtime/runtime_test.v index c1cb53d999..639a86eb59 100644 --- a/vlib/runtime/runtime_test.v +++ b/vlib/runtime/runtime_test.v @@ -1,7 +1,9 @@ import runtime fn test_nr_cpus() { + $if linux { nr_cpus := runtime.nr_cpus() println(nr_cpus) assert nr_cpus > 0 + } } diff --git a/vlib/runtime/runtime_win.v b/vlib/runtime/runtime_win.v new file mode 100644 index 0000000000..7345c63217 --- /dev/null +++ b/vlib/runtime/runtime_win.v @@ -0,0 +1,5 @@ +module runtime + +pub fn nr_cpus() int { + return 0 +}