[PATCH v1 20/29] xen/asm-generic: introduce stub header div64.h

Oleksii Kurochko posted 29 patches 2 years, 3 months ago
[PATCH v1 20/29] xen/asm-generic: introduce stub header div64.h
Posted by Oleksii Kurochko 2 years, 3 months ago
The patch introduces header stub necessry for full Xen build.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/include/asm-generic/div64.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 xen/include/asm-generic/div64.h

diff --git a/xen/include/asm-generic/div64.h b/xen/include/asm-generic/div64.h
new file mode 100644
index 0000000000..9f9c20878b
--- /dev/null
+++ b/xen/include/asm-generic/div64.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DIV64
+#define __ASM_GENERIC_DIV64
+
+#include <xen/types.h>
+
+# define do_div(n,base) ({                                      \
+        uint32_t __base = (base);                               \
+        uint32_t __rem;                                         \
+        __rem = ((uint64_t)(n)) % __base;                       \
+        (n) = ((uint64_t)(n)) / __base;                         \
+        __rem;                                                  \
+ })
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.41.0
Re: [PATCH v1 20/29] xen/asm-generic: introduce stub header div64.h
Posted by Jan Beulich 2 years, 2 months ago
On 14.09.2023 16:56, Oleksii Kurochko wrote:
> --- /dev/null
> +++ b/xen/include/asm-generic/div64.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +#ifndef __ASM_GENERIC_DIV64
> +#define __ASM_GENERIC_DIV64
> +
> +#include <xen/types.h>
> +
> +# define do_div(n,base) ({                                      \
> +        uint32_t __base = (base);                               \
> +        uint32_t __rem;                                         \
> +        __rem = ((uint64_t)(n)) % __base;                       \
> +        (n) = ((uint64_t)(n)) / __base;                         \
> +        __rem;                                                  \
> + })

While I'm fine with having just the BITS_PER_LONG == 64 implementation
here, this then still needs to have the #if retained that Arm has. Only
with that will it then be fine to have a blank between # and define.

There are style issues though: A blank is missing after the comma,
and according to recent agreement leading underscores should not be
used for symbols like the ones here anymore (I also wonder whether
"base" is really a good name for the symbol; "divisor" may be more to
the point). There are also excess parentheses around the two cast
expressions.

Jan
Re: [PATCH v1 20/29] xen/asm-generic: introduce stub header div64.h
Posted by Oleksii 2 years, 1 month ago
On Thu, 2023-10-19 at 13:12 +0200, Jan Beulich wrote:
> On 14.09.2023 16:56, Oleksii Kurochko wrote:
> > --- /dev/null
> > +++ b/xen/include/asm-generic/div64.h
> > @@ -0,0 +1,24 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +#ifndef __ASM_GENERIC_DIV64
> > +#define __ASM_GENERIC_DIV64
> > +
> > +#include <xen/types.h>
> > +
> > +# define do_div(n,base) ({                                      \
> > +        uint32_t __base = (base);                               \
> > +        uint32_t __rem;                                         \
> > +        __rem = ((uint64_t)(n)) % __base;                       \
> > +        (n) = ((uint64_t)(n)) / __base;                         \
> > +        __rem;                                                  \
> > + })
> 
> While I'm fine with having just the BITS_PER_LONG == 64
> implementation
> here, this then still needs to have the #if retained that Arm has.
> Only
> with that will it then be fine to have a blank between # and define.
> 
> There are style issues though: A blank is missing after the comma,
> and according to recent agreement leading underscores should not be
> used for symbols like the ones here anymore (I also wonder whether
> "base" is really a good name for the symbol; "divisor" may be more to
> the point). There are also excess parentheses around the two cast
> expressions.
Thanks. I'll take mentioned into account.

~ Oleskii