You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/07/14 18:10:07 UTC

[incubator-nuttx] branch master updated: add #undef for some libc function

This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new def007e  add #undef for some libc function
def007e is described below

commit def007e2d76ae196f85c71315fa6d73ecda52f95
Author: mage1 <ma...@xiaomi.com>
AuthorDate: Wed Apr 14 15:43:16 2021 +0800

    add #undef for some libc function
    
    since it's useful to redirect these functions to others
    sometime(e.g. validate the memory before write).
    
    Change-Id: I6253a9231af8809e8362f4bc5a1bd67fb094c3b0
---
 include/strings.h                     |  8 ++++++++
 libs/libc/stdlib/lib_aligned_alloc.c  |  1 +
 libs/libc/stdlib/lib_atoi.c           |  1 +
 libs/libc/stdlib/lib_atol.c           |  1 +
 libs/libc/stdlib/lib_posix_memalign.c |  1 +
 libs/libc/stdlib/lib_valloc.c         |  1 +
 libs/libc/string/lib_index.c          |  1 +
 libs/libc/string/lib_memccpy.c        |  1 +
 libs/libc/string/lib_memchr.c         |  1 +
 libs/libc/string/lib_memcmp.c         |  1 +
 libs/libc/string/lib_memcpy.c         |  1 +
 libs/libc/string/lib_memmove.c        |  1 +
 libs/libc/string/lib_memset.c         |  1 +
 libs/libc/string/lib_rindex.c         |  1 +
 libs/libc/string/lib_strcasecmp.c     |  1 +
 libs/libc/string/lib_strcat.c         |  1 +
 libs/libc/string/lib_strchr.c         |  1 +
 libs/libc/string/lib_strcmp.c         |  1 +
 libs/libc/string/lib_strcpy.c         |  1 +
 libs/libc/string/lib_strcspn.c        |  1 +
 libs/libc/string/lib_strdup.c         |  1 +
 libs/libc/string/lib_strlen.c         |  1 +
 libs/libc/string/lib_strncasecmp.c    |  1 +
 libs/libc/string/lib_strncat.c        |  1 +
 libs/libc/string/lib_strncmp.c        |  1 +
 libs/libc/string/lib_strncpy.c        |  1 +
 libs/libc/string/lib_strndup.c        |  1 +
 libs/libc/string/lib_strpbrk.c        |  1 +
 libs/libc/string/lib_strrchr.c        |  1 +
 libs/libc/string/lib_strspn.c         |  1 +
 libs/libc/string/lib_strstr.c         |  1 +
 libs/libc/string/lib_strtok.c         |  1 +
 mm/README.txt                         | 35 +++++++++++++++++++++++++++++++++++
 mm/umm_heap/umm_calloc.c              |  1 +
 mm/umm_heap/umm_free.c                |  1 +
 mm/umm_heap/umm_malloc.c              |  1 +
 mm/umm_heap/umm_malloc_size.c         |  1 +
 mm/umm_heap/umm_memalign.c            |  1 +
 mm/umm_heap/umm_realloc.c             |  1 +
 mm/umm_heap/umm_zalloc.c              |  1 +
 40 files changed, 81 insertions(+)

diff --git a/include/strings.h b/include/strings.h
index 7096bca..2ceba61 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -41,9 +41,17 @@
  * IEEE Std 1003.1-2008
  */
 
+#ifndef bcmp /* See mm/README.txt */
 #define bcmp(b1,b2,len)  memcmp(b1,b2,(size_t)len)
+#endif
+
+#ifndef bcopy /* See mm/README.txt */
 #define bcopy(b1,b2,len) (void)memmove(b2,b1,len)
+#endif
+
+#ifndef bzero /* See mm/README.txt */
 #define bzero(s,n)       (void)memset(s,0,n)
