* [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes
@ 2016-05-04 13:04 Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-05-04 13:04 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: Laurent Vivier
Some fixes in the use of muldiv64()
The patches have been generated with the help of coccinelle.
The first patch contains the scripts used to generate the two following
patches. As it is done for linux, I've added the scripts under
scripts/coccinelle.
Laurent Vivier (3):
scripts: add muldiv64() checking coccinelle scripts
The only 64bit parameter of muldiv64() is the first one.
remove useless muldiv64()
hw/timer/omap_gptimer.c | 4 +--
hw/usb/hcd-ohci.c | 2 +-
scripts/coccinelle/remove_muldiv64.cocci | 6 +++++
scripts/coccinelle/swap_muldiv64.cocci | 46 ++++++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 3 deletions(-)
create mode 100644 scripts/coccinelle/remove_muldiv64.cocci
create mode 100644 scripts/coccinelle/swap_muldiv64.cocci
--
2.5.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts
2016-05-04 13:04 [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Laurent Vivier
@ 2016-05-04 13:04 ` Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 2/3] The only 64bit parameter of muldiv64() is the first one Laurent Vivier
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-05-04 13:04 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: Laurent Vivier
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
scripts/coccinelle/remove_muldiv64.cocci | 6 +++++
scripts/coccinelle/swap_muldiv64.cocci | 46 ++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
create mode 100644 scripts/coccinelle/remove_muldiv64.cocci
create mode 100644 scripts/coccinelle/swap_muldiv64.cocci
diff --git a/scripts/coccinelle/remove_muldiv64.cocci b/scripts/coccinelle/remove_muldiv64.cocci
new file mode 100644
index 0000000..4c10bd5
--- /dev/null
+++ b/scripts/coccinelle/remove_muldiv64.cocci
@@ -0,0 +1,6 @@
+// replace muldiv64(a, 1, b) by "a / b"
+@@
+expression a, b;
+@@
+-muldiv64(a, 1, b)
++a / b
diff --git a/scripts/coccinelle/swap_muldiv64.cocci b/scripts/coccinelle/swap_muldiv64.cocci
new file mode 100644
index 0000000..39a278d
--- /dev/null
+++ b/scripts/coccinelle/swap_muldiv64.cocci
@@ -0,0 +1,46 @@
+// replace muldiv64(i32, i64, x) by muldiv64(i64, i32, x)
+@filter@
+typedef uint64_t;
+typedef int64_t;
+typedef uint32_t;
+typedef int32_t;
+uint64_t u64;
+int64_t s64;
+uint32_t u32;
+int32_t s32;
+int si;
+unsigned int ui;
+long sl;
+unsigned long ul;
+expression b;
+position p;
+@@
+ muldiv64(
+(
+si
+|
+ui
+|
+s32
+|
+u32
+)
+,
+(
+sl
+|
+ul
+|
+u64
+|
+s64
+)
+, b)@p
+
+@swap@
+position filter.p;
+expression a, b, c;
+@@
+
+-muldiv64(a,b,c)@p
++muldiv64(b,a,c)
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/3] The only 64bit parameter of muldiv64() is the first one.
2016-05-04 13:04 [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts Laurent Vivier
@ 2016-05-04 13:04 ` Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 3/3] remove useless muldiv64() Laurent Vivier
2016-05-04 18:12 ` [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-05-04 13:04 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: Laurent Vivier, Peter Maydell, Gerd Hoffmann
muldiv64() is "uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)"
Some time it is used as muldiv64(uint32_t a, uint64_t b, uint32_t c)"
This patch is the result of coccinelle script
scripts/coccinelle/swap_muldiv64.cocci to reorder arguments.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
hw/timer/omap_gptimer.c | 4 ++--
hw/usb/hcd-ohci.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c
index 3a43863..5e3e8a6 100644
--- a/hw/timer/omap_gptimer.c
+++ b/hw/timer/omap_gptimer.c
@@ -133,8 +133,8 @@ static inline void omap_gp_timer_update(struct omap_gp_timer_s *timer)
timer_mod(timer->timer, timer->time + expires);
if (timer->ce && timer->match_val >= timer->val) {
- matches = muldiv64(timer->match_val - timer->val,
- timer->ticks_per_sec, timer->rate);
+ matches = muldiv64(timer->ticks_per_sec,
+ timer->match_val - timer->val, timer->rate);
timer_mod(timer->match, timer->time + matches);
} else
timer_del(timer->match);
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index ffab561..e5b535f 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1474,7 +1474,7 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)
if (tks >= usb_frame_time)
return (ohci->frt << 31);
- tks = muldiv64(1, tks, usb_bit_time);
+ tks = muldiv64(tks, 1, usb_bit_time);
fr = (uint16_t)(ohci->fi - tks);
return (ohci->frt << 31) | fr;
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 3/3] remove useless muldiv64()
2016-05-04 13:04 [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 2/3] The only 64bit parameter of muldiv64() is the first one Laurent Vivier
@ 2016-05-04 13:04 ` Laurent Vivier
2016-05-04 18:12 ` [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-05-04 13:04 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: Laurent Vivier, Gerd Hoffmann
muldiv64(a, 1, b) is like "a / b".
This patch is the result of coccinelle script
scripts/coccinelle/remove_muldiv64.cocci.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
hw/usb/hcd-ohci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index e5b535f..2af6c16 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1474,7 +1474,7 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)
if (tks >= usb_frame_time)
return (ohci->frt << 31);
- tks = muldiv64(tks, 1, usb_bit_time);
+ tks = tks / usb_bit_time;
fr = (uint16_t)(ohci->fi - tks);
return (ohci->frt << 31) | fr;
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes
2016-05-04 13:04 [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Laurent Vivier
` (2 preceding siblings ...)
2016-05-04 13:04 ` [Qemu-devel] [PATCH 3/3] remove useless muldiv64() Laurent Vivier
@ 2016-05-04 18:12 ` Richard Henderson
3 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2016-05-04 18:12 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel, qemu-trivial
On 05/04/2016 03:04 AM, Laurent Vivier wrote:
> Some fixes in the use of muldiv64()
>
> The patches have been generated with the help of coccinelle.
>
> The first patch contains the scripts used to generate the two following
> patches. As it is done for linux, I've added the scripts under
> scripts/coccinelle.
>
> Laurent Vivier (3):
> scripts: add muldiv64() checking coccinelle scripts
> The only 64bit parameter of muldiv64() is the first one.
> remove useless muldiv64()
Reviewed-by: Richard Henderson <rth@twiddle.net>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-04 18:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-04 13:04 [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 1/3] scripts: add muldiv64() checking coccinelle scripts Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 2/3] The only 64bit parameter of muldiv64() is the first one Laurent Vivier
2016-05-04 13:04 ` [Qemu-devel] [PATCH 3/3] remove useless muldiv64() Laurent Vivier
2016-05-04 18:12 ` [Qemu-devel] [PATCH 0/3] muldiv64() trivial fixes Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).