[PATCH 5/6] newlib: xstormy16: move malloc multiplex logic from build to source files
Mike Frysinger <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Rather than define per-object rules in the Makefile, have small files that define & include the right content. This simplifies the build rules, and makes understanding the source a little easier (imo) as it makes all the subdirs behave the same: you have 1 source file and it produces 1 object. It's also about the same amount of boiler plate, without having to define custom build rules that can fall out of sync. We also realign the free & pvalloc definitions: common code puts these in malloc.o & valloc.o respectively, not in free.o & pvalloc.o objects. This will also be important as we merge the libc.a build into the top dir since it relies on a single flat list of objects for overrides. --- newlib/libc/machine/xstormy16/Makefile.am | 50 ++--------- newlib/libc/machine/xstormy16/Makefile.in | 101 +++++++++++++--------- newlib/libc/machine/xstormy16/calloc.c | 2 + newlib/libc/machine/xstormy16/cfree.c | 2 + newlib/libc/machine/xstormy16/malign.c | 2 + newlib/libc/machine/xstormy16/malloc.c | 4 + newlib/libc/machine/xstormy16/msize.c | 2 + newlib/libc/machine/xstormy16/realloc.c | 2 + newlib/libc/machine/xstormy16/valloc.c | 4 + 9 files changed, 84 insertions(+), 85 deletions(-) create mode 100644 newlib/libc/machine/xstormy16/calloc.c create mode 100644 newlib/libc/machine/xstormy16/cfree.c create mode 100644 newlib/libc/machine/xstormy16/malign.c create mode 100644 newlib/libc/machine/xstormy16/malloc.c create mode 100644 newlib/libc/machine/xstormy16/msize.c create mode 100644 newlib/libc/machine/xstormy16/realloc.c create mode 100644 newlib/libc/machine/xstormy16/valloc.c diff --git a/newlib/libc/machine/xstormy16/Makefile.am b/newlib/libc/machine/xstormy16/Makefile.am index 842bab9b04ff..d3ada18d76a2 100644 --- a/newlib/libc/machine/xstormy16/Makefile.am +++ b/newlib/libc/machine/xstormy16/Makefile.am @@ -7,50 +7,16 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) noinst_LIBRARIES = lib.a lib_a_SOURCES = setjmp.S \ + calloc.c \ callocr.c \ + cfree.c \ freer.c \ + malign.c \ + malloc.c \ mallocr.c \ + msize.c \ mstats.c \ - reallocr.c + realloc.c \ + reallocr.c \ + valloc.c lib_a_CFLAGS = $(AM_CFLAGS) - -lib_a_LIBADD = $(lpfx)malloc.o \ - $(lpfx)free.o \ - $(lpfx)realloc.o \ - $(lpfx)calloc.o \ - $(lpfx)cfree.o \ - $(lpfx)malign.o \ - $(lpfx)valloc.o \ - $(lpfx)pvalloc.o \ - $(lpfx)msize.o - -lib_a_DEPENDENCIES = $(lib_a_LIBADD) - -MALLOC_COMPILE = $(COMPILE) - -$(lpfx)malloc.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)free.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_FREE -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)realloc.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)calloc.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)cfree.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_CFREE -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)malign.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)valloc.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)pvalloc.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/tiny-malloc.c -o $@ - -$(lpfx)msize.o: tiny-malloc.c - $(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/tiny-malloc.c -o $@ diff --git a/newlib/libc/machine/xstormy16/calloc.c b/newlib/libc/machine/xstormy16/calloc.c new file mode 100644 index 000000000000..46adf7fa2530 --- /dev/null +++ b/newlib/libc/machine/xstormy16/calloc.c @@ -0,0 +1,2 @@ +#define DEFINE_CALLOC +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/cfree.c b/newlib/libc/machine/xstormy16/cfree.c new file mode 100644 index 000000000000..2ab5913678c9 --- /dev/null +++ b/newlib/libc/machine/xstormy16/cfree.c @@ -0,0 +1,2 @@ +#define DEFINE_CFREE +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/malign.c b/newlib/libc/machine/xstormy16/malign.c new file mode 100644 index 000000000000..2daba4104f94 --- /dev/null +++ b/newlib/libc/machine/xstormy16/malign.c @@ -0,0 +1,2 @@ +#define DEFINE_MEMALIGN +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/malloc.c b/newlib/libc/machine/xstormy16/malloc.c new file mode 100644 index 000000000000..f59020142e88 --- /dev/null +++ b/newlib/libc/machine/xstormy16/malloc.c @@ -0,0 +1,4 @@ +/* stdlib/malloc.c defines all these symbols in this file. */ +#define DEFINE_FREE +#define DEFINE_MALLOC +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/msize.c b/newlib/libc/machine/xstormy16/msize.c new file mode 100644 index 000000000000..90b084871a2f --- /dev/null +++ b/newlib/libc/machine/xstormy16/msize.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLOC_USABLE_SIZE +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/realloc.c b/newlib/libc/machine/xstormy16/realloc.c new file mode 100644 index 000000000000..64a29fa2be31 --- /dev/null +++ b/newlib/libc/machine/xstormy16/realloc.c @@ -0,0 +1,2 @@ +#define DEFINE_REALLOC +#include "tiny-malloc.c" diff --git a/newlib/libc/machine/xstormy16/valloc.c b/newlib/libc/machine/xstormy16/valloc.c new file mode 100644 index 000000000000..d6543bc88f3e --- /dev/null +++ b/newlib/libc/machine/xstormy16/valloc.c @@ -0,0 +1,4 @@ +/* stdlib/valloc.c defines all these symbols in this file. */ +#define DEFINE_PVALLOC +#define DEFINE_VALLOC +#include "tiny-malloc.c" -- 2.34.1