summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-01-18 15:52:53 +0000
committerHavoc Pennington <hp@redhat.com>2003-01-18 15:52:53 +0000
commit6ac750b03fb32591769d0a6ece8840932622fead (patch)
tree6a40a2ebbfb488b4c09dd9bd13a1137f6b09811b
parent650c2745b8e1065b957779e26413a5040fd97f30 (diff)
2003-01-18 Havoc Pennington <hp@pobox.com>
Building --disable-verbose-mode --disable-asserts --disable-tests cuts the library from 112K to 45K or so * configure.in: check for varargs macro support, add --enable-verbose-mode, --enable-asserts. * dbus/dbus-internals.h (_dbus_assert): support DBUS_DISABLE_ASSERT (_dbus_verbose): support DBUS_ENABLE_VERBOSE_MODE
-rw-r--r--ChangeLog12
-rw-r--r--configure.in47
-rw-r--r--dbus/dbus-internals.c6
-rw-r--r--dbus/dbus-internals.h29
4 files changed, 86 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d879044d..26a9ce24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2003-01-18 Havoc Pennington <hp@pobox.com>
+ Building --disable-verbose-mode --disable-asserts --disable-tests
+ cuts the library from 112K to 45K or so
+
+ * configure.in: check for varargs macro support,
+ add --enable-verbose-mode, --enable-asserts.
+
+ * dbus/dbus-internals.h (_dbus_assert): support
+ DBUS_DISABLE_ASSERT
+ (_dbus_verbose): support DBUS_ENABLE_VERBOSE_MODE
+
+2003-01-18 Havoc Pennington <hp@pobox.com>
+
* dbus/dbus-test.c: include config.h so that tests actually run
* dbus/dbus-string.c: add assertions that stuff is 8-byte aligned,
diff --git a/configure.in b/configure.in
index 5e859448..9f136b66 100644
--- a/configure.in
+++ b/configure.in
@@ -25,8 +25,10 @@ AM_PROG_LIBTOOL
AC_ARG_ENABLE(qt, [ --enable-qt enable Qt-friendly client library],enable_qt=$enableval,enable_qt=auto)
AC_ARG_ENABLE(glib, [ --enable-glib enable GLib-friendly client library],enable_glib=$enableval,enable_glib=auto)
-AC_ARG_ENABLE(tests, [ --enable-tests enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
-AC_ARG_ENABLE(ansi, [ --enable-ansi enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
+AC_ARG_ENABLE(tests, [ --enable-tests enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
+AC_ARG_ENABLE(ansi, [ --enable-ansi enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
+AC_ARG_ENABLE(verbose-mode, [ --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=yes)
+AC_ARG_ENABLE(asserts, [ --enable-asserts include assertion checks],enable_asserts=$enableval,enable_asserts=yes)
dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
dnl and also some stuff in the test/ subdir
@@ -35,6 +37,13 @@ if test x$enable_tests = xyes; then
AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
fi
+if test x$enable_verbose_mode = xyes; then
+ AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
+fi
+if test x$enable_asserts = xno; then
+ AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
+fi
+
changequote(,)dnl
if test "x$GCC" = "xyes"; then
case " $CFLAGS " in
@@ -108,6 +117,32 @@ dnl check for writev header and writev function so we're
dnl good to go if HAVE_WRITEV gets defined.
AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
+dnl check for flavours of varargs macros (test from GLib)
+AC_MSG_CHECKING(for ISO C99 varargs macros in C)
+AC_TRY_COMPILE([],[
+int a(int p1, int p2, int p3);
+#define call_a(...) a(1,__VA_ARGS__)
+call_a(2,3);
+],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
+AC_MSG_RESULT($dbus_have_iso_c_varargs)
+
+AC_MSG_CHECKING(for GNUC varargs macros)
+AC_TRY_COMPILE([],[
+int a(int p1, int p2, int p3);
+#define call_a(params...) a(1,params)
+call_a(2,3);
+],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
+AC_MSG_RESULT($dbus_have_gnuc_varargs)
+
+dnl Output varargs tests
+if test x$dbus_have_iso_c_varargs = xyes; then
+ AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
+fi
+if test x$dbus_have_gnuc_varargs = xyes; then
+ AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
+fi
+
+
DBUS_CLIENT_CFLAGS=
DBUS_CLIENT_LIBS=
AC_SUBST(DBUS_CLIENT_CFLAGS)
@@ -205,6 +240,8 @@ echo "
Maintainer mode: ${USE_MAINTAINER_MODE}
Building unit tests: ${enable_tests}
+ Building verbose mode: ${enable_verbose_mode}
+ Building assertions: ${enable_asserts}
Building Qt bindings: ${have_qt}
Building GLib bindings: ${have_glib}
"
@@ -212,3 +249,9 @@ echo "
if test x$enable_tests = xyes; then
echo "NOTE: building with unit tests increases the size of the installed library"
fi
+if test x$enable_verbose_mode = xyes; then
+ echo "NOTE: building with verbose mode increases library size, but is probably a good idea anyway."
+fi
+if test x$enable_asserts = xyes; then
+ echo "NOTE: building with assertions increases library size, but is probably a good idea anyway."
+fi
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index 9b672ef6..8413ac00 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -147,12 +147,14 @@ _dbus_warn (const char *format,
/**
* Prints a warning message to stderr
* if the user has enabled verbose mode.
+ * This is the real function implementation,
+ * use _dbus_verbose() macro in code.
*
* @param format printf-style format string.
*/
void
-_dbus_verbose (const char *format,
- ...)
+_dbus_verbose_real (const char *format,
+ ...)
{
va_list args;
static dbus_bool_t verbose = TRUE;
diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h
index 4bdf41d1..f0baf46b 100644
--- a/dbus/dbus-internals.h
+++ b/dbus/dbus-internals.h
@@ -36,15 +36,31 @@
DBUS_BEGIN_DECLS;
-void _dbus_warn (const char *format,
- ...);
-void _dbus_verbose (const char *format,
- ...);
+void _dbus_warn (const char *format,
+ ...);
+void _dbus_verbose_real (const char *format,
+ ...);
+
+
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+# define _dbus_verbose _dbus_verbose_real
+#else
+# ifdef HAVE_ISO_VARARGS
+# define _dbus_verbose(...)
+# elif defined (HAVE_GNUC_VARARGS)
+# define _dbus_verbose(format...)
+# else
+# error "This compiler does not support varargs macros and thus verbose mode can't be disabled meaningfully"
+# endif
+#endif /* !DBUS_ENABLE_VERBOSE_MODE */
const char* _dbus_strerror (int error_number);
DBusResultCode _dbus_result_from_errno (int error_number);
+#ifdef DBUS_DISABLE_ASSERT
+#define _dbus_assert(condition)
+#else
#define _dbus_assert(condition) \
do { \
if (!(condition)) \
@@ -54,13 +70,18 @@ do { \
_dbus_abort (); \
} \
} while (0)
+#endif /* !DBUS_DISABLE_ASSERT */
+#ifdef DBUS_DISABLE_ASSERT
+#define _dbus_assert_not_reached(explanation)
+#else
#define _dbus_assert_not_reached(explanation) \
do { \
_dbus_warn ("File \"%s\" line %d should not have been reached: %s\n", \
__FILE__, __LINE__, (explanation)); \
_dbus_abort (); \
} while (0)
+#endif /* !DBUS_DISABLE_ASSERT */
#define _DBUS_N_ELEMENTS(array) ((int) (sizeof ((array)) / sizeof ((array)[0])))