From 5798978f77ef8c3efb3c99fa7fb9538c5c597024 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 27 Feb 2025 11:54:49 -0500 Subject: bfstd: New nproc() function --- src/bfstd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/bfstd.c') diff --git a/src/bfstd.c b/src/bfstd.c index 219b8d0..aee6930 100644 --- a/src/bfstd.c +++ b/src/bfstd.c @@ -775,6 +775,16 @@ long xsysconf(int name) { return ret; } +long nproc(void) { + long nproc = xsysconf(_SC_NPROCESSORS_ONLN); + + if (nproc < 1) { + return 1; + } else { + return nproc; + } +} + size_t asciilen(const char *str) { return asciinlen(str, strlen(str)); } -- cgit v1.2.3