+#endif
 
 /****************************************************************************
  * Inline Functions
diff --git a/libs/libc/stdlib/lib_aligned_alloc.c b/libs/libc/stdlib/lib_aligned_alloc.c
index ee02506..53bcebc 100644
--- a/libs/libc/stdlib/lib_aligned_alloc.c
+++ b/libs/libc/stdlib/lib_aligned_alloc.c
@@ -30,6 +30,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef aligned_alloc /* See mm/README.txt */
 FAR void *aligned_alloc(size_t align, size_t size)
 {
   return lib_memalign(align, size);
diff --git a/libs/libc/stdlib/lib_atoi.c b/libs/libc/stdlib/lib_atoi.c
index 916dec7..4181464 100644
--- a/libs/libc/stdlib/lib_atoi.c
+++ b/libs/libc/stdlib/lib_atoi.c
@@ -28,6 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef atoi /* See mm/README.txt */
 int atoi(FAR const char *nptr)
 {
   return strtol(nptr, NULL, 10);
diff --git a/libs/libc/stdlib/lib_atol.c b/libs/libc/stdlib/lib_atol.c
index e3f2064..d1d6ba8 100644
--- a/libs/libc/stdlib/lib_atol.c
+++ b/libs/libc/stdlib/lib_atol.c
@@ -28,6 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef atol /* See mm/README.txt */
 long atol(FAR const char *nptr)
 {
   return strtol(nptr, NULL, 10);
diff --git a/libs/libc/stdlib/lib_posix_memalign.c b/libs/libc/stdlib/lib_posix_memalign.c
index f7fea99..f4f8e5e 100644
--- a/libs/libc/stdlib/lib_posix_memalign.c
+++ b/libs/libc/stdlib/lib_posix_memalign.c
@@ -31,6 +31,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef posix_memalign /* See mm/README.txt */
 int posix_memalign(FAR void **mem, size_t align, size_t size)
 {
   *mem = lib_memalign(align, size);
diff --git a/libs/libc/stdlib/lib_valloc.c b/libs/libc/stdlib/lib_valloc.c
index fa16ccc..1c72cf7 100644
--- a/libs/libc/stdlib/lib_valloc.c
+++ b/libs/libc/stdlib/lib_valloc.c
@@ -49,6 +49,7 @@
  *
  ****************************************************************************/
 
+#undef valloc /* See mm/README.txt */
 FAR void *valloc(size_t size)
 {
   return lib_memalign(sysconf(_SC_PAGESIZE), size);
diff --git a/libs/libc/string/lib_index.c b/libs/libc/string/lib_index.c
index 94f43f3..e62745c 100644
--- a/libs/libc/string/lib_index.c
+++ b/libs/libc/string/lib_index.c
@@ -32,6 +32,7 @@
  * Name: index
  ****************************************************************************/
 
+#undef index /* See mm/README.txt */
 FAR char *index(FAR const char *s, int c)
 {
   return strchr(s, c);
diff --git a/libs/libc/string/lib_memccpy.c b/libs/libc/string/lib_memccpy.c
index 6b82152..e9f1773 100644
--- a/libs/libc/string/lib_memccpy.c
+++ b/libs/libc/string/lib_memccpy.c
@@ -46,6 +46,7 @@
  *
  ****************************************************************************/
 
+#undef memccpy /* See mm/README.txt */
 FAR void *memccpy(FAR void *s1, FAR const void *s2, int c, size_t n)
 {
   FAR unsigned char *pout = (FAR unsigned char *)s1;
diff --git a/libs/libc/string/lib_memchr.c b/libs/libc/string/lib_memchr.c
index 51b9c23..ec96b1c 100644
--- a/libs/libc/string/lib_memchr.c
+++ b/libs/libc/string/lib_memchr.c
@@ -44,6 +44,7 @@
  *
  ****************************************************************************/
 
+#undef memchr /* See mm/README.txt */
 FAR void *memchr(FAR const void *s, int c, size_t n)
 {
   FAR const unsigned char *p = (FAR const unsigned char *)s;
diff --git a/libs/libc/string/lib_memcmp.c b/libs/libc/string/lib_memcmp.c
index 2191859..1f788f4 100644
--- a/libs/libc/string/lib_memcmp.c
+++ b/libs/libc/string/lib_memcmp.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_MEMCMP
+#undef memcmp /* See mm/README.txt */
 int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
 {
   unsigned char *p1 = (unsigned char *)s1;
diff --git a/libs/libc/string/lib_memcpy.c b/libs/libc/string/lib_memcpy.c
index d40bcc6..de4f8ee 100644
--- a/libs/libc/string/lib_memcpy.c
+++ b/libs/libc/string/lib_memcpy.c
@@ -35,6 +35,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_MEMCPY
+#undef memcpy /* See mm/README.txt */
 FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n)
 {
   FAR unsigned char *pout = (FAR unsigned char *)dest;
diff --git a/libs/libc/string/lib_memmove.c b/libs/libc/string/lib_memmove.c
index 17dfc13..bc72a85 100644
--- a/libs/libc/string/lib_memmove.c
+++ b/libs/libc/string/lib_memmove.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_MEMMOVE
+#undef memmove /* See mm/README.txt */
 FAR void *memmove(FAR void *dest, FAR const void *src, size_t count)
 {
   FAR char *tmp;
diff --git a/libs/libc/string/lib_memset.c b/libs/libc/string/lib_memset.c
index 961843a..e22a6cd 100644
--- a/libs/libc/string/lib_memset.c
+++ b/libs/libc/string/lib_memset.c
@@ -47,6 +47,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_MEMSET
+#undef memset /* See mm/README.txt */
 FAR void *memset(FAR void *s, int c, size_t n)
 {
 #ifdef CONFIG_MEMSET_OPTSPEED
diff --git a/libs/libc/string/lib_rindex.c b/libs/libc/string/lib_rindex.c
index b59513b..2375ee0 100644
--- a/libs/libc/string/lib_rindex.c
+++ b/libs/libc/string/lib_rindex.c
@@ -32,6 +32,7 @@
  * Name: rindex
  ****************************************************************************/
 
+#undef rindex /* See mm/README.txt */
 FAR char *rindex(FAR const char *s, int c)
 {
   return strrchr(s, c);
diff --git a/libs/libc/string/lib_strcasecmp.c b/libs/libc/string/lib_strcasecmp.c
index 1cf59fe..e02fddd 100644
--- a/libs/libc/string/lib_strcasecmp.c
+++ b/libs/libc/string/lib_strcasecmp.c
@@ -32,6 +32,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_ARCH_STRCASECMP
+#undef strcasecmp /* See mm/README.txt */
 int strcasecmp(FAR const char *cs, FAR const char *ct)
 {
   int result;
diff --git a/libs/libc/string/lib_strcat.c b/libs/libc/string/lib_strcat.c
index 06f6fef..beb23e2 100644
--- a/libs/libc/string/lib_strcat.c
+++ b/libs/libc/string/lib_strcat.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_ARCH_STRCAT
+#undef strcat /* See mm/README.txt */
 char *strcat(char *dest, const char *src)
 {
   char *ret   = dest;
diff --git a/libs/libc/string/lib_strchr.c b/libs/libc/string/lib_strchr.c
index 81182b7..7da3bf9 100644
--- a/libs/libc/string/lib_strchr.c
+++ b/libs/libc/string/lib_strchr.c
@@ -45,6 +45,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_STRCHR
+#undef strchr /* See mm/README.txt */
 FAR char *strchr(FAR const char *s, int c)
 {
   if (s)
diff --git a/libs/libc/string/lib_strcmp.c b/libs/libc/string/lib_strcmp.c
index 15da7a8..2ac4f62 100644
--- a/libs/libc/string/lib_strcmp.c
+++ b/libs/libc/string/lib_strcmp.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_STRCMP
+#undef strcmp /* See mm/README.txt */
 int strcmp(FAR const char *cs, FAR const char *ct)
 {
   register signed char result;
diff --git a/libs/libc/string/lib_strcpy.c b/libs/libc/string/lib_strcpy.c
index f40fe60..d66dc7e 100644
--- a/libs/libc/string/lib_strcpy.c
+++ b/libs/libc/string/lib_strcpy.c
@@ -43,6 +43,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_STRCPY
+#undef strcpy /* See mm/README.txt */
 FAR char *strcpy(FAR char *dest, FAR const char *src)
 {
   char *tmp = dest;
diff --git a/libs/libc/string/lib_strcspn.c b/libs/libc/string/lib_strcspn.c
index 5f25035..7a8211e 100644
--- a/libs/libc/string/lib_strcspn.c
+++ b/libs/libc/string/lib_strcspn.c
@@ -39,6 +39,7 @@
  *
  ****************************************************************************/
 
+#undef strcspn /* See mm/README.txt */
 size_t strcspn(const char *s, const char *reject)
 {
   size_t i;
diff --git a/libs/libc/string/lib_strdup.c b/libs/libc/string/lib_strdup.c
index 82c42db..9e548bc 100644
--- a/libs/libc/string/lib_strdup.c
+++ b/libs/libc/string/lib_strdup.c
@@ -32,6 +32,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef strdup /* See mm/README.txt */
 FAR char *strdup(FAR const char *s)
 {
   FAR char *news = NULL;
diff --git a/libs/libc/string/lib_strlen.c b/libs/libc/string/lib_strlen.c
index c559257..647c6d0 100644
--- a/libs/libc/string/lib_strlen.c
+++ b/libs/libc/string/lib_strlen.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_STRLEN
+#undef strlen /* See mm/README.txt */
 size_t strlen(const char *s)
 {
   const char *sc;
diff --git a/libs/libc/string/lib_strncasecmp.c b/libs/libc/string/lib_strncasecmp.c
index 9a2cb52..2b3ac6b 100644
--- a/libs/libc/string/lib_strncasecmp.c
+++ b/libs/libc/string/lib_strncasecmp.c
@@ -33,6 +33,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_ARCH_STRNCASECMP
+#undef strncasecmp /* See mm/README.txt */
 int strncasecmp(const char *cs, const char *ct, size_t nb)
 {
   int result = 0;
diff --git a/libs/libc/string/lib_strncat.c b/libs/libc/string/lib_strncat.c
index c9cf3ef..cc68ea1 100644
--- a/libs/libc/string/lib_strncat.c
+++ b/libs/libc/string/lib_strncat.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_ARCH_STRNCAT
+#undef strncat /* See mm/README.txt */
 char *strncat(char *dest, const char *src, size_t n)
 {
   char *ret   = dest;
diff --git a/libs/libc/string/lib_strncmp.c b/libs/libc/string/lib_strncmp.c
index 8d9b512..117f1fd 100644
--- a/libs/libc/string/lib_strncmp.c
+++ b/libs/libc/string/lib_strncmp.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_ARCH_STRNCMP
+#undef strncmp /* See mm/README.txt */
 int strncmp(const char *cs, const char *ct, size_t nb)
 {
   int result = 0;
diff --git a/libs/libc/string/lib_strncpy.c b/libs/libc/string/lib_strncpy.c
index 90acbad..1a7cf58 100644
--- a/libs/libc/string/lib_strncpy.c
+++ b/libs/libc/string/lib_strncpy.c
@@ -52,6 +52,7 @@
  ****************************************************************************/
 
 #ifndef CONFIG_LIBC_ARCH_STRNCPY
+#undef strncpy /* See mm/README.txt */
 FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
 {
   FAR char *ret = dest;     /* Value to be returned */
diff --git a/libs/libc/string/lib_strndup.c b/libs/libc/string/lib_strndup.c
index 07b124e..d6b0313 100644
--- a/libs/libc/string/lib_strndup.c
+++ b/libs/libc/string/lib_strndup.c
@@ -49,6 +49,7 @@
  *
  ****************************************************************************/
 
+#undef strndup /* See mm/README.txt */
 FAR char *strndup(FAR const char *s, size_t size)
 {
   FAR char *news = NULL;
diff --git a/libs/libc/string/lib_strpbrk.c b/libs/libc/string/lib_strpbrk.c
index 1f3ca0e..90e56a8 100644
--- a/libs/libc/string/lib_strpbrk.c
+++ b/libs/libc/string/lib_strpbrk.c
@@ -30,6 +30,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef strpbrk /* See mm/README.txt */
 FAR char *strpbrk(FAR const char *str, FAR const char *charset)
 {
   /* Sanity checking */
diff --git a/libs/libc/string/lib_strrchr.c b/libs/libc/string/lib_strrchr.c
index 80b6d7d..9e5e4c8 100644
--- a/libs/libc/string/lib_strrchr.c
+++ b/libs/libc/string/lib_strrchr.c
@@ -34,6 +34,7 @@
  * occurrence of the character c in the string s.
  */
 
+#undef strrchr /* See mm/README.txt */
 FAR char *strrchr(FAR const char *s, int c)
 {
   if (s)
diff --git a/libs/libc/string/lib_strspn.c b/libs/libc/string/lib_strspn.c
index ee88d50..65443e0 100644
--- a/libs/libc/string/lib_strspn.c
+++ b/libs/libc/string/lib_strspn.c
@@ -39,6 +39,7 @@
  *
  ****************************************************************************/
 
+#undef strspn /* See mm/README.txt */
 size_t strspn(const char *s, const char *accept)
 {
   size_t i;
diff --git a/libs/libc/string/lib_strstr.c b/libs/libc/string/lib_strstr.c
index a9c7f9a..d8ee9f2 100644
--- a/libs/libc/string/lib_strstr.c
+++ b/libs/libc/string/lib_strstr.c
@@ -30,6 +30,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef strstr /* See mm/README.txt */
 FAR char *strstr(FAR const char *str, FAR const char *substr)
 {
   FAR const char *candidate; /* Candidate in str with matching start character */
diff --git a/libs/libc/string/lib_strtok.c b/libs/libc/string/lib_strtok.c
index 4556d0e..7822943 100644
--- a/libs/libc/string/lib_strtok.c
+++ b/libs/libc/string/lib_strtok.c
@@ -66,6 +66,7 @@ static char *g_saveptr = NULL;
  *
  ****************************************************************************/
 
+#undef strtok /* See mm/README.txt */
 char *strtok(char *str, const char *delim)
 {
   return strtok_r(str, delim, &g_saveptr);
diff --git a/mm/README.txt b/mm/README.txt
index 8c2856a..5607cbb 100644
--- a/mm/README.txt
+++ b/mm/README.txt
@@ -74,6 +74,41 @@ This directory contains the NuttX memory management logic.  This include:
      mm/umm_heap - Holds the user-mode memory allocation interfaces
      mm/kmm_heap - Holds the kernel-mode memory allocation interfaces
 
+   Debugging:
+
+    Please follow these steps to hook all memory related routines:
+
+    1.Add a new header file(e.g. xxx_malloc.h):
+
+      ...
+      #include <malloc.h>
+      #include <stdlib.h>
+      #include <string.h>
+      #include <strings.h>
+
+      #ifndef __ASSEMBLY__
+      FAR void *xxx_malloc(FAR const char *file, int line, size_t size);
+      void xxx_free(FAR const char *file, int line, FAR const void *ptr);
+      FAR void *xxx_memcpy(FAR const char *file, int line,
+                           FAR void *dst, FAR const void *src, size_t len);
+      ...
+      #define malloc(s) xxx_malloc(__FILE__, __LINE__, s)
+      #define free(p) xxx_free(__FILE__, __LINE__, p)
+      #define memcpy(d, s, l) xxx_memcpy(__FILE__, __LINE__, d, s, l)
+      ...
+      #endif
+      ...
+
+    2.Implement xxx_malloc, xxx_free, xxx_memcpy... in source code, you can:
+      a.Modify some arguments(e.g. extend the allocation size for redzone)
+      d.Check the critical arguments(e.g. pointer and length) in the range 
+      b.Forward to the original implementation(call malloc/free/memcpy)
+      c.Attach the context info(e.g. file and line) before return
+
+    3.Enable the hook by either:
+      a.Include xxx_malloc.h in your source code to hook one file
+      b.Add -include xxx_malloc.h to CFLAGS to hook all source code
+
 2) Granule Allocator.
 
      A non-standard granule allocator is also available in this directory  The
diff --git a/mm/umm_heap/umm_calloc.c b/mm/umm_heap/umm_calloc.c
index d10142b..69eadb7 100644
--- a/mm/umm_heap/umm_calloc.c
+++ b/mm/umm_heap/umm_calloc.c
@@ -42,6 +42,7 @@
  *
  ****************************************************************************/
 
+#undef calloc /* See mm/README.txt */
 FAR void *calloc(size_t n, size_t elem_size)
 {
 #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
diff --git a/mm/umm_heap/umm_free.c b/mm/umm_heap/umm_free.c
index fca7060..ebdf952 100644
--- a/mm/umm_heap/umm_free.c
+++ b/mm/umm_heap/umm_free.c
@@ -43,6 +43,7 @@
  *
  ****************************************************************************/
 
+#undef free /* See mm/README.txt */
 void free(FAR void *mem)
 {
   mm_free(USR_HEAP, mem);
diff --git a/mm/umm_heap/umm_malloc.c b/mm/umm_heap/umm_malloc.c
index 1906eb1..261f0d8 100644
--- a/mm/umm_heap/umm_malloc.c
+++ b/mm/umm_heap/umm_malloc.c
@@ -49,6 +49,7 @@
  *
  ****************************************************************************/
 
+#undef malloc /* See mm/README.txt */
 FAR void *malloc(size_t size)
 {
 #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
diff --git a/mm/umm_heap/umm_malloc_size.c b/mm/umm_heap/umm_malloc_size.c
index 74c0e76..c095e6b 100644
--- a/mm/umm_heap/umm_malloc_size.c
+++ b/mm/umm_heap/umm_malloc_size.c
@@ -32,6 +32,7 @@
  * Public Functions
  ****************************************************************************/
 
+#undef malloc_size /* See mm/README.txt */
 size_t malloc_size(FAR void *mem)
 {
   return mm_malloc_size(mem);
diff --git a/mm/umm_heap/umm_memalign.c b/mm/umm_heap/umm_memalign.c
index 1a0f4d0..9181b34 100644
--- a/mm/umm_heap/umm_memalign.c
+++ b/mm/umm_heap/umm_memalign.c
@@ -48,6 +48,7 @@
  *
  ****************************************************************************/
 
+#undef memalign /* See mm/README.txt */
 FAR void *memalign(size_t alignment, size_t size)
 {
 #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
diff --git a/mm/umm_heap/umm_realloc.c b/mm/umm_heap/umm_realloc.c
index 6466a03..a320a33 100644
--- a/mm/umm_heap/umm_realloc.c
+++ b/mm/umm_heap/umm_realloc.c
@@ -50,6 +50,7 @@
  *
  ****************************************************************************/
 
+#undef realloc /* See mm/README.txt */
 FAR void *realloc(FAR void *oldmem, size_t size)
 {
 #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
diff --git a/mm/umm_heap/umm_zalloc.c b/mm/umm_heap/umm_zalloc.c
index 4c367f1..11a7ba0 100644
--- a/mm/umm_heap/umm_zalloc.c
+++ b/mm/umm_heap/umm_zalloc.c
@@ -49,6 +49,7 @@
  *
  ****************************************************************************/
 
+#undef zalloc /* See mm/README.txt */
 FAR void *zalloc(size_t size)
 {
 #ifdef CONFIG_ARCH_ADDRENV