summaryrefslogtreecommitdiffstats
path: root/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2018-01-29 00:05:07 +0100
committerArmin Kuster <akuster808@gmail.com>2018-02-11 11:50:56 -0800
commitedbe41f53ec15eeae4673498c41a1f3a42ac813b (patch)
treed27d63b3249b2d4ebfee8ad5e837466d256e7ac2 /meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
parent75356b6a76e965f6e282e8219e88afc1ab4f3240 (diff)
downloadmeta-openembedded-edbe41f53ec15eeae4673498c41a1f3a42ac813b.tar.gz
ubi-utils-klibc_1.5.2: fix build for qemuarm
Building the recipe with TUNE_FEATURES = "aarch64" and TARGET_FPU = "" fails. See patch headers for more details. Patch sent upstream for master, here rebased for 1.5.2. Tested runtime on armv5. While there backport one more patch fixing warnings in libmtd.c and move the patches in their specific dir, preparing for v2.0.1. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
new file mode 100644
index 0000000000..36b012f901
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
@@ -0,0 +1,64 @@
1From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 28 Jan 2018 21:47:59 +0100
4Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic
5
6We use floating point just to print out KiB, MiB, GiB.
7Avoid that to be klibc friendly.
8
9Fixes compilation for aarch64 against klibc:
10
11error: '-mgeneral-regs-only' is incompatible with floating-point argument
12| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
13etc.
14
15Note:
16* In the KiB case, we could apparently multiply by 100 before dividing
17 without risking overflow. This code simply avoids multiplications.
18
19Upstream-Status: Submitted
20
21Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
22---
23 ubi-utils/ubiutils-common.c | 18 ++++++++++++------
24 1 file changed, 12 insertions(+), 6 deletions(-)
25
26diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c
27index 6609a6b..0ded2a4 100644
28--- a/ubi-utils/ubiutils-common.c
29+++ b/ubi-utils/ubiutils-common.c
30@@ -107,6 +107,9 @@ long long ubiutils_get_bytes(const char *str)
31 void ubiutils_print_bytes(long long bytes, int bracket)
32 {
33 const char *p;
34+ int GiB = 1024 * 1024 * 1024;
35+ int MiB = 1024 * 1024;
36+ int KiB = 1024;
37
38 if (bracket)
39 p = " (";
40@@ -115,12 +118,15 @@ void ubiutils_print_bytes(long long bytes, int bracket)
41
42 printf("%lld bytes", bytes);
43
44- if (bytes > 1024 * 1024 * 1024)
45- printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
46- else if (bytes > 1024 * 1024)
47- printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024));
48- else if (bytes > 1024 && bytes != 0)
49- printf("%s%.1f KiB", p, (double)bytes / 1024);
50+ if (bytes > GiB)
51+ printf("%s%lld.%lld GiB", p,
52+ bytes / GiB, bytes % GiB / (GiB / 10));
53+ else if (bytes > MiB)
54+ printf("%s%lld.%lld MiB", p,
55+ bytes / MiB, bytes % MiB / (MiB / 10));
56+ else if (bytes > KiB && bytes != 0)
57+ printf("%s%lld.%lld KiB", p,
58+ bytes / KiB, bytes % KiB / (KiB / 10));
59 else
60 return;
61
62--
632.7.4
64