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 #include #include -#include 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 -#include - -#include -#include -#include -#include - -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 - -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 #include #include -#include 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 #include #include -#include #include #include @@ -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 #include -#include #include #include #include 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 #include -#include #include #include #include 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 #include -#include #include #include #include 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 #include -#include #include #include #include diff --git a/src/ui/android/jni/Android.mk b/src/ui/android/jni/Android.mk index 3359d6486..6076cac20 100644 --- a/src/ui/android/jni/Android.mk +++ b/src/ui/android/jni/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) jni_c_files := jpgf.c pgf_c_files := data.c expr.c graphviz.c lexer.c linearizer.c literals.c parser.c parseval.c pgf.c printer.c reader.c reasoner.c jit.c gu_c_files := assert.c choice.c exn.c fun.c in.c list.c map.c out.c str.c type.c utf8.c \ -bits.c defs.c enum.c file.c hash.c log.c mem.c prime.c seq.c string.c ucs.c variant.c +bits.c defs.c enum.c file.c hash.c mem.c prime.c seq.c string.c ucs.c variant.c LOCAL_MODULE := jpgf LOCAL_SRC_FILES := $(addprefix ../../../runtime/java/, $(jni_c_files)) \