* [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
@ 2022-03-15 15:16 Joel Sherrill
[not found] ` <BN2P110MB1544D6E89DF3E9BB09EC091D9A109@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
2022-03-15 15:47 ` Mike Frysinger
0 siblings, 2 replies; 10+ messages in thread
From: Joel Sherrill @ 2022-03-15 15:16 UTC (permalink / raw)
To: newlib
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
[not found] ` <BN2P110MB1544D6E89DF3E9BB09EC091D9A109@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
@ 2022-03-15 15:38 ` C Howland
2022-03-15 15:44 ` Joel Sherrill
0 siblings, 1 reply; 10+ messages in thread
From: C Howland @ 2022-03-15 15:38 UTC (permalink / raw)
To: newlib
>
> ------------------------------
> *From:* Newlib <newlib-bounces+craig.howland=caci.com@sourceware.org> on
> behalf of Joel Sherrill <joel@rtems.org>
> *Sent:* Tuesday, March 15, 2022 11:16 AM
> *To:* newlib@sourceware.org <newlib@sourceware.org>
> *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.
Craig
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 15:38 ` C Howland
@ 2022-03-15 15:44 ` Joel Sherrill
2022-03-15 15:54 ` C Howland
0 siblings, 1 reply; 10+ messages in thread
From: Joel Sherrill @ 2022-03-15 15:44 UTC (permalink / raw)
To: C Howland; +Cc: Newlib
On Tue, Mar 15, 2022, 10:38 AM C Howland <cc1964t@gmail.com> wrote:
> >
> > ------------------------------
> > *From:* Newlib <newlib-bounces+craig.howland=caci.com@sourceware.org> on
> > behalf of Joel Sherrill <joel@rtems.org>
> > *Sent:* Tuesday, March 15, 2022 11:16 AM
> > *To:* newlib@sourceware.org <newlib@sourceware.org>
> > *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
> Craig
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 15:16 [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size() Joel Sherrill
[not found] ` <BN2P110MB1544D6E89DF3E9BB09EC091D9A109@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
@ 2022-03-15 15:47 ` Mike Frysinger
2022-03-15 18:42 ` Sebastian Huber
1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2022-03-15 15:47 UTC (permalink / raw)
To: Joel Sherrill; +Cc: newlib
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
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 ?
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 15:44 ` Joel Sherrill
@ 2022-03-15 15:54 ` C Howland
0 siblings, 0 replies; 10+ messages in thread
From: C Howland @ 2022-03-15 15:54 UTC (permalink / raw)
To: newlib
On Tue, 15 Mar 2022 at 11:44, Joel Sherrill <joel@rtems.org> wrote:
>
>
> On Tue, Mar 15, 2022, 10:38 AM C Howland <cc1964t@gmail.com> wrote:
>
>> >
>> > ------------------------------
>> > *From:* Newlib <newlib-bounces+craig.howland=caci.com@sourceware.org>
>> on
>> > behalf of Joel Sherrill <joel@rtems.org>
>> > *Sent:* Tuesday, March 15, 2022 11:16 AM
>> > *To:* newlib@sourceware.org <newlib@sourceware.org>
>> > *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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 15:47 ` Mike Frysinger
@ 2022-03-15 18:42 ` Sebastian Huber
2022-03-15 20:36 ` Mike Frysinger
2022-03-15 20:54 ` Joel Sherrill
0 siblings, 2 replies; 10+ messages in thread
From: Sebastian Huber @ 2022-03-15 18:42 UTC (permalink / raw)
To: Joel Sherrill, newlib
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.
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 18:42 ` Sebastian Huber
@ 2022-03-15 20:36 ` Mike Frysinger
2022-03-15 21:14 ` Joel Sherrill
2022-03-15 20:54 ` Joel Sherrill
1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2022-03-15 20:36 UTC (permalink / raw)
To: Sebastian Huber; +Cc: Joel Sherrill, newlib
[-- Attachment #1: Type: text/plain, Size: 1404 bytes --]
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 ...
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.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 18:42 ` Sebastian Huber
2022-03-15 20:36 ` Mike Frysinger
@ 2022-03-15 20:54 ` Joel Sherrill
2022-03-15 23:50 ` Mike Frysinger
1 sibling, 1 reply; 10+ messages in thread
From: Joel Sherrill @ 2022-03-15 20:54 UTC (permalink / raw)
To: Sebastian Huber; +Cc: Newlib
On Tue, Mar 15, 2022, 1:43 PM Sebastian Huber <
sebastian.huber@embedded-brains.de> 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.
>
Thanks Sebastian. Good catch.
The prototype isn't wrapped by __GNU_VISIBLE. Should it be?
--joel
>
> --
> embedded brains GmbH
> Herr Sebastian HUBER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email: sebastian.huber@embedded-brains.de
> phone: +49-89-18 94 741 - 16
> fax: +49-89-18 94 741 - 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRB 157899
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 20:36 ` Mike Frysinger
@ 2022-03-15 21:14 ` Joel Sherrill
0 siblings, 0 replies; 10+ messages in thread
From: Joel Sherrill @ 2022-03-15 21:14 UTC (permalink / raw)
To: Sebastian Huber, Joel Sherrill, Newlib
On Tue, Mar 15, 2022 at 4:04 PM Mike Frysinger <vapier@gentoo.org> 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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size()
2022-03-15 20:54 ` Joel Sherrill
@ 2022-03-15 23:50 ` Mike Frysinger
0 siblings, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2022-03-15 23:50 UTC (permalink / raw)
To: Joel Sherrill; +Cc: Sebastian Huber, Newlib
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
On 15 Mar 2022 15:54, Joel Sherrill wrote:
> The prototype isn't wrapped by __GNU_VISIBLE. Should it be?
we're talking about malloc.h here. this is already a non-standard header.
the standard malloc APIs are defined in stdlib.h:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
so i'm not sure how much value there is annotating standards in a header
that is not in any standard, and whose inclusion clearly declares "i am
not conforming to any standards".
we could put a disclaimer/explanation at the top of the header file to
make this a bit more clear.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-03-15 23:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 15:16 [PATCH newlib] libc/include/malloc.h: Add prototype for GNU extension malloc_usable_size() Joel Sherrill
[not found] ` <BN2P110MB1544D6E89DF3E9BB09EC091D9A109@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
2022-03-15 15:38 ` C Howland
2022-03-15 15:44 ` Joel Sherrill
2022-03-15 15:54 ` C Howland
2022-03-15 15:47 ` Mike Frysinger
2022-03-15 18:42 ` Sebastian Huber
2022-03-15 20:36 ` Mike Frysinger
2022-03-15 21:14 ` Joel Sherrill
2022-03-15 20:54 ` Joel Sherrill
2022-03-15 23:50 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).