From 9193242a7652aafd2925d40a1c0a96ee400b6497 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 11 Oct 2019 14:16:02 +0300 Subject: [PATCH] fix runtime module test --- vlib/runtime/runtime.v | 12 ------------ vlib/runtime/runtime_lin.v | 13 +++++++++++++ vlib/runtime/runtime_mac.v | 5 +++++ vlib/runtime/runtime_test.v | 2 ++ vlib/runtime/runtime_win.v | 5 +++++ 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 vlib/runtime/runtime_lin.v create mode 100644 vlib/runtime/runtime_mac.v create mode 100644 vlib/runtime/runtime_win.v 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 +}