summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-02-27 11:54:49 -0500
committerTavian Barnes <tavianator@tavianator.com>2025-02-27 11:54:49 -0500
commit5798978f77ef8c3efb3c99fa7fb9538c5c597024 (patch)
tree32d3fbcff0910b4c17a7b4b6048d2e0631d2abfe /src/bfstd.c
parenta561d782265c2157f270f0ead6b88db24e433d92 (diff)
downloadbfs-5798978f77ef8c3efb3c99fa7fb9538c5c597024.tar.xz
bfstd: New nproc() function
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c10
1 files changed, 10 insertions, 0 deletions
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));
}