wrappers.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "wrappers.h"
  2. #include <stdbool.h>
  3. #include <stdarg.h>
  4. #include <furi/core/check.h>
  5. #include <furi/core/thread.h>
  6. #include <furi/core/common_defines.h>
  7. #include "printf_tiny.h"
  8. void _putchar(char character) {
  9. furi_thread_stdout_write(&character, 1);
  10. }
  11. int __wrap_printf(const char* format, ...) {
  12. va_list args;
  13. va_start(args, format);
  14. int ret = vprintf_(format, args);
  15. va_end(args);
  16. return ret;
  17. }
  18. int __wrap_vsnprintf(char* str, size_t size, const char* format, va_list args) {
  19. return vsnprintf_(str, size, format, args);
  20. }
  21. int __wrap_puts(const char* str) {
  22. size_t size = furi_thread_stdout_write(str, strlen(str));
  23. size += furi_thread_stdout_write("\n", 1);
  24. return size;
  25. }
  26. int __wrap_putchar(int ch) {
  27. size_t size = furi_thread_stdout_write((char*)&ch, 1);
  28. return size;
  29. }
  30. int __wrap_putc(int ch, FILE* stream) {
  31. UNUSED(stream);
  32. size_t size = furi_thread_stdout_write((char*)&ch, 1);
  33. return size;
  34. }
  35. int __wrap_snprintf(char* str, size_t size, const char* format, ...) {
  36. va_list args;
  37. va_start(args, format);
  38. int ret = __wrap_vsnprintf(str, size, format, args);
  39. va_end(args);
  40. return ret;
  41. }
  42. int __wrap_fflush(FILE* stream) {
  43. UNUSED(stream);
  44. furi_thread_stdout_flush();
  45. return 0;
  46. }
  47. __attribute__((__noreturn__)) void __wrap___assert(const char* file, int line, const char* e) {
  48. UNUSED(file);
  49. UNUSED(line);
  50. // TODO: message file and line number
  51. furi_crash(e);
  52. }
  53. __attribute__((__noreturn__)) void
  54. __wrap___assert_func(const char* file, int line, const char* func, const char* e) {
  55. UNUSED(file);
  56. UNUSED(line);
  57. UNUSED(func);
  58. // TODO: message file and line number
  59. furi_crash(e);
  60. }