1From acbaee34bcb1881db97969dd2c411446f32ca4cc Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Sat, 25 Oct 2014 19:45:33 +0200
4Subject: [PATCH 3/5] Fix debug mode build with uClibc
5
6When --enable-debug is passed, liblog4c-localtime wants to use
7<mcheck.h>. It takes the precaution of testing if __GLIBC__ is
8defined. But unfortunately, the uClibc C library pretends to be
9compatible with glibc by defining __GLIBC__, but it doesn't provide
10mcheck.h.
11
12To better support this situation, we add an AC_CHECK_HEADERS() check
13on mcheck.h, and then use HAVE_MCHECK_H were appropriate.
14
15Submitted upstream: https://github.com/rcmadruga/log4c-localtime/pull/1
16
17Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
18---
19 configure.in     | 2 +-
20 src/log4c/init.c | 6 +++---
21 2 files changed, 4 insertions(+), 4 deletions(-)
22
23diff --git a/configure.in b/configure.in
24index 612ccbe..dbf11e9 100644
25--- a/configure.in
26+++ b/configure.in
27@@ -115,7 +115,7 @@ AM_CONDITIONAL(TEST, test x$enable_test = xyes)
28 AC_HEADER_STDC
29 AC_CHECK_HEADERS([fcntl.h inttypes.h langinfo.h limits.h stddef.h stdint.h \
30 stdlib.h string.h sys/time.h syslog.h unistd.h stdarg.h varargs.h getopt.h \
31-pthread.h])
32+pthread.h mcheck.h])
33
34 # Checks for typedefs, structures, and compiler characteristics.
35 AC_C_CONST
36diff --git a/src/log4c/init.c b/src/log4c/init.c
37index 7dd9eb4..4b88210 100644
38--- a/src/log4c/init.c
39+++ b/src/log4c/init.c
40@@ -35,7 +35,7 @@ static const char version[] = "$Id$";
41 #include <layout_type_basic_r.h>
42 #include <layout_type_dated_r.h>
43
44-#if defined(__LOG4C_DEBUG__) && defined(__GLIBC__)
45+#if defined(__LOG4C_DEBUG__) && defined(HAVE_MCHECK_H)
46 #include <mcheck.h>
47 #endif
48
49@@ -100,7 +100,7 @@ extern int log4c_init(void)
50     sd_debug("log4c_init[");
51
52     /* activate GLIBC allocation debugging */
53-#if defined(__LOG4C_DEBUG__) && defined(__GLIBC__)
54+#if defined(__LOG4C_DEBUG__) && defined(HAVE_MCHECK_H)
55     mtrace();
56 #endif
57
58@@ -280,7 +280,7 @@ extern int log4c_fini(void)
59 	log4c_dump_all_instances(stderr);
60     }
61 #endif
62-#if defined(__LOG4C_DEBUG__) && defined(__GLIBC__)
63+#if defined(__LOG4C_DEBUG__) && defined(HAVE_MCHECK_H)
64     muntrace();
65 #endif
66
67--
682.0.0
69
70