On 27.10.2023 15:34, Nicola Vetrini wrote: > --- a/xen/include/xen/macros.h > +++ b/xen/include/xen/macros.h > @@ -8,8 +8,14 @@ > #define DIV_ROUND(n, d) (((n) + (d) / 2) / (d)) > #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) > > -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) > -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) > +/* > + * Given an unsigned integer argument, expands to a mask where just the least > + * significant nonzero bit of the argument is set, or 0 if no bits are set. > + */ > +#define ISOLATE_LOW_BIT(x) ((x) & -(x))
Not even considering future Misra changes (which aiui may require that anyway), this generalization of the macro imo demands that its argument now be evaluated only once. Also another thought regarding the name: Would ISOLATE_LSB() be acceptable to everyone having voiced a view on the set of proposed names? It would be at least a little shorter ... Jan
