Re: git: 3d73146baeb9 - main - pwait: Add an option to print remaining processes
Date: Tue, 28 Oct 2025 17:28:19 UTC
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