link_wrapper.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * All linker intercepted functions were listed in this file.
  3. *
  4. * Some of them were implemented in newlib nad unable to replace easily,
  5. * some are skipped due to link order.
  6. */
  7. /****************************************************************************/
  8. #include <stdio.h>
  9. extern int log_write(char * buf, int len);
  10. int __wrap__write(int file, char * ptr, int len)
  11. {
  12. return log_write(ptr, len);
  13. }
  14. /****************************************************************************/
  15. #include "FreeRTOS.h"
  16. #include "task.h"
  17. #include <sys/time.h>
  18. #include <sys/times.h>
  19. int __wrap__gettimeofday(struct timeval * tv, void * ptz)
  20. {
  21. int ticks = xTaskGetTickCount();
  22. if (tv != NULL)
  23. {
  24. tv->tv_sec = (ticks / 1000);
  25. tv->tv_usec = (ticks % 1000) * 1000;
  26. return 0;
  27. }
  28. return -1;
  29. }
  30. /****************************************************************************/
  31. #include <assert.h>
  32. #include <stdio.h>
  33. extern void platform_assert(const char * expr, const char * file, int line);
  34. void __assert_func(const char * file, int line, const char * func, const char * expr)
  35. {
  36. fflush(NULL);
  37. platform_assert(expr, file, line);
  38. while (true)
  39. ;
  40. }
  41. /****************************************************************************/
  42. #include <FreeRTOS.h>
  43. #include <assert.h>
  44. #include <stdlib.h>
  45. void * __wrap__calloc_r(size_t nmemb, size_t size)
  46. {
  47. void * p = pvPortCalloc(nmemb, size);
  48. while (!p)
  49. ;
  50. return p;
  51. }
  52. void * __wrap__malloc_r(void * REENT, size_t size)
  53. {
  54. void * p = pvPortMalloc(size);
  55. while (!p)
  56. ;
  57. return p;
  58. }
  59. void __wrap__free_r(void * REENT, void * ptr)
  60. {
  61. return vPortFree(ptr);
  62. }
  63. void * __wrap__realloc_r(void * REENT, void * ptr, size_t size)
  64. {
  65. void * p = pvPortRealloc(ptr, size);
  66. while (!p)
  67. ;
  68. return p;
  69. }
  70. /****************************************************************************/
  71. #include <FreeRTOS.h>
  72. #include <stdlib.h>
  73. extern void mt793xLog(const char * aFormat, ...);
  74. extern void mt793x_wpa_log_cb(void * ctx, int level, int type, const char * txt, size_t len);
  75. void __wrap__wlan_printf(int skip, int level, const char * fmt, ...)
  76. {
  77. va_list ap;
  78. if (skip)
  79. return;
  80. va_start(ap, fmt);
  81. mt793xLog(fmt, ap);
  82. va_end(ap);
  83. }
  84. /****************************************************************************/