wrappers.c 1.7 KB

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