diff mbox series

[03/16] target/mips/cp0_timer: Explicit unit in variable name

Message ID 20200928171539.788309-4-f4bug@amsat.org
State Superseded
Headers show
Series hw/mips: Set CPU frequency | expand

Commit Message

Philippe Mathieu-Daudé Sept. 28, 2020, 5:15 p.m. UTC
Name variables holding nanoseconds with the '_ns' suffix.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/mips/cp0_timer.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Aleksandar Markovic Sept. 30, 2020, 6:10 p.m. UTC | #1
On Monday, September 28, 2020, Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> Name variables holding nanoseconds with the '_ns' suffix.

>

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---



Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>



>  target/mips/cp0_timer.c | 19 ++++++++++---------

>  1 file changed, 10 insertions(+), 9 deletions(-)

>

> diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c

> index 9c38e9da1c8..5194c967ae3 100644

> --- a/target/mips/cp0_timer.c

> +++ b/target/mips/cp0_timer.c

> @@ -32,13 +32,14 @@

>  /* MIPS R4K timer */

>  static void cpu_mips_timer_update(CPUMIPSState *env)

>  {

> -    uint64_t now, next;

> +    uint64_t now_ns, next_ns;

>      uint32_t wait;

>

> -    now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

> -    wait = env->CP0_Compare - env->CP0_Count - (uint32_t)(now /

> TIMER_PERIOD);

> -    next = now + (uint64_t)wait * TIMER_PERIOD;

> -    timer_mod(env->timer, next);

> +    now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

> +    wait = env->CP0_Compare - env->CP0_Count -

> +           (uint32_t)(now_ns / TIMER_PERIOD);

> +    next_ns = now_ns + (uint64_t)wait * TIMER_PERIOD;

> +    timer_mod(env->timer, next_ns);

>  }

>

>  /* Expire the timer.  */

> @@ -56,16 +57,16 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env)

>      if (env->CP0_Cause & (1 << CP0Ca_DC)) {

>          return env->CP0_Count;

>      } else {

> -        uint64_t now;

> +        uint64_t now_ns;

>

> -        now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

> +        now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

>          if (timer_pending(env->timer)

> -            && timer_expired(env->timer, now)) {

> +            && timer_expired(env->timer, now_ns)) {

>              /* The timer has already expired.  */

>              cpu_mips_timer_expire(env);

>          }

>

> -        return env->CP0_Count + (uint32_t)(now / TIMER_PERIOD);

> +        return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD);

>      }

>  }

>

> --

> 2.26.2

>

>
<br><br>On Monday, September 28, 2020, Philippe Mathieu-Daudé &lt;<a href="mailto:f4bug@amsat.org">f4bug@amsat.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Name variables holding nanoseconds with the &#39;_ns&#39; suffix.<br>
<br>
Signed-off-by: Philippe Mathieu-Daudé &lt;<a href="mailto:f4bug@amsat.org">f4bug@amsat.org</a>&gt;<br>

---</blockquote><div><br></div><div><span style="color:rgb(34,34,34);font-size:14px;line-height:22.1200008392334px">Reviewed-by: Aleksandar Markovic &lt;</span><a href="mailto:aleksandar.qemu.devel@gmail.com" target="_blank" style="font-size:14px;line-height:22.1200008392334px">aleksandar.qemu.devel@gmail.c<wbr>om</a><span style="color:rgb(34,34,34);font-size:14px;line-height:22.1200008392334px">&gt;</span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 target/mips/cp0_timer.c | 19 ++++++++++---------<br>
 1 file changed, 10 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c<br>
