[enable_pthreads="$enableval"], [enable_pthreads="yes"])
AM_CONDITIONAL([DISABLE_PTHREADS], [test "$enable_pthreads" = "no"])
+AC_ARG_ENABLE([debug],
+ AS_HELP_STRING([--disable-debug], [Do not include debugging statements]),
+ [enable_debug="$enableval"], [enable_debug="yes"])
+AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "no" ])
+
AC_CHECK_LIB([m], [pow], [], AC_MSG_ERROR([libm is required]))
if test "x$enable_pthreads" = "xno"; then
AC_CHECK_LIB([pthread], [pthread_mutex_lock], [], AC_MSG_ERROR([libpthread is required]))
fi
+if test "x$enable_debug" = "xyes"; then
+ AC_DEFINE([NL_DEBUG], [1], [Define to 1 to enable debugging])
+fi
+
AC_CONFIG_SUBDIRS([doc])
AC_CONFIG_FILES([
struct nl_list_head list;
};
-#define NL_DEBUG 1
-
-#define NL_DBG(LVL,FMT,ARG...) \
- do { \
- if (LVL <= nl_debug) \
- fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \
+#ifdef NL_DEBUG
+#define NL_DBG(LVL,FMT,ARG...) \
+ do { \
+ if (LVL <= nl_debug) \
+ fprintf(stderr, \
+ "DBG<" #LVL ">%20s:%-4u %s: " FMT, \
+ __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__, ##ARG); \
} while (0)
+#else /* NL_DEBUG */
+#define NL_DBG(LVL,FMT,ARG...) do { } while(0)
+#endif /* NL_DEBUG */
#define BUG() \
do { \
- NL_DBG(1, "BUG: %s:%d\n", \
- __FILE__, __LINE__); \
+ fprintf(stderr, "BUG at file position %s:%d:%s\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__); \
assert(0); \
} while (0)
#define APPBUG(msg) \
do { \
- NL_DBG(1, "APPLICATION BUG: %s:%d:%s: %s\n", \
+ fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, msg); \
assert(0); \
} while(0)
uint32_t n_ifindex;
char n_addr[0];
} __attribute__((packed)) *nkey;
+#ifdef NL_DEBUG
char buf[INET6_ADDRSTRLEN+5];
+#endif
if (neigh->n_family == AF_BRIDGE) {
if (neigh->n_lladdr)
uint32_t rt_prio;
char rt_addr[0];
} __attribute__((packed)) *rkey;
+#ifdef NL_DEBUG
char buf[INET6_ADDRSTRLEN+5];
+#endif
if (route->rt_dst)
addr = route->rt_dst;
struct rtnl_route *new_route = (struct rtnl_route *) new_obj;
struct rtnl_route *old_route = (struct rtnl_route *) old_obj;
struct rtnl_nexthop *new_nh;
- char buf[INET6_ADDRSTRLEN+5];
int action = new_obj->ce_msgtype;
+#ifdef NL_DEBUG
+ char buf[INET6_ADDRSTRLEN+5];
+#endif
/*
* ipv6 ECMP route notifications from the kernel come as
int nl_debug = 0;
/** @cond SKIP */
+#ifdef NL_DEBUG
struct nl_dump_params nl_debug_dp = {
.dp_type = NL_DUMP_DETAILS,
};
nl_debug_dp.dp_fd = stderr;
}
+#endif
int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *))
{