diff options
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch')
-rw-r--r-- | meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch new file mode 100644 index 000000000..fee1cbcf9 --- /dev/null +++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch | |||
@@ -0,0 +1,84 @@ | |||
1 | From e56767b9caa02e7c41803499c77dc939d5a7f64a Mon Sep 17 00:00:00 2001 | ||
2 | From: Thorsten Glaser <tg@mirbsd.org> | ||
3 | Date: Fri, 20 Jun 2014 10:56:27 +0000 | ||
4 | Subject: [PATCH 4/6] Restore compatibility to dietlibc, klibc, musl libc after commit 4f1b108 | ||
5 | |||
6 | Each C library has their own way to define off_t, and the <features.h> | ||
7 | header is nonstandard and specific to the GNU libc and those that clone | ||
8 | it (uClibc). Fefe’s dietlibc uses different flags, and klibc always uses | ||
9 | a 64-bit off_t (like the BSDs); musl libc cannot be recognised using cpp | ||
10 | instructions, so we assume 64 bit there (and on unknown C libraries) and | ||
11 | leave it to the user to submit a follow-up fix if we guess wrong. I also | ||
12 | added a static assertion to verify the 64 bit guess is correct. | ||
13 | |||
14 | It would be really better using a configure script for this instead. | ||
15 | |||
16 | Fixes: | ||
17 | | CC lib/libmtd.o | ||
18 | | In file included from ubi-utils/ubiutils-common.c:35:0: | ||
19 | | ./include/common.h:29:22: fatal error: features.h: No such file or directory | ||
20 | | #include <features.h> | ||
21 | | ^ | ||
22 | | compilation terminated. | ||
23 | |||
24 | Upstream-Status: Pending | ||
25 | |||
26 | Signed-off-by: Thorsten Glaser <tg@mirbsd.org> | ||
27 | Signed-off-by: Andrea Adami <andrea.adami@gmail.com> | ||
28 | --- | ||
29 | include/common.h | 24 ++++++++++++++++++++++++ | ||
30 | 1 file changed, 24 insertions(+) | ||
31 | |||
32 | diff --git a/include/common.h b/include/common.h | ||
33 | index 6895e5c..77f3f7d 100644 | ||
34 | --- a/include/common.h | ||
35 | +++ b/include/common.h | ||
36 | @@ -26,7 +26,9 @@ | ||
37 | #include <string.h> | ||
38 | #include <fcntl.h> | ||
39 | #include <errno.h> | ||
40 | +#if defined(__GLIBC__) || defined(__UCLIBC__) | ||
41 | #include <features.h> | ||
42 | +#endif | ||
43 | #include <inttypes.h> | ||
44 | #include "version.h" | ||
45 | |||
46 | @@ -52,6 +54,21 @@ extern "C" { | ||
47 | #endif | ||
48 | |||
49 | /* define a print format specifier for off_t */ | ||
50 | +#if defined(__KLIBC__) | ||
51 | +/* always 64 bit on klibc */ | ||
52 | +#define PRIxoff_t PRIx64 | ||
53 | +#define PRIdoff_t PRId64 | ||
54 | +#elif defined(__dietlibc__) | ||
55 | +/* depends on compiler flags on dietlibc */ | ||
56 | +#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) | ||
57 | +#define PRIxoff_t PRIx64 | ||
58 | +#define PRIdoff_t PRId64 | ||
59 | +#else | ||
60 | +#define PRIxoff_t "l"PRIx32 | ||
61 | +#define PRIdoff_t "l"PRId32 | ||
62 | +#endif | ||
63 | +#elif defined(__GLIBC__) || defined(__UCLIBC__) | ||
64 | +/* depends on compiler flags on glibc and uClibc */ | ||
65 | #ifdef __USE_FILE_OFFSET64 | ||
66 | #define PRIxoff_t PRIx64 | ||
67 | #define PRIdoff_t PRId64 | ||
68 | @@ -59,6 +76,13 @@ extern "C" { | ||
69 | #define PRIxoff_t "l"PRIx32 | ||
70 | #define PRIdoff_t "l"PRId32 | ||
71 | #endif | ||
72 | +#else | ||
73 | +/* unknown libc or musl */ | ||
74 | +#define PRIxoff_t PRIx64 | ||
75 | +#define PRIdoff_t PRId64 | ||
76 | +/* verify our guess of 64 bit is correct */ | ||
77 | +static char __PRIxoff_t_static_assert[sizeof(off_t) == 8 ? 1 : -1]; | ||
78 | +#endif | ||
79 | |||
80 | /* Verbose messages */ | ||
81 | #define bareverbose(verbose, fmt, ...) do { \ | ||
82 | -- | ||
83 | 1.9.1 | ||
84 | |||