[Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h"

Philippe Mathieu-Daudé posted 40 patches 7 years, 8 months ago
Only 38 patches received!
There is a newer version of this series
[Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h"
Posted by Philippe Mathieu-Daudé 7 years, 8 months ago
Loosely based on 076b35b5a56.

Suggested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
I suppose the following warning is irrelevant:

  WARNING: 1 added file, does MAINTAINERS need updating

 include/qemu/units.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 include/qemu/units.h

diff --git a/include/qemu/units.h b/include/qemu/units.h
new file mode 100644
index 0000000000..e3a39ed59e
--- /dev/null
+++ b/include/qemu/units.h
@@ -0,0 +1,20 @@
+/*
+ * IEC binary prefixes definitions
+ *
+ * Copyright (C) 2015 Nikunj A Dadhania, IBM Corporation
+ * Copyright (C) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef QEMU_UNITS_H
+#define QEMU_UNITS_H
+
+#define KiB     (1ULL << 10)
+#define MiB     (1ULL << 20)
+#define GiB     (1ULL << 30)
+#define TiB     (1ULL << 40)
+#define PiB     (1ULL << 50)
+#define EiB     (1ULL << 60)
+
+#endif
-- 
2.17.1


Re: [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h"
Posted by Richard Henderson 7 years, 8 months ago
On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
> +#define KiB     (1ULL << 10)
> +#define MiB     (1ULL << 20)
> +#define GiB     (1ULL << 30)
> +#define TiB     (1ULL << 40)
> +#define PiB     (1ULL << 50)
> +#define EiB     (1ULL << 60)

Is there any particular reason to force these to be unsigned?
Or, for that matter, 64-bit (at least for the first 3).

I ask because this changes the types of some of the expressions
in which you use these.


r~