[Top][All Lists]

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH v5 01/46] include: Add IEC binary

From: Eric Blake
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v5 01/46] include: Add IEC binary prefixes in "qemu/units.h"
Date: Wed, 27 Jun 2018 07:26:27 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 06/27/2018 06:27 AM, Igor Mammedov wrote:
On Mon, 25 Jun 2018 09:41:53 -0300
Philippe Mathieu-Daudé <address@hidden> wrote:

Loosely based on 076b35b5a56.

Suggested-by: Stefan Weil <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>

+#ifndef QEMU_UNITS_H
+#define QEMU_UNITS_H
+#define KiB     (INT64_C(1) << 10)
+#define MiB     (INT64_C(1) << 20)
+#define GiB     (INT64_C(1) << 30)
+#define TiB     (INT64_C(1) << 40)
+#define PiB     (INT64_C(1) << 50)
+#define EiB     (INT64_C(1) << 60)
Shouldn't above use UINT64_C()

Since the decision of signed vs. unsigned was intentional based on review on earlier versions, it may be worth a comment in this file that these constants are intentionally signed (in usage patterns, these tend to be multiplied by another value; and while it is easy to go to unsigned by doing '1U * KiB', you can't go in the opposite direction if you want a signed number for '1 * KiB' unless KiB is signed).

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

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