Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Andy Shevchenko
On Mon, May 13, 2024 at 06:34:19PM +0530, Devarsh Thakkar wrote: > On 13/05/24 17:55, Andy Shevchenko wrote: > > On Mon, May 13, 2024 at 04:55:58PM +0530, Devarsh Thakkar wrote: > >> On 13/05/24 14:29, Andy Shevchenko wrote: > >>> On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: > >

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Devarsh Thakkar
Hi Andy, On 13/05/24 17:55, Andy Shevchenko wrote: > On Mon, May 13, 2024 at 04:55:58PM +0530, Devarsh Thakkar wrote: >> On 13/05/24 14:29, Andy Shevchenko wrote: >>> On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: On 10/05/24 20:45, Jani Nikula wrote: > > [...] > - align na

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Andy Shevchenko
On Mon, May 13, 2024 at 04:55:58PM +0530, Devarsh Thakkar wrote: > On 13/05/24 14:29, Andy Shevchenko wrote: > > On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: > >> On 10/05/24 20:45, Jani Nikula wrote: [...] > >>> Moreover, I think the naming of round_up() and round_down() shou

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Devarsh Thakkar
Hi Andy, On 13/05/24 14:29, Andy Shevchenko wrote: > On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: >> On 10/05/24 20:45, Jani Nikula wrote: > > [...] > >>> Moreover, I think the naming of round_up() and round_down() should have >>> reflected the fact that they operate on power

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Andy Shevchenko
On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: > On 10/05/24 20:45, Jani Nikula wrote: [...] > > Moreover, I think the naming of round_up() and round_down() should have > > reflected the fact that they operate on powers of 2. It's unfortunate > > that the difference to roundup()

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-13 Thread Andy Shevchenko
On Sun, May 12, 2024 at 07:46:58AM +0300, Alexey Dobriyan wrote: > I think > > roundup(x, 1 << n) Since it's about power-of-two, round_up() is better. > is more readable. -- With Best Regards, Andy Shevchenko

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-11 Thread Alexey Dobriyan
I think roundup(x, 1 << n) is more readable.

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-11 Thread Devarsh Thakkar
Hi Jani, Thanks for the quick review. On 10/05/24 20:45, Jani Nikula wrote: [...] > Moreover, I think the naming of round_up() and round_down() should have > reflected the fact that they operate on powers of 2. It's unfortunate > that the difference to roundup() and rounddown() is just the under

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-11 Thread Devarsh Thakkar
Hi Andy, Thanks for the quick review. On 10/05/24 20:31, Andy Shevchenko wrote: > On Fri, May 10, 2024 at 12:09:52AM +0530, Devarsh Thakkar wrote: >> Add macros to round to nearest specified power of 2. > > This is not what they are doing. For the above we already have macros defined. > Sorry

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-10 Thread Andy Shevchenko
On Fri, May 10, 2024 at 06:15:34PM +0300, Jani Nikula wrote: > On Fri, 10 May 2024, Andy Shevchenko > wrote: > > On Fri, May 10, 2024 at 12:09:52AM +0530, Devarsh Thakkar wrote: > >> Add macros to round to nearest specified power of 2. > > > > This is not what they are doing. For the above we alr

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-10 Thread Jani Nikula
On Fri, 10 May 2024, Andy Shevchenko wrote: > On Fri, May 10, 2024 at 12:09:52AM +0530, Devarsh Thakkar wrote: >> Add macros to round to nearest specified power of 2. > > This is not what they are doing. For the above we already have macros defined. > >> Two macros are added : > > (Yes, after I wr

Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-10 Thread Andy Shevchenko
On Fri, May 10, 2024 at 12:09:52AM +0530, Devarsh Thakkar wrote: > Add macros to round to nearest specified power of 2. This is not what they are doing. For the above we already have macros defined. > Two macros are added : (Yes, after I wrapped to comment this line looks better on its own, so

[PATCH v7 6/8] math.h Add macros to round to closest specified power of 2

2024-05-09 Thread Devarsh Thakkar
Add macros to round to nearest specified power of 2. Two macros are added : round_closest_up and round_closest_down which round up to nearest multiple of 2 with a preference to round up or round down respectively if there are two possible nearest values to the given number. This patch is inspired