From e96f18d4e720663f79c6a7dc74c19b3c7f83ea5f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 9 Nov 2023 15:08:21 -0800 Subject: Small boot cleanup (#1475) --- src/boot/O2/sprintf.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/boot/O2/sprintf.c (limited to 'src/boot/O2/sprintf.c') diff --git a/src/boot/O2/sprintf.c b/src/boot/O2/sprintf.c new file mode 100644 index 000000000..773b982ff --- /dev/null +++ b/src/boot/O2/sprintf.c @@ -0,0 +1,30 @@ +#include "ultra64.h" +#include "libc/stdlib.h" +#include "libc/string.h" + +void* proutSprintf(void* dst, const char* fmt, size_t size) { + return (void*)((uintptr_t)memcpy(dst, fmt, size) + size); +} + +int vsprintf(char* dst, char* fmt, va_list args) { + int ans = _Printf(proutSprintf, dst, fmt, args); + if (ans > -1) { + dst[ans] = 0; + } + return ans; +} + +int sprintf(char* dst, const char* fmt, ...) { + int ans; + va_list args; + va_start(args, fmt); + + ans = _Printf(&proutSprintf, dst, fmt, args); + if (ans > -1) { + dst[ans] = 0; + } + + va_end(args); + + return ans; +} -- cgit v1.2.3