[Toybox] nproc(1)
Rob Landley
rob at landley.net
Tue Apr 30 20:36:34 PDT 2024
On 4/29/24 16:56, enh via Toybox wrote:
> isn't nproc(1) just a call to sysconf(3) with either
> _SC_NPROCESSORS_ONLN for regular behavior, or _SC_NPROCESSORS_CONF for
> --all?
>From musl src/conf/sysconf.c:
case JT_NPROCESSORS_CONF & 255:
case JT_NPROCESSORS_ONLN & 255: ;
unsigned char set[128] = {1};
int i, cnt;
__syscall(SYS_sched_getaffinity, 0, sizeof set, set);
for (i=cnt=0; i<sizeof set; i++)
for (; set[i]; set[i]&=set[i]-1, cnt++);
return cnt;
Musl returns the same thing for "conf" and "online".
Rob
More information about the Toybox
mailing list