diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-25 12:36:41 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-25 12:36:41 (EDT) |
commit | ec249526ef406db942067c274415d17fb923c2cc (patch) | |
tree | 1581e4e3dd5f324b5c689764a14d3e8e03753867 | |
parent | c64472f47e5434caddb247ca9e7500111b82f7dc (diff) | |
download | marquee-ec249526ef406db942067c274415d17fb923c2cc.zip marquee-ec249526ef406db942067c274415d17fb923c2cc.tar.gz marquee-ec249526ef406db942067c274415d17fb923c2cc.tar.bz2 |
MqTree: Fix width of pointers in debugging output
And modify configure.ac to search for logl() and add -lm to LIBS.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/tree.c | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index 9d82351..e6ff630 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,8 @@ AC_ARG_ENABLE( [enable_debug=no]) if test "x${enable_debug}" = 'xyes'; then + AC_SEARCH_LIBS([logl], [m], [], + [AC_MSG_ERROR([unable to find the logl() function])]) AC_DEFINE([MQ_TREE_DEBUG], [1], [Define to 1 to enable tree debugging.]) else AC_DEFINE([MQ_TREE_DEBUG], [0], [Define to 1 to enable tree debugging.]) @@ -31,6 +31,10 @@ #if MQ_TREE_DEBUG +#include <math.h> + +#define PRIWxPTR ((int) (logl(UINTPTR_MAX) / logl(16))) + static void debug_print_tree_recurse(MqTree *node, gsize indent) { @@ -40,15 +44,16 @@ debug_print_tree_recurse(MqTree *node, gsize indent) for (i = 0; i < indent; ++i) { g_print("\t"); } - g_print("\t0x%" PRIxPTR " (size %d, position %d, " - "parent 0x%" PRIxPTR ", " - "siblings 0x%" PRIxPTR " and 0x%" PRIxPTR ", " - "children 0x%" PRIxPTR " to 0x%" PRIxPTR ")\n", - (uintptr_t) node, node->size, node->position, - (uintptr_t) node->parent, - (uintptr_t) node->prev, (uintptr_t) node->next, - (uintptr_t) node->first_child, - (uintptr_t) node->last_child); + g_print("\t0x%0*" PRIxPTR " (size %d, position %d, " + "parent 0x%0*" PRIxPTR ", " + "siblings 0x%0*" PRIxPTR " and 0x%0*" PRIxPTR ", " + "children 0x%0*" PRIxPTR " to 0x%0*" PRIxPTR ")\n", + PRIWxPTR, (uintptr_t) node, node->size, node->position, + PRIWxPTR, (uintptr_t) node->parent, + PRIWxPTR, (uintptr_t) node->prev, + PRIWxPTR, (uintptr_t) node->next, + PRIWxPTR, (uintptr_t) node->first_child, + PRIWxPTR, (uintptr_t) node->last_child); if (node->first_child) { debug_print_tree_recurse(node->first_child, indent + 1); @@ -59,7 +64,7 @@ debug_print_tree_recurse(MqTree *node, gsize indent) static void debug_print_tree(const gchar *msg, MqTree *node) { - g_print("%s 0x%" PRIxPTR ", ", msg, (uintptr_t) node); + g_print("%s 0x%0*" PRIxPTR ", ", msg, PRIWxPTR, (uintptr_t) node); node = node->root; g_print("new tree (size %d):\n", node->size); debug_print_tree_recurse(node, 0); @@ -68,13 +73,14 @@ debug_print_tree(const gchar *msg, MqTree *node) static void debug_print_node(MqTree *node) { - g_print("\t0x%" PRIxPTR "\n", (uintptr_t) node); + g_print("\t0x%0*" PRIxPTR "\n", PRIWxPTR, (uintptr_t) node); } static void debug_print_head(const gchar *head, MqTree *node) { - g_print("%s, starting at 0x%" PRIxPTR "\n", head, (uintptr_t) node); + g_print("%s, starting at 0x%0*" PRIxPTR "\n", + head, PRIWxPTR, (uintptr_t) node); } #else /* MQ_TREE_DEBUG */ |