hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f7bd44d85dba55e61b3eb0947124848583c6ac89
parent f7ccc2ff0fb67c15925fb8de15f8439fe0582401
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri,  8 Sep 2023 00:21:16 -0400

os: make cpucount return size

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mcmd/hare/build.ha | 4++--
Mos/+freebsd/platform_environ.ha | 4++--
Mos/+linux/platform_environ.ha | 6+++---
3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmd/hare/build.ha b/cmd/hare/build.ha @@ -29,8 +29,8 @@ fn build(name: str, cmd: *getopt::command) (void | error) = { jobs = match (os::cpucount()) { case errors::error => yield 1z; - case let ncpu: int => - yield ncpu: size; + case let ncpu: size => + yield ncpu; }, version = build::get_version(os::tryenv("HAREC", "harec"))?, ... diff --git a/os/+freebsd/platform_environ.ha b/os/+freebsd/platform_environ.ha @@ -95,7 +95,7 @@ export fn machine() const str = { }; // Returns the number of usable CPUs. -export fn cpucount() (int | errors::error) = { +export fn cpucount() (size | errors::error) = { let count = 0; let length = size(int); match (rt::sysctlbyname("hw.ncpu", &count, &length, null, 0)) { @@ -103,5 +103,5 @@ export fn cpucount() (int | errors::error) = { case let err: rt::errno => return errors::errno(err); }; - return count; + return count: size; }; diff --git a/os/+linux/platform_environ.ha b/os/+linux/platform_environ.ha @@ -97,7 +97,7 @@ export fn machine() const str = { }; // Returns the number of usable CPUs. -export fn cpucount() (int | errors::error) = { +export fn cpucount() (size | errors::error) = { let set = rt::cpu_set { ... }; match (rt::sched_getaffinity(rt::getpid(), size(rt::cpu_set), &set)) { case void => void; @@ -105,9 +105,9 @@ export fn cpucount() (int | errors::error) = { return errors::errno(err); }; - let ret = 0; + let ret = 0z; for (let i = 0z; i < len(set.__bits); i += 1) { - ret += math::popcount(set.__bits[i]): int; + ret += math::popcount(set.__bits[i]); }; return ret; };