I don't like adding additional levels of macros to build the augmented
rbtree callbacks. OTOH, all of the existing callbacks compute the max
(within the subtree) of a per-node scalar property. So, I guess I
could do a RB_DECLARE_MAX_CALLBACKS, and one of its arguments would
tell it how to compute the per-node scalar property, and it would
generate the code that both computes the max within the subtree and
assigns it into the augmented variable for the subtree's root. I will
prepare a v2 version of this patchset that does that.

On Mon, Jul 1, 2019 at 7:40 AM Peter Zijlstra <pet...@infradead.org> wrote:
>
> On Mon, Jul 01, 2019 at 09:46:30AM +0200, Peter Zijlstra wrote:
> > On Fri, Jun 28, 2019 at 05:49:52PM -0700, Michel Lespinasse wrote:
>
> > > The motivation for this change is that I want to introduce augmented 
> > > rbtree
> > > uses where the augmented data for the subtree is a struct instead of a 
> > > scalar.
>
> > Can't we have a helper macro that converts an old (scalar) style compute
> > into a new style compute and avoid this unfortunate and error prone
> > copy/pasta ?
>
> Or add a RBEQUAL argument that does:
>
> -               if (node->RBAUGMENTED == augmented)
> +               if (RBEQUAL(&node->RBAUGMENTED, &augmented))
>
> With a bit of foo you can even provide a default implementation that
> does: *a == *b.
>
> See GEN_UNARY_RMWcc() for how to do that.



-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.

Reply via email to