From ac69a640ba9dde383b9c3ddca59c3d6d14ea5b2e Mon Sep 17 00:00:00 2001 From: Oxore Date: Tue, 7 Mar 2023 18:17:44 +0300 Subject: Move retarget.cpp to where it belongs --- app/platform/retarget.cpp | 93 ----------------------------------- app/platform/stm32f0-gcc/retarget.cpp | 93 +++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 app/platform/retarget.cpp create mode 100644 app/platform/stm32f0-gcc/retarget.cpp (limited to 'app') diff --git a/app/platform/retarget.cpp b/app/platform/retarget.cpp deleted file mode 100644 index 524840e..0000000 --- a/app/platform/retarget.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "unistd.h" -#include -#include -#include -#include -#include "third_party/printf/printf.h" - -#ifdef errno -#undef errno -#endif - -int errno{}; - -extern "C" [[noreturn]] void vApplicationMallocFailedHook(void) -{ - for (;;); -} - -extern "C" [[noreturn]] void vApplicationStackOverflowHook(void *task_handle, char *task_name) -{ - (void) task_handle; - (void) task_name; - for (;;); -} - -extern "C" void vApplicationIdleHook(void) -{ -} - -extern "C" [[noreturn]] void _exit(int __status) -{ - (void) __status; - for (;;); -} - -/* func can be NULL, in which case no function information is given. */ -extern "C" [[noreturn]] void __assert_func ( - const char *file, int line, const char *func, const char *failedexpr) -{ - dprintf(STDERR_FILENO, - "assertion \"%s\" failed: file \"%s\", line %d%s%s\n", - failedexpr, file, line, - func ? ", function: " : "", func ? func : ""); - abort(); - /* NOTREACHED */ -} - -extern "C" ssize_t read(int fd, void *buf, size_t nbytes) -{ - (void) fd; - (void) buf; - (void) nbytes; - errno = ENOSYS; - return -1; -} - -extern "C" ssize_t write(int fd, const void *buf, size_t nbytes) -{ - (void) fd; - (void) buf; - (void) nbytes; - errno = ENOSYS; - return -1; -} - -static void dputchar2(char c, void* fd) -{ - write(reinterpret_cast(fd), &c, 1); -} - -static void dputchar(char c, int fd) -{ - write(fd, &c, 1); -} - -extern "C" int dprintf(int fd, const char * format, ...) -{ - va_list args; - va_start(args, format); - const int ret = vfctprintf(dputchar2, reinterpret_cast(fd), format, args); - va_end(args); - return ret; -} - -extern "C" int vdprintf(int fd, const char * format, va_list args) -{ - return vfctprintf(dputchar2, reinterpret_cast(fd), format, args); -} - -extern "C" void putchar_(char c) -{ - dputchar(c, STDIN_FILENO); -} diff --git a/app/platform/stm32f0-gcc/retarget.cpp b/app/platform/stm32f0-gcc/retarget.cpp new file mode 100644 index 0000000..524840e --- /dev/null +++ b/app/platform/stm32f0-gcc/retarget.cpp @@ -0,0 +1,93 @@ +#include "unistd.h" +#include +#include +#include +#include +#include "third_party/printf/printf.h" + +#ifdef errno +#undef errno +#endif + +int errno{}; + +extern "C" [[noreturn]] void vApplicationMallocFailedHook(void) +{ + for (;;); +} + +extern "C" [[noreturn]] void vApplicationStackOverflowHook(void *task_handle, char *task_name) +{ + (void) task_handle; + (void) task_name; + for (;;); +} + +extern "C" void vApplicationIdleHook(void) +{ +} + +extern "C" [[noreturn]] void _exit(int __status) +{ + (void) __status; + for (;;); +} + +/* func can be NULL, in which case no function information is given. */ +extern "C" [[noreturn]] void __assert_func ( + const char *file, int line, const char *func, const char *failedexpr) +{ + dprintf(STDERR_FILENO, + "assertion \"%s\" failed: file \"%s\", line %d%s%s\n", + failedexpr, file, line, + func ? ", function: " : "", func ? func : ""); + abort(); + /* NOTREACHED */ +} + +extern "C" ssize_t read(int fd, void *buf, size_t nbytes) +{ + (void) fd; + (void) buf; + (void) nbytes; + errno = ENOSYS; + return -1; +} + +extern "C" ssize_t write(int fd, const void *buf, size_t nbytes) +{ + (void) fd; + (void) buf; + (void) nbytes; + errno = ENOSYS; + return -1; +} + +static void dputchar2(char c, void* fd) +{ + write(reinterpret_cast(fd), &c, 1); +} + +static void dputchar(char c, int fd) +{ + write(fd, &c, 1); +} + +extern "C" int dprintf(int fd, const char * format, ...) +{ + va_list args; + va_start(args, format); + const int ret = vfctprintf(dputchar2, reinterpret_cast(fd), format, args); + va_end(args); + return ret; +} + +extern "C" int vdprintf(int fd, const char * format, va_list args) +{ + return vfctprintf(dputchar2, reinterpret_cast(fd), format, args); +} + +extern "C" void putchar_(char c) +{ + dputchar(c, STDIN_FILENO); +} -- cgit v1.2.3