diff mbox

[1/3] include/common.h: fix build against musl

Message ID 1429827173-1739-1-git-send-email-joerg.krause@embedded.rocks
State Accepted
Commit bd9ed192b5d6ee7afc49bfd383a23b50792de8c2
Headers show

Commit Message

Jörg Krause April 23, 2015, 10:12 p.m. UTC
Like uClibc version older than (not yet released) 0.9.34 musl does not have
a rpmatch() implementation.

uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its
version and then for a non glibc implementation (like musl). Note, musl does
not define __MUSL__.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
 include/common.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Brian Norris May 28, 2015, 11:43 p.m. UTC | #1
On Fri, Apr 24, 2015 at 12:12:51AM +0200, Jörg Krause wrote:
> Like uClibc version older than (not yet released) 0.9.34 musl does not have
> a rpmatch() implementation.
> 
> uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its
> version and then for a non glibc implementation (like musl). Note, musl does
> not define __MUSL__.
> 
> Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>

Applied this one to mtd-utils.git. Thanks!
diff mbox

Patch

diff --git a/include/common.h b/include/common.h
index 9b8804a..fb0ca83 100644
--- a/include/common.h
+++ b/include/common.h
@@ -117,11 +117,12 @@  extern "C" {
 	fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \
 } while(0)
 
-#if defined(__UCLIBC__)
-/* uClibc versions before 0.9.34 don't have rpmatch() */
-#if __UCLIBC_MAJOR__ == 0 && \
+/* uClibc versions before 0.9.34 and musl don't have rpmatch() */
+#if defined(__UCLIBC__) && \
+		(__UCLIBC_MAJOR__ == 0 && \
 		(__UCLIBC_MINOR__ < 9 || \
-		(__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 34))
+		(__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 34))) || \
+	!defined(__GLIBC__)
 #undef rpmatch
 #define rpmatch __rpmatch
 static inline int __rpmatch(const char *resp)
@@ -130,7 +131,6 @@  static inline int __rpmatch(const char *resp)
 	(resp[0] == 'n' || resp[0] == 'N') ? 0 : -1;
 }
 #endif
-#endif
 
 /**
  * prompt the user for confirmation