diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-02-27 11:54:49 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-02-27 11:54:49 -0500 |
commit | 5798978f77ef8c3efb3c99fa7fb9538c5c597024 (patch) | |
tree | 32d3fbcff0910b4c17a7b4b6048d2e0631d2abfe /src/bfstd.c | |
parent | a561d782265c2157f270f0ead6b88db24e433d92 (diff) | |
download | bfs-5798978f77ef8c3efb3c99fa7fb9538c5c597024.tar.xz |
bfstd: New nproc() function
Diffstat (limited to 'src/bfstd.c')
-rw-r--r-- | src/bfstd.c | 10 |
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)); } |