qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH 02/19] host-utils: move abs64() to host-utils


From: Luis Fernando Fujita Pires
Subject: RE: [PATCH 02/19] host-utils: move abs64() to host-utils
Date: Wed, 25 Aug 2021 12:48:35 +0000

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? :)

--
Luis Pires
Instituto de Pesquisas ELDORADO
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]