qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Luis Pires <luis.pires@eldorado.org.br>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	richard.henderson@linaro.org, qemu-devel@nongnu.org,
	groug@kaod.org, qemu-ppc@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 02/19] host-utils: move abs64() to host-utils
Date: Wed, 25 Aug 2021 13:43:10 +1000	[thread overview]
Message-ID: <YSW8TigYwJVIrd5w@yekko> (raw)
In-Reply-To: <20210824142730.102421-3-luis.pires@eldorado.org.br>

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

On Tue, Aug 24, 2021 at 11:27:13AM -0300, Luis Pires wrote:
> Move abs64 to host-utils so it can be reused elsewhere.
> Also made it inline.
> 
> Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
> ---
>  hw/i386/kvm/i8254.c       | 5 -----
>  include/qemu/host-utils.h | 8 ++++++++
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
> index fa68669e8a..761034743b 100644
> --- a/hw/i386/kvm/i8254.c
> +++ b/hw/i386/kvm/i8254.c
> @@ -59,11 +59,6 @@ struct KVMPITClass {
>      DeviceRealize parent_realize;
>  };
>  
> -static int64_t abs64(int64_t v)
> -{
> -    return v < 0 ? -v : v;

Hrm..  I'm a bit concerned about mkaing this a more widespread
function, because it has a nasty edge case... which is basically
unavoidable in an abs64() implementation.  Specifically:

abs64(0x800_0000_0000_00000) == 0x800_0000_0000_0000 < 0

At least in the most likely 2's complement implementation.

> -}
> -
>  static void kvm_pit_update_clock_offset(KVMPITState *s)
>  {
>      int64_t offset, clock_offset;
> diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
> index 711b221704..5fec44a9c4 100644
> --- a/include/qemu/host-utils.h
> +++ b/include/qemu/host-utils.h
> @@ -357,6 +357,14 @@ static inline uint64_t revbit64(uint64_t x)
>  #endif
>  }
>  
> +/**
> + * Return the absolute value of a 64-bit integer
> + */
> +static inline int64_t abs64(int64_t v)
> +{
> +    return v < 0 ? -v : v;
> +}
> +
>  /**
>   * sadd32_overflow - addition with overflow indication
>   * @x, @y: addends

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-08-25  4:15 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 14:27 [PATCH 00/19] target/ppc: DFP instructions using decodetree Luis Pires
2021-08-24 14:27 ` [PATCH 01/19] host-utils: Fix overflow detection in divu128() Luis Pires
2021-08-24 14:27 ` [PATCH 02/19] host-utils: move abs64() to host-utils Luis Pires
2021-08-25  3:43   ` David Gibson [this message]
2021-08-25 12:48     ` Luis Fernando Fujita Pires
2021-08-25 20:26       ` Eduardo Habkost
2021-08-25 20:37         ` Luis Fernando Fujita Pires
2021-08-25 21:18           ` Eduardo Habkost
2021-08-25 21:27             ` Philippe Mathieu-Daudé
2021-08-27 14:28               ` Luis Fernando Fujita Pires
2021-08-24 14:27 ` [PATCH 03/19] host-utils: move checks out of divu128/divs128 Luis Pires
2021-08-24 14:27 ` [PATCH 04/19] host-utils: add 128-bit quotient support to divu128/divs128 Luis Pires
2021-08-24 14:27 ` [PATCH 05/19] host-utils: add unit tests for divu128/divs128 Luis Pires
2021-08-24 14:27 ` [PATCH 06/19] libdecnumber: introduce decNumberFrom[U]Int128 Luis Pires
2021-08-24 14:27 ` [PATCH 07/19] target/ppc: Move REQUIRE_ALTIVEC/VECTOR to translate.c Luis Pires
2021-08-25  3:46   ` David Gibson
2021-08-24 14:27 ` [PATCH 08/19] target/ppc: Introduce REQUIRE_FPU Luis Pires
2021-08-25  3:46   ` David Gibson
2021-08-24 14:27 ` [PATCH 09/19] target/ppc: Implement DCFFIXQQ Luis Pires
2021-08-24 14:27 ` [PATCH 10/19] host-utils: Introduce mulu128 Luis Pires
2021-08-24 14:27 ` [PATCH 11/19] libdecnumber: Introduce decNumberIntegralToInt128 Luis Pires
2021-08-24 14:27 ` [PATCH 12/19] target/ppc: Implement DCTFIXQQ Luis Pires
2021-08-24 14:27 ` [PATCH 13/19] target/ppc: Move dtstdc[q]/dtstdg[q] to decodetree Luis Pires
2021-08-25 13:15   ` Philippe Mathieu-Daudé
2021-08-24 14:27 ` [PATCH 14/19] target/ppc: Move d{add, sub, mul, div, iex}[q] " Luis Pires
2021-08-25 13:16   ` Philippe Mathieu-Daudé
2021-08-24 14:27 ` [PATCH 15/19] target/ppc: Move dcmp{u, o}[q], dts{tex, tsf, tsfi}[q] " Luis Pires
2021-08-24 14:27 ` [PATCH 16/19] target/ppc: Move dquai[q], drint{x,n}[q] " Luis Pires
2021-08-25 13:18   ` Philippe Mathieu-Daudé
2021-08-24 14:27 ` [PATCH 17/19] target/ppc: Move dqua[q], drrnd[q] " Luis Pires
2021-08-25 13:18   ` Philippe Mathieu-Daudé
2021-08-24 14:27 ` [PATCH 18/19] target/ppc: Move dct{dp, qpq}, dr{sp, dpq}, dc{f, t}fix[q], dxex[q] " Luis Pires
2021-08-25 13:19   ` Philippe Mathieu-Daudé
2021-08-24 14:27 ` [PATCH 19/19] target/ppc: Move ddedpd[q], denbcd[q], dscli[q], dscri[q] " Luis Pires
2021-08-25 13:20   ` Philippe Mathieu-Daudé

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=YSW8TigYwJVIrd5w@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=groug@kaod.org \
    --cc=luis.pires@eldorado.org.br \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.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 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).