fa2e7096565de66b19fe333b4195105b94d2bf01
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / mtd / 0001-Fix-rpmatch-call-under-uClibc-and-musl.patch
1 From b56296212c27071f06d98cdad6b32b7db583adb0 Mon Sep 17 00:00:00 2001
2 From: Baruch Siach <baruch@tkos.co.il>
3 Date: Sun, 13 Apr 2014 15:26:46 +0300
4 Subject: [PATCH 1/1] Fix rpmatch() call under uClibc and musl
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The current uClibc 0.9.33 and the musl C library do not implement rpmatch().
10
11 Combine two upstream uClibc patches (commit 50c9e11f7e and
12 5923077649) and a musl patch sent to the mailing list
13 (http://patchwork.ozlabs.org/patch/464074/).
14
15 include/common.h: fix build against current uClibc
16
17 Commit dbe0fd17f2 (mtd-utils: new prompt() helper for talking to the user)
18 introduced a rpmatch() call. However, uClibc versions older than (not yet
19 released) 0.9.34 don't have rpmatch() implementation. Add one.
20
21 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
22 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
23 Acked-by: Mike Frysinger <vapier@gentoo.org>
24
25 include/common.h: fix build against recent 0.9.33 uClibc
26
27 An implementation of rpmatch() was backported to the 0.9.33 branch of uClibc.
28 So the uClibc version check introduced in commit 50c9e11f7e (include/common.h:
29 fix build against current uClibc) is not enough. Rename the local rpmatch()
30 implementation to avoid collision.
31
32 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
33 Acked-by: Mike Frysinger <vapier@gentoo.org>
34 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
35
36 include/common.h: fix build against musl
37
38 Like uClibc version older than (not yet released) 0.9.34 musl does not have
39 a rpmatch() implementation.
40
41 uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its
42 version and then for a non glibc implementation (like musl). Note, musl does
43 not define __MUSL__.
44
45 Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
46 ---
47  include/common.h | 15 +++++++++++++++
48  1 file changed, 15 insertions(+)
49
50 diff --git a/include/common.h b/include/common.h
51 index 4ffccea..944c712 100644
52 --- a/include/common.h
53 +++ b/include/common.h
54 @@ -102,6 +102,21 @@ extern "C" {
55         fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \
56  } while(0)
57  
58 +/* uClibc versions before 0.9.34 and musl don't have rpmatch() */
59 +#if defined(__UCLIBC__) && \
60 +               (__UCLIBC_MAJOR__ == 0 && \
61 +               (__UCLIBC_MINOR__ < 9 || \
62 +               (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 34))) || \
63 +       !defined(__GLIBC__)
64 +#undef rpmatch
65 +#define rpmatch __rpmatch
66 +static inline int __rpmatch(const char *resp)
67 +{
68 +    return (resp[0] == 'y' || resp[0] == 'Y') ? 1 :
69 +       (resp[0] == 'n' || resp[0] == 'N') ? 0 : -1;
70 +}
71 +#endif
72 +
73  /**
74   * prompt the user for confirmation
75   */
76 -- 
77 2.3.6
78