Re: [PATCH 1/7] math64: Add div64_s64_rem

From: Andy Shevchenko
Date: Wed Jul 16 2025 - 06:15:35 EST


On Tue, Jul 15, 2025 at 01:36:33PM -0400, Sean Anderson wrote:
> On 7/15/25 04:03, Andy Shevchenko wrote:
> > On Mon, Jul 14, 2025 at 09:20:17PM -0400, Sean Anderson wrote:
> >> Add a function to do signed 64-bit division with remainder. This is
> >> implemented using div64_u64_rem in the same way that div_s64_rem is
> >> implemented using div_u64_rem.
> >
> > LGTM, but one important Q. Can we (start to) add the test cases, please?
>
> Well, this just calls div64_u64_rem. So I am inclined to make the test something
> like
>
> #define test(n, d, q, r) ({ \
> u64 _q, _r; \
> _q = div64_u64_rem(n, d, &r); \
> assert(_q == q); \
> assert(_r == r); \
> })
>
> test( 3, 2, 1, 1);
> test( 3, -2, -1, 1);
> test(-3, 2, -1, -1);
> test(-3, -2, 1, -1);

Perhaps, but it should be done somewhere in lib/tests/...

--
With Best Regards,
Andy Shevchenko