All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Oleksii Kurochko" <oleksii.kurochko@gmail.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>, "Wei Liu" <wl@xen.org>,
	"Shawn Anastasio" <sanastasio@raptorengineering.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v4 08/14] xen/asm-generic: introduce generic div64.h header
Date: Mon, 27 Nov 2023 16:13:21 +0200	[thread overview]
Message-ID: <adc8456bd3c5574491f78ac7f8ce7934d359d005.1701093907.git.oleksii.kurochko@gmail.com> (raw)
In-Reply-To: <cover.1701093907.git.oleksii.kurochko@gmail.com>

All archs have the do_div implementation for BITS_PER_LONG == 64
so do_div64.h is moved to asm-generic.

x86 and PPC were switched to asm-generic version of div64.h.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in V4:
 - Added Acked-by: Jan Beulich <jbeulich@suse.com>.
 - include <asm-generic/div64.h> in Arm's div64.h for 64-bit case.
---
Changes in V3:
 - Drop x86 and PPC's div64.h.
 - Update the commit message.
---
Changes in V2:
	- rename base to divisor
	- add "#if BITS_PER_LONG == 64"
	- fix code style
---
 xen/arch/arm/include/asm/div64.h  |  8 +-------
 xen/arch/ppc/include/asm/Makefile |  1 +
 xen/arch/ppc/include/asm/div64.h  | 14 --------------
 xen/arch/x86/include/asm/Makefile |  1 +
 xen/arch/x86/include/asm/div64.h  | 14 --------------
 xen/include/asm-generic/div64.h   | 27 +++++++++++++++++++++++++++
 6 files changed, 30 insertions(+), 35 deletions(-)
 delete mode 100644 xen/arch/ppc/include/asm/div64.h
 delete mode 100644 xen/arch/x86/include/asm/div64.h
 create mode 100644 xen/include/asm-generic/div64.h

diff --git a/xen/arch/arm/include/asm/div64.h b/xen/arch/arm/include/asm/div64.h
index fc667a80f9..0459d5cc01 100644
--- a/xen/arch/arm/include/asm/div64.h
+++ b/xen/arch/arm/include/asm/div64.h
@@ -24,13 +24,7 @@
 
 #if BITS_PER_LONG == 64
 
-# define do_div(n,base) ({                                      \
-        uint32_t __base = (base);                               \
-        uint32_t __rem;                                         \
-        __rem = ((uint64_t)(n)) % __base;                       \
-        (n) = ((uint64_t)(n)) / __base;                         \
-        __rem;                                                  \
- })
+#include <asm-generic/div64.h>
 
 #elif BITS_PER_LONG == 32
 
diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/Makefile
index 3241236c64..5364bb1d59 100644
--- a/xen/arch/ppc/include/asm/Makefile
+++ b/xen/arch/ppc/include/asm/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += device.h
+generic-y += div64.h
 generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
diff --git a/xen/arch/ppc/include/asm/div64.h b/xen/arch/ppc/include/asm/div64.h
deleted file mode 100644
index d213e50585..0000000000
--- a/xen/arch/ppc/include/asm/div64.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_DIV64_H__
-#define __ASM_PPC_DIV64_H__
-
-#include <xen/types.h>
-
-#define do_div(n, base) ({                       \
-    uint32_t base_ = (base);                     \
-    uint32_t rem_ = (uint64_t)(n) % base_;       \
-    (n) = (uint64_t)(n) / base_;                 \
-    rem_;                                        \
-})
-
-#endif /* __ASM_PPC_DIV64_H__ */
diff --git a/xen/arch/x86/include/asm/Makefile b/xen/arch/x86/include/asm/Makefile
index 874429ed30..daab34ff0a 100644
--- a/xen/arch/x86/include/asm/Makefile
+++ b/xen/arch/x86/include/asm/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
+generic-y += div64.h
 generic-y += percpu.h
