History log of /freebsd-current/bin/nproc/nproc.c
Revision Date Author Comments
# 606c37c5 12-Apr-2024 Collin Funk <collin.funk1@gmail.com>

nproc: Prefer sys/cdefs.h __unreachable over the builtin

The __builtin_unreachable macro provided by Clang and GCC is a hint to
the compiler used for optimization. The programs work fine even if the
compiler doesn't support it. The sys/cdefs.h has had __unreachable for
9 years (commit 732b31de5d9244bd1cc98192e09ee1881e9f55e9). It expands
to the builtin if it is available. In the rare case that it is
unsupported it expands to a null statement so compilation does not
fail.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: imp, freebsd@igalic.co
Pull Request: https://github.com/freebsd/freebsd-src/pull/1117


# 059320b8 15-Feb-2023 Mateusz Guzik <mjg@FreeBSD.org>

nproc: denote an incompatiblity with Linux

On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel,
while it does not on FreeBSD.

Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting
the same value, it will automagically unbreak should someone change the
above.


# 48bfd359 04-Feb-2023 Mateusz Guzik <mjg@FreeBSD.org>

Add nproc(1)

This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by: des
Reviewed by: pstef
Differential Revision: https://reviews.freebsd.org/D38386