Date: Tue, 28 Oct 2025 10:28:19 -0700 From: Gleb Smirnoff <glebius@freebsd.org> To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 3d73146baeb9 - main - pwait: Add an option to print remaining processes Message-ID: <aQD9M9K-Zk0M-213@cell.glebi.us> In-Reply-To: <202510281157.59SBvhNB002870@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
On Tue, Oct 28, 2025 at 11:57:43AM +0000, Dag-Erling Smørgrav wrote:
D> +static int
D> +pidcmp(const struct pid *a, const struct pid *b)
D> +{
D> + return (a->pid > b->pid ? 1 : a->pid < b->pid ? -1 : 0);
D> +}
D> +
D> +RB_HEAD(pidtree, pid);
D> +static struct pidtree pids = RB_INITIALIZER(&pids);
D> +RB_GENERATE_STATIC(pidtree, pid, entry, pidcmp);
We have a nice trick in our tree(3) that allows to use lighter compare
functions. The function can return any signed integer type, thus we
can:
static pid_t
pidcmp(const struct pid *a, const struct pid *b)
{
return (a->pid - b->pid);
}
--
Gleb Smirnoff
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aQD9M9K-Zk0M-213>
