You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/07/13 13:46:20 UTC

[GitHub] [incubator-nuttx] gustavonihei edited a comment on pull request #4124: add #undef for some libc function

gustavonihei edited a comment on pull request #4124:
URL: https://github.com/apache/incubator-nuttx/pull/4124#issuecomment-879100326


   > --wrap is a gcc specific feature, even clang doesn't support yet:
   > https://stackoverflow.com/questions/31476632/what-is-the-equivalent-of-gnus-wrap-linker-flag-in-os-x-linker
   > And then violate https://github.com/apache/incubator-nuttx/blob/master/INVIOLABLES.md:
   
   Good point. I was unaware that LLVM's Linker did not implement it.
   
   @xiaoxiang781216 Have you considered renaming the standard functions as `nx_<function>` (e.g. `nx_malloc`) and defining `<function>` as a weak symbol when `CONFIG_MM_DEBUG` is enabled? Then the weak `malloc` by default only calls `nx_malloc` and any available checkers could simply provide a `malloc` implementation. Something like:
   ```c
   #ifdef CONFIG_MM_DEBUG
   weak_function FAR void *malloc(size_t size)
   {
     return nx_malloc(size);
   }
   
   FAR void *nx_malloc(size_t size)
   #else
   FAR void *malloc(size_t size)
   {
     /* Default implementation */
   }
   #endif
   ```
   
   This approach would have the advantage of being explicit of what this is intending to achieve, but at the cost of performing this mass renaming of target functions.
   That was I was referring to when I said that we wouldn't need to rely on the preprocessor.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org