[DTrace-devel] [DTrace] DTrace userspace branch dm/2.0-branch-dev-aggs updated. 2ffdae6376cbe280267577edbfc5dc93a776398f

Kris Van Hees kris.van.hees at oracle.com
Wed Nov 25 13:38:52 PST 2020


Catching up on various things and had a quick question on a comment below:

On Wed, Nov 25, 2020 at 09:41:33AM -0800, Eugene Loh wrote:
... stuff skipped...
> > +
> > +	// Change to a positive value
> > +	BPFCODE(BPF_NEG_REG(idxreg))
> 
> That changes the magnitude.  Probably need BPF_MUL_IMM(regfoo, -1) or 
> something.  Note that x and -x are not 2s complements.  If x and y are 
> 2s complements, they add up to -1.  x and -x add up to 0.

If the purpose of this code is to turn a vlaue that is negative into one that
is positive, i.e. the value is a int64_t, then why would BPF_NEG_REG(reg) be
wrong?  It is actually implemented as: regs[reg] = -regs[reg]



More information about the DTrace-devel mailing list