hare

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

commit ded6a857ae6ec506260ead973a6e91e1f4a0b6ca
parent 202446b8fed35ef124c4604e485319bb51cf7748
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun, 23 Apr 2023 02:40:55 -0400

os+linux: only call uname once

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

Diffstat:
Mos/+linux/environ+libc.ha | 5+++++
Mos/+linux/environ.ha | 5+++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/os/+linux/environ+libc.ha b/os/+linux/environ+libc.ha @@ -84,6 +84,7 @@ let uts_valid: bool = false; export fn sysname() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.sysname: *const char)!; }; @@ -92,6 +93,7 @@ export fn sysname() const str = { export fn hostname() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.nodename: *const char)!; }; @@ -100,6 +102,7 @@ export fn hostname() const str = { export fn release() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.release: *const char)!; }; @@ -108,6 +111,7 @@ export fn release() const str = { export fn version() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.version: *const char)!; }; @@ -116,6 +120,7 @@ export fn version() const str = { export fn machine() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.machine: *const char)!; }; diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -84,6 +84,7 @@ let uts_valid: bool = false; export fn sysname() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.sysname: *const char)!; }; @@ -92,6 +93,7 @@ export fn sysname() const str = { export fn hostname() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.nodename: *const char)!; }; @@ -100,6 +102,7 @@ export fn hostname() const str = { export fn release() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.release: *const char)!; }; @@ -108,6 +111,7 @@ export fn release() const str = { export fn version() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.version: *const char)!; }; @@ -116,6 +120,7 @@ export fn version() const str = { export fn machine() const str = { if (!uts_valid) { rt::uname(&uts) as void; + uts_valid = true; }; return strings::fromc(&uts.machine: *const char)!; };