From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH 5/6] newlib: xstormy16: move malloc multiplex logic from build to source files
Date: Tue, 1 Mar 2022 20:36:22 -0500 [thread overview]
Message-ID: <20220302013623.368-6-vapier@gentoo.org> (raw)
In-Reply-To: <20220302013623.368-1-vapier@gentoo.org>
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
next prev parent reply other threads:[~2022-03-02 1:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 1:36 [PATCH 0/6] rework malloc logic from build rules " Mike Frysinger
2022-03-02 1:36 ` [PATCH 1/6] newlib: move nano-malloc logic from build " Mike Frysinger
2022-03-02 1:36 ` [PATCH 2/6] newlib: rename mallocr.c to _mallocr.c Mike Frysinger
2022-03-02 1:36 ` [PATCH 3/6] newlib: xstormy16: fix mallopt definition & mstats handling Mike Frysinger
2022-03-02 9:46 ` Corinna Vinschen
2022-03-09 9:23 ` Mike Frysinger
2022-03-10 8:12 ` Corinna Vinschen
2022-03-10 8:00 ` Sebastian Huber
2022-03-02 1:36 ` [PATCH 4/6] newlib: xstormy16: break up mallocr stubs Mike Frysinger
2022-03-02 1:36 ` Mike Frysinger [this message]
2022-03-02 1:36 ` [PATCH 6/6] newlib: libc: move stdlib multiplex logic from build to source files Mike Frysinger
2022-03-02 9:47 ` [PATCH 0/6] rework malloc logic from build rules " Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220302013623.368-6-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).