Skip to content

Commit d3a595f

Browse files
WinterMuteDacoTaco
authored andcommitted
replace kprintf with Calico's dietPrint. Closes #75
1 parent cefe292 commit d3a595f

2 files changed

Lines changed: 401 additions & 245 deletions

File tree

gc/ogc/system.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ distribution.
3838
3939
*/
4040

41+
#include <stdarg.h>
42+
4143
#include <gctypes.h>
4244
#include <gcbool.h>
4345
#include <gcutil.h>
@@ -399,7 +401,26 @@ powercallback SYS_SetPowerCallback(powercallback cb);
399401
*/
400402
u64 SYS_Time(void);
401403

402-
void kprintf(const char *str, ...);
404+
/*! @brief Printing callback used by @ref dietPrint.
405+
@note The incoming @p buf may be NULL, in which case the callback is
406+
expected to output the number of space characters given by @p size.
407+
*/
408+
typedef void (*DietPrintFn)(const char* buf, size_t size);
409+
410+
/*! @brief Sets @p fn as the current printing callback.
411+
@warning This function changes global state, and as such is not thread safe.
412+
*/
413+
static inline void dietPrintSetFunc(DietPrintFn fn)
414+
{
415+
extern DietPrintFn g_dietPrintFn;
416+
g_dietPrintFn = fn;
417+
}
418+
419+
//! @brief Prints the specified formatted text (works like vprintf).
420+
void dietPrintV(const char* fmt, va_list va) __attribute__((format(printf, 1, 0)));
421+
422+
//! @brief Prints the specified formatted text (works like printf).
423+
void kprintf(const char *str, ...) __attribute__((format(printf, 1, 2)));
403424

404425
#ifdef __cplusplus
405426
}

0 commit comments

Comments
 (0)