lkml.org 
[lkml]   [2023]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 1/1] drm/i915: Move abs_diff() to math.h
On Thu,  3 Aug 2023 16:19:18 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> abs_diff() belongs to math.h. Move it there.
> This will allow others to use it.
>
> ...
>
> --- a/include/linux/math.h
> +++ b/include/linux/math.h
> @@ -155,6 +155,13 @@ __STRUCT_FRACT(u32)
> __builtin_types_compatible_p(typeof(x), unsigned type), \
> ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
>
> +#define abs_diff(a, b) ({ \
> + typeof(a) __a = (a); \
> + typeof(b) __b = (b); \
> + (void)(&__a == &__b); \
> + __a > __b ? (__a - __b) : (__b - __a); \
> +})

Can we document it please?

Also, the open-coded type comparison could be replaced with __typecheck()?

And why the heck isn't __typecheck() in typecheck.h, to be included by
minmax.h.

etcetera. Sigh. I'll grab it, but please at least send along some
kerneldoc?


\
 
 \ /
  Last update: 2023-08-03 19:25    [W:0.045 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site