summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-09-12 09:30:02 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-09-12 09:30:02 +0000
commit9c3dd1e1e140ef6ed037baaf49fd4eec0fd65e5b (patch)
tree52e749a2df2a6cef42a57723fc224412c39240e6 /src/runtime/c
parent2105188bd0ab85a6388bc18de12e43936f996105 (diff)
remove the logging from libgu
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/Makefile.am2
-rw-r--r--src/runtime/c/gu/choice.c4
-rw-r--r--src/runtime/c/gu/log.c79
-rw-r--r--src/runtime/c/gu/log.h65
-rw-r--r--src/runtime/c/gu/map.c2
-rw-r--r--src/runtime/c/gu/mem.c10
-rw-r--r--src/runtime/c/pgf/linearizer.c1
-rw-r--r--src/runtime/c/pgf/parser.c1
-rw-r--r--src/runtime/c/utils/pgf-parse.c1
-rw-r--r--src/runtime/c/utils/pgf-translate.c1
10 files changed, 0 insertions, 166 deletions
diff --git a/src/runtime/c/Makefile.am b/src/runtime/c/Makefile.am
index bc5ad0327..8fcbe847f 100644
--- a/src/runtime/c/Makefile.am
+++ b/src/runtime/c/Makefile.am
@@ -21,7 +21,6 @@ guinclude_HEADERS = \
gu/hash.h \
gu/in.h \
gu/list.h \
- gu/log.h \
gu/map.h \
gu/mem.h \
gu/out.h \
@@ -59,7 +58,6 @@ libgu_la_SOURCES = \
gu/hash.c \
gu/in.c \
gu/list.c \
- gu/log.c \
gu/map.c \
gu/mem.c \
gu/out.c \
diff --git a/src/runtime/c/gu/choice.c b/src/runtime/c/gu/choice.c
index ddf0bb68b..ed1e02a51 100644
--- a/src/runtime/c/gu/choice.c
+++ b/src/runtime/c/gu/choice.c
@@ -1,7 +1,6 @@
#include <gu/choice.h>
#include <gu/seq.h>
#include <gu/assert.h>
-#include <gu/log.h>
struct GuChoice {
GuBuf* path;
@@ -21,7 +20,6 @@ GuChoiceMark
gu_choice_mark(GuChoice* ch)
{
gu_assert(ch->path_idx <= gu_buf_length(ch->path));
- gu_debug("%p@%d: mark", ch, ch->path_idx);
return (GuChoiceMark){ch->path_idx};
}
@@ -29,7 +27,6 @@ void
gu_choice_reset(GuChoice* ch, GuChoiceMark mark)
{
gu_assert(ch->path_idx <= gu_buf_length(ch->path));
- gu_debug("%p@%d: reset %d", ch, ch->path_idx, mark.path_idx);
gu_require(mark.path_idx <= ch->path_idx );
ch->path_idx = mark.path_idx;
}
@@ -51,7 +48,6 @@ gu_choice_next(GuChoice* ch, int n_choices)
i = n_choices;
}
int ret = (i == 0) ? -1 : n_choices - i;
- gu_debug("%p@%d: %d", ch, ch->path_idx, ret);
ch->path_idx++;
return ret;
}
diff --git a/src/runtime/c/gu/log.c b/src/runtime/c/gu/log.c
deleted file mode 100644
index 399646c50..000000000
--- a/src/runtime/c/gu/log.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <gu/defs.h>
-#include <gu/log.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-
-static int gu_log_depth = 0;
-
-static bool
-gu_log_match(const char* pat, size_t patlen, const char* str)
-{
- if (patlen > 0 && pat[patlen-1] == '*') {
- return strncmp(pat, str, patlen-1) == 0;
- } else if (strlen(str) == patlen) {
- return strncmp(pat, str, patlen) == 0;
- }
- return false;
-}
-
-static bool
-gu_log_enabled(const char* func, const char* file)
-{
- const char* cfg = getenv("GU_LOG");
- if (cfg == NULL) {
- return false;
- }
- const char* p = cfg;
- while (true) {
- size_t len = strcspn(p, ",");
- if (gu_log_match(p, len, func)) {
- return true;
- }
- if (gu_log_match(p, len, file)) {
- return true;
- }
- if (p[len] == '\0') {
- break;
- }
- p = &p[len + 1];
- }
- return false;
-}
-
-
-void
-gu_log_full_v(GuLogKind kind, const char* func, const char* file, int line,
- const char* fmt, va_list args)
-{
- (void) (kind && line);
- if (!gu_log_enabled(func, file)) {
- return;
- }
- if (kind == GU_LOG_KIND_EXIT) {
- gu_log_depth--;
- }
- if (fmt) {
- int indent = gu_min(32 + gu_log_depth, 48);
- fprintf(stderr, "%-*s: ", indent, func);
- vfprintf(stderr, fmt, args);
- fputc('\n', stderr);
- fflush(stderr);
- }
- if (kind == GU_LOG_KIND_ENTER) {
- gu_log_depth++;
- }
-}
-
-void
-gu_log_full(GuLogKind kind, const char* func, const char* file, int line,
- const char* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- gu_log_full_v(kind, func, file, line, fmt, args);
- va_end(args);
-}
-
diff --git a/src/runtime/c/gu/log.h b/src/runtime/c/gu/log.h
deleted file mode 100644
index ec9ecdf75..000000000
--- a/src/runtime/c/gu/log.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef GU_LOG_H_
-#define GU_LOG_H_
-
-#include <stdarg.h>
-
-typedef enum GuLogKind {
- GU_LOG_KIND_ENTER,
- GU_LOG_KIND_EXIT,
- GU_LOG_KIND_DEBUG,
- GU_LOG_KIND_ERROR
-} GuLogKind;
-
-void
-gu_log_full(GuLogKind kind, const char* func, const char* file, int line,
- const char* fmt, ...);
-
-
-void
-gu_log_full_v(GuLogKind kind, const char* func, const char* file, int line,
- const char* fmt, va_list args);
-
-
-#ifndef NDEBUG
-
-#define gu_logv(kind_, fmt_, args_) \
- gu_log_full_v(kind_, __func__, __FILE__, __LINE__, fmt_, args_)
-
-#define gu_log(kind_, ...) \
- gu_log_full(kind_, __func__, __FILE__, __LINE__, __VA_ARGS__)
-
-#else
-
-static inline void
-gu_logv(GuLogKind kind, const char* fmt, va_list args)
-{
- (void) kind;
- (void) fmt;
- (void) args;
-}
-
-static inline void
-gu_log(GuLogKind kind, const char* fmt, ...)
-{
- (void) kind;
- (void) fmt;
-}
-
-#endif
-
-
-
-
-#define gu_enter(...) \
- gu_log(GU_LOG_KIND_ENTER, __VA_ARGS__)
-
-#define gu_exit(...) \
- gu_log(GU_LOG_KIND_EXIT, __VA_ARGS__)
-
-#define gu_debug(...) \
- gu_log(GU_LOG_KIND_DEBUG, __VA_ARGS__)
-
-#define gu_debugv(kind_, fmt_, args_) \
- gu_logv(GU_LOG_KIND_DEBUG, fmt_, args_)
-
-#endif // GU_LOG_H_
diff --git a/src/runtime/c/gu/map.c b/src/runtime/c/gu/map.c
index 6505953af..ea045f82a 100644
--- a/src/runtime/c/gu/map.c
+++ b/src/runtime/c/gu/map.c
@@ -4,7 +4,6 @@
#include <gu/map.h>
#include <gu/assert.h>
#include <gu/prime.h>
-#include <gu/log.h>
typedef enum {
GU_MAP_GENERIC,
@@ -185,7 +184,6 @@ gu_map_resize(GuMap* map)
}
gu_assert(data->n_entries > data->n_occupied);
- gu_debug("Resized to %d entries", data->n_entries);
data->n_occupied = 0;
data->zero_idx = SIZE_MAX;
diff --git a/src/runtime/c/gu/mem.c b/src/runtime/c/gu/mem.c
index ae355e5b6..62ffef85d 100644
--- a/src/runtime/c/gu/mem.c
+++ b/src/runtime/c/gu/mem.c
@@ -21,7 +21,6 @@
#include <gu/fun.h>
#include <gu/bits.h>
#include <gu/assert.h>
-#include <gu/log.h>
#include <string.h>
#include <stdlib.h>
@@ -60,7 +59,6 @@ gu_mem_realloc(void* p, size_t size)
if (size != 0 && buf == NULL) {
gu_fatal("Memory allocation failed");
}
- gu_debug("%p %zu -> %p", p, size, buf); // strictly illegal
return buf;
}
@@ -71,14 +69,12 @@ gu_mem_alloc(size_t size)
if (buf == NULL) {
gu_fatal("Memory allocation failed");
}
- gu_debug("%zu -> %p", size, buf);
return buf;
}
static void
gu_mem_free(void* p)
{
- gu_debug("%p", p);
free(p);
}
@@ -180,7 +176,6 @@ gu_local_pool_(uint8_t* buf, size_t sz)
{
GuPool* pool = gu_init_pool(buf, sz);
pool->flags |= GU_POOL_LOCAL;
- gu_debug("%p", pool);
return pool;
}
@@ -190,7 +185,6 @@ gu_new_pool(void)
size_t sz = GU_FLEX_SIZE(GuPool, init_buf, gu_mem_pool_initial_size);
uint8_t* buf = gu_mem_buf_alloc(sz, &sz);
GuPool* pool = gu_init_pool(buf, sz);
- gu_debug("%p", pool);
return pool;
}
@@ -264,8 +258,6 @@ void*
gu_malloc_prefixed(GuPool* pool, size_t pre_align, size_t pre_size,
size_t align, size_t size)
{
- gu_enter("-> %p %zu %zu %zu %zu",
- pool, pre_align, pre_size, align, size);
void* ret = NULL;
if (pre_align == 0) {
pre_align = gu_alignof(GuMaxAlign);
@@ -291,7 +283,6 @@ gu_malloc_prefixed(GuPool* pool, size_t pre_align, size_t pre_size,
ret = gu_pool_malloc_aligned(pool, pre_align, pre_size,
align, size);
}
- gu_exit("<- %p", ret);
return ret;
}
@@ -318,7 +309,6 @@ gu_pool_finally(GuPool* pool, GuFinalizer* finalizer)
void
gu_pool_free(GuPool* pool)
{
- gu_debug("%p", pool);
GuFinalizerNode* node = pool->finalizers;
while (node) {
GuFinalizerNode* next = node->next;
diff --git a/src/runtime/c/pgf/linearizer.c b/src/runtime/c/pgf/linearizer.c
index 9626c0ebd..93fbb452c 100644
--- a/src/runtime/c/pgf/linearizer.c
+++ b/src/runtime/c/pgf/linearizer.c
@@ -2,7 +2,6 @@
#include "linearizer.h"
#include <gu/map.h>
#include <gu/fun.h>
-#include <gu/log.h>
#include <gu/choice.h>
#include <gu/seq.h>
#include <gu/file.h>
diff --git a/src/runtime/c/pgf/parser.c b/src/runtime/c/pgf/parser.c
index 47880e874..97bc08375 100644
--- a/src/runtime/c/pgf/parser.c
+++ b/src/runtime/c/pgf/parser.c
@@ -2,7 +2,6 @@
#include <gu/seq.h>
#include <gu/assert.h>
-#include <gu/log.h>
#include <gu/file.h>
#include <math.h>
#include <stdlib.h>
diff --git a/src/runtime/c/utils/pgf-parse.c b/src/runtime/c/utils/pgf-parse.c
index a990ee933..bd7ea6c89 100644
--- a/src/runtime/c/utils/pgf-parse.c
+++ b/src/runtime/c/utils/pgf-parse.c
@@ -1,6 +1,5 @@
#include <gu/variant.h>
#include <gu/map.h>
-#include <gu/log.h>
#include <gu/enum.h>
#include <gu/file.h>
#include <pgf/pgf.h>
diff --git a/src/runtime/c/utils/pgf-translate.c b/src/runtime/c/utils/pgf-translate.c
index b8eae9cb4..41f74fda2 100644
--- a/src/runtime/c/utils/pgf-translate.c
+++ b/src/runtime/c/utils/pgf-translate.c
@@ -1,6 +1,5 @@
#include <gu/variant.h>
#include <gu/map.h>
-#include <gu/log.h>
#include <gu/enum.h>
#include <gu/file.h>
#include <pgf/pgf.h>