Compare commits

...

2 Commits

Author SHA1 Message Date
7fd472c17c day 11 part 1 (plenty of logs) 2021-12-12 19:00:51 +01:00
80c19f9331 debug.[ch]: kernel style #ifdef free C source 2021-12-12 19:00:06 +01:00
5 changed files with 26 additions and 7 deletions

View File

@@ -24,7 +24,7 @@ CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -march=native
CFLAGS += -DDEBUG # activate general debug (debug.c)
CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c)
CFLAGS += -DDEBUG_POOL # memory pools management
INCDIR := ./include

View File

@@ -24,7 +24,7 @@ LDLIB := -l$(LIB)
export LD_LIBRARY_PATH = $(LIBDIR)
CFLAGS += -std=gnu99
CFLAGS += -O2
#CFLAGS += -O2
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -Wextra
@@ -32,6 +32,9 @@ CFLAGS += -march=native
CFLAGS += -Wmissing-declarations
CFLAGS += -Wno-unused-result
CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c)
CFLAGS += -DDEBUG_POOL # memory pools management
TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n"
export PATH := .:$(PATH)
@@ -52,4 +55,4 @@ clean:
.c:
@echo compiling $<
@$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@
$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@

View File

@@ -297,3 +297,7 @@ After step 100:
After 100 steps, there have been a total of 1656 flashes.
Given the starting energy levels of the dumbo octopuses in your cavern, simulate 100 steps. How many total flashes are there after 100 steps?
Your puzzle answer was 1739.
The first half of this puzzle is complete! It provides one gold star: *

View File

@@ -19,13 +19,22 @@
#include "bits.h"
#ifdef DEBUG_DEBUG
void debug_init(u32 level);
void debug_level_set(u32 level);
void debug_devel_set(u32 level);
void debug(u32 level, bool timestamp, u32 indent,
const char *src, u32 line, const char *, ...);
#ifdef DEBUG
#else /* DEBUG_DEBUG */
#define _unused __attribute__((__unused__))
static inline void debug_init(_unused u32 level) {}
static inline void debug_level_set(_unused u32 level) {}
static inline void debug_devel_set(_unused u32 level) {}
static inline void debug(_unused u32 level, _unused bool timestamp,
_unused u32 indent, _unused const char *src,
_unused u32 line, const char *, ...) {}
#undef _unused
#endif /* DEBUG_DEBUG */
/* format: only printf
*/
@@ -63,6 +72,4 @@ void debug(u32 level, bool timestamp, u32 indent,
#define log_it(...)
#define log_f(...)
#endif /* DEBUG */
#endif /* DEBUG_H */

View File

@@ -14,6 +14,11 @@
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#ifndef DEBUG_DEBUG
#define DEBUG_DEBUG
#endif
#include "debug.h"
#define NANOSEC 1000000000 /* nano sec in sec */