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