diff --git a/xen/arch/x86/include/asm/div64.h b/xen/arch/x86/include/asm/div64.h
deleted file mode 100644
index dd49f64a3b..0000000000
--- a/xen/arch/x86/include/asm/div64.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __X86_DIV64
-#define __X86_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
diff --git a/xen/include/asm-generic/div64.h b/xen/include/asm-generic/div64.h
new file mode 100644
index 0000000000..068d8a11ad
--- /dev/null
+++ b/xen/include/asm-generic/div64.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DIV64
+#define __ASM_GENERIC_DIV64
+
+#include <xen/types.h>
+
+#if BITS_PER_LONG == 64
+
+#define do_div(n, divisor) ({                   \
+    uint32_t divisor_ = (divisor);              \
+    uint32_t rem_ = (uint64_t)(n) % divisor_;   \
+    (n) = (uint64_t)(n) / divisor_;             \
+    rem_;                                       \
+})
+
+#endif /* BITS_PER_LONG */
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.43.0



  parent reply	other threads:[~2023-11-27 14:13 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 14:13 [PATCH v4 00/14] Introduce generic headers Oleksii Kurochko
2023-11-27 14:13 ` [PATCH v4 01/14] xen/asm-generic: introduce stub header paging.h Oleksii Kurochko
2023-11-28 21:16   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 02/14] xen/asm-generic: introduce generic device.h Oleksii Kurochko
2023-11-27 14:31   ` Jan Beulich
2023-11-27 19:46     ` Oleksii
2023-11-28  7:51       ` Jan Beulich
2023-11-28 21:36       ` Shawn Anastasio
2023-11-28 21:28   ` Shawn Anastasio
2023-11-29  8:16     ` Jan Beulich
2023-11-29 12:49     ` Oleksii
2023-11-29 19:18       ` Shawn Anastasio
2023-11-30 12:48         ` Oleksii
2023-11-27 14:13 ` [PATCH v4 03/14] xen/asm-generic: introduce generic hypercall.h Oleksii Kurochko
2023-11-28 21:47   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 04/14] xen/asm-generic: introduce generic header iocap.h Oleksii Kurochko
2023-11-28 21:50   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 05/14] xen/asm-generic: introduce stub header <asm/random.h> Oleksii Kurochko
2023-11-28 21:51   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 06/14] xen/asm-generic: introduce generic header percpu.h Oleksii Kurochko
2023-11-27 14:33   ` Jan Beulich
2023-11-28 21:58   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 07/14] xen/asm-generic: introduce generalized hardirq.h Oleksii Kurochko
2023-11-28 22:01   ` Shawn Anastasio
2023-11-27 14:13 ` Oleksii Kurochko [this message]
2023-11-28 22:07   ` [PATCH v4 08/14] xen/asm-generic: introduce generic div64.h header Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 09/14] xen/asm-generic: introduce generic header altp2m.h Oleksii Kurochko
2023-11-28 22:09   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 10/14] xen/asm-generic: introduce stub header monitor.h Oleksii Kurochko
2023-11-28 22:21   ` Shawn Anastasio
2023-11-29  8:19     ` Jan Beulich
2023-11-29  8:21       ` Jan Beulich
2023-11-29 12:41         ` Oleksii
2023-11-29 12:39     ` Oleksii
2023-11-29 19:27       ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 11/14] xen/asm-generic: introduce stub header numa.h Oleksii Kurochko
2023-11-27 14:35   ` Jan Beulich
2023-11-29 19:49   ` Shawn Anastasio
2023-11-30 12:49     ` Oleksii
2023-11-27 14:13 ` [PATCH v4 12/14] xen/asm-generic: introduce stub header softirq.h Oleksii Kurochko
2023-11-27 14:36   ` Jan Beulich
2023-11-27 19:39     ` Oleksii
2023-11-29 19:54   ` Shawn Anastasio
2023-11-29 20:04   ` Shawn Anastasio
2023-11-27 14:13 ` [PATCH v4 13/14] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h> Oleksii Kurochko
2023-11-27 14:41   ` Jan Beulich
2023-11-27 19:38     ` Oleksii
2023-11-28  7:57       ` Jan Beulich
2023-11-28  9:28         ` Oleksii
2023-11-28  9:58           ` Jan Beulich
2023-11-28 11:49             ` Oleksii
2023-11-28 12:53               ` Jan Beulich
2023-11-28 13:28                 ` Oleksii
2023-11-27 14:13 ` [PATCH v4 14/14] xen/asm-generic: ifdef inclusion of <asm/mem_access.h> Oleksii Kurochko
2023-11-27 14:43   ` Jan Beulich
2023-11-29  9:25 ` [PATCH v4 00/14] Introduce generic headers Jan Beulich
2023-11-29 12:32   ` Oleksii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adc8456bd3c5574491f78ac7f8ce7934d359d005.1701093907.git.oleksii.kurochko@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sanastasio@raptorengineering.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.