[PATCH 3/6] newlib: xstormy16: fix mallopt definition & mstats handling

Mike Frysinger vapier@gentoo.org
Wed Mar 9 09:23:45 GMT 2022


On 02 Mar 2022 10:46, Corinna Vinschen wrote:
> On Mar  1 20:36, Mike Frysinger wrote:
> > The mallopt symbol is defined in tiny-malloc.c, not mallocr.c, but
> > the Makefile in here tries to compile it out of the latter.  This
> > leads to mallopt never being defined.
> > 
> > The build also creates mallinfo.o & mallopt.o & mallstats.o objects
> > to override common ones, but the common dir doesn't use these names.
> > Instead, it places these all in mstats.o.
> > 
> > So move the build define logic to a dedicated file and compile it
> > directly to make things a bit simpler while fixing the missing func
> > and aligning objects with the cmomon code.
> > ---
> >  newlib/libc/machine/xstormy16/Makefile.am | 15 ++--------
> >  newlib/libc/machine/xstormy16/Makefile.in | 36 +++++++++++++----------
> >  newlib/libc/machine/xstormy16/mstats.c    |  6 ++++
> >  3 files changed, 29 insertions(+), 28 deletions(-)
> >  create mode 100644 newlib/libc/machine/xstormy16/mstats.c
> > [...]
> > diff --git a/newlib/libc/machine/xstormy16/mstats.c b/newlib/libc/machine/xstormy16/mstats.c
> > new file mode 100644
> > index 000000000000..1bd24da555f1
> > --- /dev/null
> > +++ b/newlib/libc/machine/xstormy16/mstats.c
> > @@ -0,0 +1,6 @@
> > +/* stdlib/mstats.c defines all these symbols in this file.
> > +   TODO: Missing mstats function.  */
> > +#define DEFINE_MALLINFO
> > +#define DEFINE_MALLOC_STATS
> > +#define DEFINE_MALLOPT
> > +#include "tiny-malloc.c"
> 
> XStormy16 is such a small target, it would be better to split these into
> three files.

it must be really tiny if we need to micro manage this.
    152       0       0     152      98 lib_a-mallinfo.o
    274       0       0     274     112 lib_a-mallstats.o
      4       0       0       4       4 lib_a-mallopt.o

the only way they'd get pulled in is if one func is used, so if code called
mallopt() but not mallinfo() or malloc_stats(), it would waste 426 bytes.

the point of this change is to align xstormy16 with how common code is laid
out.  are you suggesting we split the common mstats.c too ?  it wouldn't be
hard as that file is pretty small.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20220309/24f5460e/attachment.sig>


More information about the Newlib mailing list