diff options
author | Andrea Adami <andrea.adami@gmail.com> | 2018-01-29 00:05:07 +0100 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2018-02-11 11:50:56 -0800 |
commit | edbe41f53ec15eeae4673498c41a1f3a42ac813b (patch) | |
tree | d27d63b3249b2d4ebfee8ad5e837466d256e7ac2 /meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch | |
parent | 75356b6a76e965f6e282e8219e88afc1ab4f3240 (diff) | |
download | meta-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.patch | 64 |
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 @@ | |||
1 | From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrea Adami <andrea.adami@gmail.com> | ||
3 | Date: Sun, 28 Jan 2018 21:47:59 +0100 | ||
4 | Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic | ||
5 | |||
6 | We use floating point just to print out KiB, MiB, GiB. | ||
7 | Avoid that to be klibc friendly. | ||
8 | |||
9 | Fixes compilation for aarch64 against klibc: | ||
10 | |||
11 | error: '-mgeneral-regs-only' is incompatible with floating-point argument | ||
12 | | printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024)); | ||
13 | etc. | ||
14 | |||
15 | Note: | ||
16 | * In the KiB case, we could apparently multiply by 100 before dividing | ||
17 | without risking overflow. This code simply avoids multiplications. | ||
18 | |||
19 | Upstream-Status: Submitted | ||
20 | |||
21 | Signed-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 | |||
26 | diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c | ||
27 | index 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 | -- | ||
63 | 2.7.4 | ||
64 | |||