Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: [...] > > > > > > +Also note that the modulo operation often varies by language > > > > > > +when the dividend or divisor are negative, where Python, Ruby, > etc. > > > > > > +differ from C, Go, Java, etc. This specification requires > > > > > > +that modulo use truncated division (where -13 % 3 == -1) as > > > > > > +implemented in C, Go, > > > > > > +etc.: > > > > > > + > > > > > > + a % n = a - n * trunc(a / n) > > > > > > + > > > > > > > > > > Interesting bit of info, but I'm not sure how it relates to the ISA doc. [...] > Those differences are in signed div/mod only, right? > Unsigned div/mod doesn't have it, right? > bpf has only unsigned div/mod. Ah right, will replace. However since imm is a signed integer, that leaves an ambiguity that is important to clarify. What is the expected value for the following 64-bit BPF_DIV operation: r0 = 0xFFFFFFFFFFFFFFFF r0 /= -10 Is it 0x1 or 0x10000000a? i.e., is the -10 sign extended to 0xFFFFFFFFFFFFFFF6 or treated as 0xFFFFFFF6 when doing the unsigned division? Dave