index 9c38e9da1c8..5194c967ae3 100644<br>
--- a/target/mips/cp0_timer.c<br>
+++ b/target/mips/cp0_timer.c<br>
@@ -32,13 +32,14 @@<br>
 /* MIPS R4K timer */<br>
 static void cpu_mips_timer_update(<wbr>CPUMIPSState *env)<br>
 {<br>
-    uint64_t now, next;<br>
+    uint64_t now_ns, next_ns;<br>
     uint32_t wait;<br>
<br>
-    now = qemu_clock_get_ns(QEMU_CLOCK_<wbr>VIRTUAL);<br>
-    wait = env-&gt;CP0_Compare - env-&gt;CP0_Count - (uint32_t)(now / TIMER_PERIOD);<br>
-    next = now + (uint64_t)wait * TIMER_PERIOD;<br>
-    timer_mod(env-&gt;timer, next);<br>
+    now_ns = qemu_clock_get_ns(QEMU_CLOCK_<wbr>VIRTUAL);<br>
+    wait = env-&gt;CP0_Compare - env-&gt;CP0_Count -<br>
+           (uint32_t)(now_ns / TIMER_PERIOD);<br>
+    next_ns = now_ns + (uint64_t)wait * TIMER_PERIOD;<br>
+    timer_mod(env-&gt;timer, next_ns);<br>
 }<br>
<br>
 /* Expire the timer.  */<br>
@@ -56,16 +57,16 @@ uint32_t cpu_mips_get_count(<wbr>CPUMIPSState *env)<br>
     if (env-&gt;CP0_Cause &amp; (1 &lt;&lt; CP0Ca_DC)) {<br>
         return env-&gt;CP0_Count;<br>
     } else {<br>
-        uint64_t now;<br>
+        uint64_t now_ns;<br>
<br>
-        now = qemu_clock_get_ns(QEMU_CLOCK_<wbr>VIRTUAL);<br>
+        now_ns = qemu_clock_get_ns(QEMU_CLOCK_<wbr>VIRTUAL);<br>
         if (timer_pending(env-&gt;timer)<br>
-            &amp;&amp; timer_expired(env-&gt;timer, now)) {<br>
+            &amp;&amp; timer_expired(env-&gt;timer, now_ns)) {<br>
             /* The timer has already expired.  */<br>
             cpu_mips_timer_expire(env);<br>
         }<br>
<br>
-        return env-&gt;CP0_Count + (uint32_t)(now / TIMER_PERIOD);<br>
+        return env-&gt;CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD);<br>
     }<br>
 }<br>
 <br>
-- <br>
2.26.2<br>
<br>
</blockquote>
diff mbox series

Patch

diff --git a/target/mips/cp0_timer.c b/target/mips/cp0_timer.c
index 9c38e9da1c8..5194c967ae3 100644
--- a/target/mips/cp0_timer.c
+++ b/target/mips/cp0_timer.c
@@ -32,13 +32,14 @@ 
 /* MIPS R4K timer */
 static void cpu_mips_timer_update(CPUMIPSState *env)
 {
-    uint64_t now, next;
+    uint64_t now_ns, next_ns;
     uint32_t wait;
 
-    now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
-    wait = env->CP0_Compare - env->CP0_Count - (uint32_t)(now / TIMER_PERIOD);
-    next = now + (uint64_t)wait * TIMER_PERIOD;
-    timer_mod(env->timer, next);
+    now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+    wait = env->CP0_Compare - env->CP0_Count -
+           (uint32_t)(now_ns / TIMER_PERIOD);
+    next_ns = now_ns + (uint64_t)wait * TIMER_PERIOD;
+    timer_mod(env->timer, next_ns);
 }
 
 /* Expire the timer.  */
@@ -56,16 +57,16 @@  uint32_t cpu_mips_get_count(CPUMIPSState *env)
     if (env->CP0_Cause & (1 << CP0Ca_DC)) {
         return env->CP0_Count;
     } else {
-        uint64_t now;
+        uint64_t now_ns;
 
-        now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+        now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
         if (timer_pending(env->timer)
-            && timer_expired(env->timer, now)) {
+            && timer_expired(env->timer, now_ns)) {
             /* The timer has already expired.  */
             cpu_mips_timer_expire(env);
         }
 
-        return env->CP0_Count + (uint32_t)(now / TIMER_PERIOD);
+        return env->CP0_Count + (uint32_t)(now_ns / TIMER_PERIOD);
     }
 }