Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
Joel Sherrill <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAF9ehCWc5W04rMXU0aWrJgo+u_kpUv7eZBoxiHukbCaaVnDWpg@mail.gmail.com> |
On Tue, Mar 15, 2022 at 4:04 PM Mike Frysinger <[email protected]> wrote: > On 15 Mar 2022 19:42, Sebastian Huber wrote: > > On 15/03/2022 16:47, Mike Frysinger wrote: > > > On 15 Mar 2022 10:16, Joel Sherrill wrote: > > >> This is not provided by the newlib malloc implementation but may > > >> be available in external implementations. > > >> --- > > >> newlib/libc/include/malloc.h | 4 ++++ > > >> 1 file changed, 4 insertions(+) > > >> > > >> diff --git a/newlib/libc/include/malloc.h > b/newlib/libc/include/malloc.h > > >> index a9dc5bca6..e73095e1e 100644 > > >> --- a/newlib/libc/include/malloc.h > > >> +++ b/newlib/libc/include/malloc.h > > >> @@ -137,6 +137,10 @@ extern void __malloc_lock(struct _reent *); > > >> > > >> extern void __malloc_unlock(struct _reent *); > > >> > > >> +#if __GNU_VISIBLE > > >> +extern size_t malloc_usable_size(void *); > > >> +#endif > > >> + > > > i'm confused. isn't this prototype already defined in this header file > > > on line 101 above where you added this ? > > > > Yes, and it is implemented by the Newlib malloc. > > while true, we disable malloc in newlib for rtems: > > newlib/configure.host: > # RTEMS supplies its own versions of some routines: > # malloc() (reentrant version) > #... > *-*-rtems*) > ... > newlib_cflags="${newlib_cflags} ... -DMALLOC_PROVIDED ... > We disable their implementation -- not the malloc.h header. > > so i'm not sure what trouble Joel is running into. maybe rtems also > provides > its own malloc.h and that's what is missing this prototype. > I was reviewing the submitted code which added malloc_usable_size to RTEMS. It also added the prototype to an RTEMS internal file. I took it on faith that the prototype was missing and looked at the Linux man page for where the prototype should be. Then I just stupidly missed it. Their code should have include malloc.h and not an internal RTEMS file. Sorry and thanks. --joel -mike >