Skip to content

Commit 8fb74f4

Browse files
niklarmPatater
authored andcommitted
uVisor: Wrap _memalign_r and _calloc_r
1 parent 778d682 commit 8fb74f4

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

platform/mbed_alloc_wrappers.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats)
8080

8181
extern "C" {
8282
void * __real__malloc_r(struct _reent * r, size_t size);
83+
void * __real__memalign_r(struct _reent * r, size_t alignment, size_t bytes);
8384
void * __real__realloc_r(struct _reent * r, void * ptr, size_t size);
8485
void __real__free_r(struct _reent * r, void * ptr);
8586
void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size);
@@ -178,8 +179,6 @@ extern "C" void __wrap__free_r(struct _reent * r, void * ptr) {
178179
#endif // #ifdef MBED_MEM_TRACING_ENABLED
179180
}
180181

181-
#endif // if !defined(FEATURE_UVISOR)
182-
183182
extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) {
184183
void *ptr = NULL;
185184
#ifdef MBED_HEAP_STATS_ENABLED
@@ -200,6 +199,12 @@ extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size)
200199
return ptr;
201200
}
202201

202+
extern "C" void * __wrap__memalign_r(struct _reent * r, size_t alignment, size_t bytes) {
203+
return __real__memalign_r(r, alignment, bytes);
204+
}
205+
206+
#endif // if !defined(FEATURE_UVISOR)
207+
203208

204209
/******************************************************************************/
205210
/* ARMCC memory allocation wrappers */

tools/profiles/debug.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"c": ["-std=gnu99"],
1212
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
1313
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
14-
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r",
14+
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1515
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
1616
"-Wl,-n"]
1717
},

tools/profiles/develop.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"c": ["-std=gnu99"],
1111
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
1212
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
13-
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r",
13+
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1414
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
1515
"-Wl,-n"]
1616
},

tools/profiles/release.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"c": ["-std=gnu99"],
1111
"cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"],
1212
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
13-
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r",
13+
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1414
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
1515
"-Wl,-n"]
1616
},

0 commit comments

Comments
 (0)