2022-03-16 20:33:13 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
|
2023-08-14 03:31:27 +00:00
|
|
|
#ifdef _COSMO_SOURCE
|
2023-06-06 10:30:37 +00:00
|
|
|
|
2023-08-19 13:41:06 +00:00
|
|
|
#define klog __klog
|
2023-06-06 10:30:37 +00:00
|
|
|
#define kprintf __kprintf
|
|
|
|
#define ksnprintf __ksnprintf
|
|
|
|
#define kvprintf __kvprintf
|
|
|
|
#define kvsnprintf __kvsnprintf
|
2023-08-19 13:41:06 +00:00
|
|
|
#define kloghandle __kloghandle
|
2023-06-06 10:30:37 +00:00
|
|
|
#define kisdangerous __kisdangerous
|
2023-10-25 21:32:20 +00:00
|
|
|
#define uprintf __uprintf
|
|
|
|
#define uvprintf __uvprintf
|
2023-06-06 10:30:37 +00:00
|
|
|
|
2022-03-16 20:33:13 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
|
2023-10-25 21:32:20 +00:00
|
|
|
COSMOPOLITAN_C_START_
|
2023-06-06 10:30:37 +00:00
|
|
|
|
2022-03-16 20:33:13 +00:00
|
|
|
void kprintf(const char *, ...);
|
|
|
|
size_t ksnprintf(char *, size_t, const char *, ...);
|
|
|
|
void kvprintf(const char *, va_list);
|
|
|
|
size_t kvsnprintf(char *, size_t, const char *, va_list);
|
2023-08-19 13:41:06 +00:00
|
|
|
|
2022-03-16 20:33:13 +00:00
|
|
|
bool kisdangerous(const void *);
|
2023-10-25 21:32:20 +00:00
|
|
|
|
2023-08-19 13:41:06 +00:00
|
|
|
void klog(const char *, size_t);
|
2023-10-25 21:32:20 +00:00
|
|
|
void _klog_serial(const char *, size_t);
|
2023-08-19 13:41:06 +00:00
|
|
|
long kloghandle(void);
|
2022-03-16 20:33:13 +00:00
|
|
|
|
2023-10-25 21:32:20 +00:00
|
|
|
void uprintf(const char *, ...);
|
|
|
|
void uvprintf(const char *, va_list);
|
|
|
|
|
|
|
|
#ifndef TINY
|
|
|
|
#define KINFOF(FMT, ...) \
|
|
|
|
do { \
|
|
|
|
uprintf("\r\e[35m%s:%d: " FMT "\e[0m\n", \
|
|
|
|
__FILE__, __LINE__, ## __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
#define KWARNF(FMT, ...) \
|
|
|
|
do { \
|
|
|
|
uprintf("\r\e[94;49mwarn: %s:%d: " FMT "\e[0m\n", \
|
|
|
|
__FILE__, __LINE__, ## __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define KINFOF(FMT, ...) ((void)0)
|
|
|
|
#define KWARNF(FMT, ...) ((void)0)
|
|
|
|
#endif
|
|
|
|
#define KDIEF(FMT, ...) \
|
|
|
|
do { \
|
|
|
|
kprintf("\r\e[30;101mfatal: %s:%d: " FMT "\e[0m\n", \
|
|
|
|
__FILE__, __LINE__, ## __VA_ARGS__); \
|
|
|
|
for (;;) asm volatile("cli\n\thlt"); \
|
|
|
|
} while (0)
|
|
|
|
|
2022-03-16 20:33:13 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
2023-08-14 03:31:27 +00:00
|
|
|
#endif /* _COSMO_SOURCE */
|
2022-03-16 20:33:13 +00:00
|
|
|
#endif /* COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_ */
|