diff mbox series

[v4,01/40] include: Add IEC binary prefixes in "qemu/units.h"

Message ID 20180611011501.10235-2-f4bug@amsat.org
State New
Headers show
Series Use the IEC binary prefix definitions | expand

Commit Message

Philippe Mathieu-Daudé June 11, 2018, 1:14 a.m. UTC
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

Comments

Richard Henderson June 12, 2018, 8:42 p.m. UTC | #1
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~
diff mbox series

Patch

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