Nikolay Borisov
2019-May-24 16:30 UTC
[Nouveau] [RFC][PATCH] kernel.h: Add generic roundup_64() macro
On 24.05.19 г. 18:26 ч., Steven Rostedt wrote:> On Fri, 24 May 2019 16:11:14 +0100 > Roger Willcocks <roger at filmlight.ltd.uk> wrote: > >> On 23/05/2019 16:27, Steven Rostedt wrote: >>> >>> I haven't yet tested this, but what about something like the following: >>> >>> ...perhaps forget about the constant check, and just force >>> the power of two check: >>> >>> \ >>> if (!(__y & (__y >> 1))) { \ >>> __x = round_up(x, y); \ >>> } else { \ >> >> You probably want >> >> if (!(__y & (__y - 1)) >> >> -- > > Yes I do. I corrected it in my next email. > > http://lkml.kernel.org/r/20190523133648.591f9e78 at gandalf.local.homeOr perhaps just using is_power_of_2 from include/linux/log2.h ?> >> #define roundup(x, y) ( \ >> { \ >> typeof(y) __y = y; \ >> typeof(x) __x; \ >> \ >> if (__y & (__y - 1)) \ >> __x = round_up(x, __y); \ >> else \ >> __x = (((x) + (__y - 1)) / __y) * __y; \ >> __x; \ >> }) > > > -- Steve >
Steven Rostedt
2019-May-24 16:36 UTC
[Nouveau] [RFC][PATCH] kernel.h: Add generic roundup_64() macro
On Fri, 24 May 2019 19:30:45 +0300 Nikolay Borisov <nborisov at suse.com> wrote:> > Yes I do. I corrected it in my next email. > > > > http://lkml.kernel.org/r/20190523133648.591f9e78 at gandalf.local.home > > Or perhaps just using is_power_of_2 from include/linux/log2.h ?Even better. Thanks, -- Steve
Maybe Matching Threads
- [RFC][PATCH] kernel.h: Add generic roundup_64() macro
- [RFC][PATCH] kernel.h: Add generic roundup_64() macro
- [RFC][PATCH] kernel.h: Add generic roundup_64() macro
- [RFC][PATCH] kernel.h: Add generic roundup_64() macro
- [RFC][PATCH] kernel.h: Add generic roundup_64() macro