41 lines
1.0 KiB
C
41 lines
1.0 KiB
C
#ifndef KPRINTF_H_
|
|
#define KPRINTF_H_
|
|
|
|
#include <printf/printf.h>
|
|
#include "term/term.h"
|
|
#include "spinlock/spinlock.h"
|
|
|
|
#define kprintf(fmt, ...) \
|
|
do { \
|
|
spinlock_acquire(&TERM.spinlock); \
|
|
printf_(fmt, ##__VA_ARGS__); \
|
|
spinlock_release(&TERM.spinlock); \
|
|
} while(0)
|
|
|
|
#define kprintf_unsafe(fmt, ...) \
|
|
do { \
|
|
printf_(fmt, ##__VA_ARGS__); \
|
|
} while(0)
|
|
|
|
#define ksprintf sprintf_
|
|
#define kvsprintf vsprintf_
|
|
#define ksnprintf snprintf_
|
|
#define kvsnprintf vsnprintf_
|
|
#define kvprintf vprintf_
|
|
|
|
#ifdef KPRINTF_COLORS
|
|
# include "ansi_colors.h"
|
|
# define LOG(component, fmt, ...) kprintf(CRESET "[" CYN component CRESET "]: " fmt, ##__VA_ARGS__)
|
|
#else
|
|
# define LOG(component, fmt, ...) kprintf("["component"]: "fmt, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#ifdef KPRINTF_COLORS
|
|
# include "ansi_colors.h"
|
|
# define ERR(component, fmt, ...) kprintf(CRESET "[" RED component CRESET "]: " fmt, ##__VA_ARGS__)
|
|
#else
|
|
# define ERR(component, fmt, ...) kprintf("["component"]: "fmt, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#endif // KPRINTF_H_
|