forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink_wrapper.c
113 lines (84 loc) · 2.32 KB
/
link_wrapper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* All linker intercepted functions were listed in this file.
*
* Some of them were implemented in newlib nad unable to replace easily,
* some are skipped due to link order.
*/
/****************************************************************************/
#include <stdio.h>
extern int log_write(char * buf, int len);
int __wrap__write(int file, char * ptr, int len)
{
return log_write(ptr, len);
}
/****************************************************************************/
#include "FreeRTOS.h"
#include "task.h"
#include <sys/time.h>
#include <sys/times.h>
int __wrap__gettimeofday(struct timeval * tv, void * ptz)
{
int ticks = xTaskGetTickCount();
if (tv != NULL)
{
tv->tv_sec = (ticks / 1000);
tv->tv_usec = (ticks % 1000) * 1000;
return 0;
}
return -1;
}
/****************************************************************************/
#include <assert.h>
#include <stdio.h>
extern void platform_assert(const char * expr, const char * file, int line);
void __assert_func(const char * file, int line, const char * func, const char * expr)
{
fflush(NULL);
platform_assert(expr, file, line);
while (true)
;
}
/****************************************************************************/
#include <FreeRTOS.h>
#include <assert.h>
#include <stdlib.h>
void * __wrap__calloc_r(size_t nmemb, size_t size)
{
void * p = pvPortCalloc(nmemb, size);
while (!p)
;
return p;
}
void * __wrap__malloc_r(void * REENT, size_t size)
{
void * p = pvPortMalloc(size);
while (!p)
;
return p;
}
void __wrap__free_r(void * REENT, void * ptr)
{
return vPortFree(ptr);
}
void * __wrap__realloc_r(void * REENT, void * ptr, size_t size)
{
void * p = pvPortRealloc(ptr, size);
while (!p)
;
return p;
}
/****************************************************************************/
#include <FreeRTOS.h>
#include <stdlib.h>
extern void mt793xLog(const char * aFormat, ...);
extern void mt793x_wpa_log_cb(void * ctx, int level, int type, const char * txt, size_t len);
void __wrap__wlan_printf(int skip, int level, const char * fmt, ...)
{
va_list ap;
if (skip)
return;
va_start(ap, fmt);
mt793xLog(fmt, ap);
va_end(ap);
}
/****************************************************************************/