[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 02/19] host-utils: move abs64() to host-utils
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH 02/19] host-utils: move abs64() to host-utils |
Date: |
Wed, 25 Aug 2021 16:26:38 -0400 |
On Wed, Aug 25, 2021 at 12:48:35PM +0000, Luis Fernando Fujita Pires wrote:
> From: David Gibson <david@gibson.dropbear.id.au>
> > 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.
>
> Right, that's true of any standard implementation of abs().
> I thought about making it return uint64_t, but that could make
> it weird for other uses of abs64(), where callers wouldn't
> expect a type change from int64_t to uint64_t. Maybe create a
> separate uabs64() that returns uint64_t? Or is that even
> weirder? :)
Which users of abs64 would expect it to return int64_t?
kvm_pit_update_clock_offset() doesn't seem to.
--
Eduardo
- [PATCH 00/19] target/ppc: DFP instructions using decodetree, Luis Pires, 2021/08/24
- [PATCH 01/19] host-utils: Fix overflow detection in divu128(), Luis Pires, 2021/08/24
- [PATCH 02/19] host-utils: move abs64() to host-utils, Luis Pires, 2021/08/24
- Re: [PATCH 02/19] host-utils: move abs64() to host-utils, David Gibson, 2021/08/25
- RE: [PATCH 02/19] host-utils: move abs64() to host-utils, Luis Fernando Fujita Pires, 2021/08/25
- Re: [PATCH 02/19] host-utils: move abs64() to host-utils,
Eduardo Habkost <=
- RE: [PATCH 02/19] host-utils: move abs64() to host-utils, Luis Fernando Fujita Pires, 2021/08/25
- Re: [PATCH 02/19] host-utils: move abs64() to host-utils, Eduardo Habkost, 2021/08/25
- Re: [PATCH 02/19] host-utils: move abs64() to host-utils, Philippe Mathieu-Daudé, 2021/08/25
- RE: [PATCH 02/19] host-utils: move abs64() to host-utils, Luis Fernando Fujita Pires, 2021/08/27
[PATCH 03/19] host-utils: move checks out of divu128/divs128, Luis Pires, 2021/08/24
[PATCH 04/19] host-utils: add 128-bit quotient support to divu128/divs128, Luis Pires, 2021/08/24
[PATCH 05/19] host-utils: add unit tests for divu128/divs128, Luis Pires, 2021/08/24
[PATCH 06/19] libdecnumber: introduce decNumberFrom[U]Int128, Luis Pires, 2021/08/24
[PATCH 07/19] target/ppc: Move REQUIRE_ALTIVEC/VECTOR to translate.c, Luis Pires, 2021/08/24