[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH][for-4.19 v3 1/8] xen/include: add macro LOWEST_BIT



On 20/10/2023 19:03, Julien Grall wrote:
Hi Nicola,

On 20/10/2023 16:28, Nicola Vetrini wrote:
diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h
index d0caae7db298..49f3ebf848e9 100644
--- a/xen/include/xen/macros.h
+++ b/xen/include/xen/macros.h
@@ -8,8 +8,11 @@
  #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))
+/* Returns the 2^ffs(x) or 0, where ffs(x) is the index of the lowest set bit */
+#define LOWEST_BIT(x) ((x) & -(x))
+
+#define MASK_EXTR(v, m) (((v) & (m)) / LOWEST_BIT(m))
+#define MASK_INSR(v, m) (((v) * LOWEST_BIT(m)) & (m))
    #define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x
  #define count_args(args...) \
diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h
index aea259db1ef2..23cad71c8a47 100644
--- a/xen/include/xen/types.h
+++ b/xen/include/xen/types.h

I don't understand how the changes in this file are related to the
commit. Did you intend to create a separate commit?

The rest LGTM.


Oh, I made a mistake. This hunk should have been part of patch 7 as a cleanup.
I can resubmit with this removed, or it could be ignored altogether.

@@ -31,9 +31,9 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  #define NULL ((void*)0)
  #endif
  -#define INT8_MIN        (-127-1)
-#define INT16_MIN       (-32767-1)
-#define INT32_MIN       (-2147483647-1)
+#define INT8_MIN        (-127 - 1)
+#define INT16_MIN       (-32767 - 1)
+#define INT32_MIN       (-2147483647 - 1)
    #define INT8_MAX        (127)
  #define INT16_MAX       (32767)
@@ -43,10 +43,10 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
  #define UINT16_MAX      (65535)
  #define UINT32_MAX      (4294967295U)
  -#define INT_MAX         ((int)(~0U>>1))
+#define INT_MAX         ((int)(~0U >> 1))
  #define INT_MIN         (-INT_MAX - 1)
  #define UINT_MAX        (~0U)
-#define LONG_MAX        ((long)(~0UL>>1))
+#define LONG_MAX        ((long)(~0UL >> 1))
  #define LONG_MIN        (-LONG_MAX - 1)
  #define ULONG_MAX       (~0UL)


Cheers,

--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.