Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
C Howland <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CANk6obSUdbBNdLeM5P=MAmoqTb_n0tw3KdPGejMCOU8QQsEL+w@mail.gmail.com> |
On Tue, 15 Mar 2022 at 11:44, Joel Sherrill <[email protected]> wrote: > > > On Tue, Mar 15, 2022, 10:38 AM C Howland <[email protected]> wrote: > >> > >> > ------------------------------ >> > *From:* Newlib <[email protected]> >> on >> > behalf of Joel Sherrill <[email protected]> >> > *Sent:* Tuesday, March 15, 2022 11:16 AM >> > *To:* [email protected] <[email protected]> >> > *Subject:* [PATCH newlib] libc/include/malloc.h: Add prototype for GNU >> > extension malloc_usable_size() >> > >> > >> > 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 >> > + >> > /* A compatibility routine for an earlier version of the allocator. */ >> > >> > extern void mstats (char *); >> > -- >> > 2.24.4 >> > >> > >> Sorry, but I fail to see why adding this makes sense. If there's an >> application which adds a function they should be editing the header file >> when they add it. (There's not even a stub being supplied here.) >> Additionally, the Linux man page for the function says "The main use of >> this function is for debugging and introspection." That is, it is not >> even >> a general application utility, but of very limited use. Either provide >> the >> function with the prototype or no prototype. >> > > RTEMS provides its own malloc family implementation and we are providing > it. I can wrap all that in an RTEMS conditional if you like. > > I have no experience with the malloc implementation in Newlib or any idea > how to implement it. > > --joel > RTEMS wrapper is good. (Sorry, but you didn't mention you were providing it in RTEMS, although in hindsight I should have assumed so when wording my response.) No reason to try to retrofit it to the Newlib implementation. Craig