[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] ui/gtk: don't try to redefine SI prefixes
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 1/3] ui/gtk: don't try to redefine SI prefixes |
Date: |
Thu, 14 Jan 2021 12:11:52 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
On 12/13/20 5:57 PM, Volker Rümelin wrote:
> Redefining SI prefixes is always wrong. 1s has per definition
> 1000ms. Remove the misnamed named constant and replace it with
> a comment explaining the frequency to period conversion in two
> simple steps. Now you can cancel out the unit mHz in the comment
> with the implicit unit mHz in refresh_rate_millihz and see why
> the implicit unit ms for update_interval remains.
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
> include/ui/gtk.h | 2 --
> ui/gtk.c | 3 ++-
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/ui/gtk.h b/include/ui/gtk.h
> index eaeb450f91..80851fb4c7 100644
> --- a/include/ui/gtk.h
> +++ b/include/ui/gtk.h
> @@ -24,8 +24,6 @@
> #include "ui/egl-context.h"
> #endif
>
> -#define MILLISEC_PER_SEC 1000000
Indeed this is MICROSEC_PER_SEC.
> -
> typedef struct GtkDisplayState GtkDisplayState;
>
> typedef struct VirtualGfxConsole {
> diff --git a/ui/gtk.c b/ui/gtk.c
> index a752aa22be..86b386a20d 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -798,7 +798,8 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t
> *cr, void *opaque)
> refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ?
> vc->window : s->window);
> if (refresh_rate_millihz) {
> - vc->gfx.dcl.update_interval = MILLISEC_PER_SEC /
> refresh_rate_millihz;
> + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */
> + vc->gfx.dcl.update_interval = 1000 * 1000 / refresh_rate_millihz;
> }
>
> fbw = surface_width(vc->gfx.ds);
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH 1/3] ui/gtk: don't try to redefine SI prefixes,
Philippe Mathieu-Daudé <=