From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH 4/6] newlib: xstormy16: break up mallocr stubs
Date: Tue, 1 Mar 2022 20:36:21 -0500 [thread overview]
Message-ID: <20220302013623.368-5-vapier@gentoo.org> (raw)
In-Reply-To: <20220302013623.368-1-vapier@gentoo.org>
Move the multiplex logic out of the build and into source files to
make the build rules a lot simpler.
---
newlib/libc/machine/xstormy16/Makefile.am | 24 +++--------
newlib/libc/machine/xstormy16/Makefile.in | 52 ++++++++++++++---------
newlib/libc/machine/xstormy16/callocr.c | 7 +++
newlib/libc/machine/xstormy16/freer.c | 7 +++
newlib/libc/machine/xstormy16/mallocr.c | 26 ------------
newlib/libc/machine/xstormy16/reallocr.c | 7 +++
6 files changed, 60 insertions(+), 63 deletions(-)
create mode 100644 newlib/libc/machine/xstormy16/callocr.c
create mode 100644 newlib/libc/machine/xstormy16/freer.c
create mode 100644 newlib/libc/machine/xstormy16/reallocr.c
diff --git a/newlib/libc/machine/xstormy16/Makefile.am b/newlib/libc/machine/xstormy16/Makefile.am
index f5237dce3880..842bab9b04ff 100644
--- a/newlib/libc/machine/xstormy16/Makefile.am
+++ b/newlib/libc/machine/xstormy16/Makefile.am
@@ -7,7 +7,11 @@ AM_CCASFLAGS = $(AM_CPPFLAGS)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = setjmp.S \
- mstats.c
+ callocr.c \
+ freer.c \
+ mallocr.c \
+ mstats.c \
+ reallocr.c
lib_a_CFLAGS = $(AM_CFLAGS)
lib_a_LIBADD = $(lpfx)malloc.o \
@@ -18,11 +22,7 @@ lib_a_LIBADD = $(lpfx)malloc.o \
$(lpfx)malign.o \
$(lpfx)valloc.o \
$(lpfx)pvalloc.o \
- $(lpfx)msize.o \
- $(lpfx)mallocr.o \
- $(lpfx)freer.o \
- $(lpfx)reallocr.o \
- $(lpfx)callocr.o
+ $(lpfx)msize.o
lib_a_DEPENDENCIES = $(lib_a_LIBADD)
@@ -54,15 +54,3 @@ $(lpfx)pvalloc.o: tiny-malloc.c
$(lpfx)msize.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/tiny-malloc.c -o $@
-
-$(lpfx)mallocr.o: mallocr.c
- $(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/mallocr.c -o $@
-
-$(lpfx)freer.o: mallocr.c
- $(MALLOC_COMPILE) -DDEFINE_FREE -c $(srcdir)/mallocr.c -o $@
-
-$(lpfx)reallocr.o: mallocr.c
- $(MALLOC_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/mallocr.c -o $@
-
-$(lpfx)callocr.o: mallocr.c
- $(MALLOC_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/mallocr.c -o $@
diff --git a/newlib/libc/machine/xstormy16/callocr.c b/newlib/libc/machine/xstormy16/callocr.c
new file mode 100644
index 000000000000..3e5053c67650
--- /dev/null
+++ b/newlib/libc/machine/xstormy16/callocr.c
@@ -0,0 +1,7 @@
+#include <malloc.h>
+
+void *
+_calloc_r (struct _reent *r, size_t a, size_t b)
+{
+ return calloc (a, b);
+}
diff --git a/newlib/libc/machine/xstormy16/freer.c b/newlib/libc/machine/xstormy16/freer.c
new file mode 100644
index 000000000000..f79ef55495af
--- /dev/null
+++ b/newlib/libc/machine/xstormy16/freer.c
@@ -0,0 +1,7 @@
+#include <malloc.h>
+
+void
+_free_r (struct _reent *r, void *x)
+{
+ free (x);
+}
diff --git a/newlib/libc/machine/xstormy16/mallocr.c b/newlib/libc/machine/xstormy16/mallocr.c
index 07be5303979d..d54df0bdf115 100644
--- a/newlib/libc/machine/xstormy16/mallocr.c
+++ b/newlib/libc/machine/xstormy16/mallocr.c
@@ -1,33 +1,7 @@
#include <malloc.h>
-#ifdef DEFINE_MALLOC
void *
_malloc_r (struct _reent *r, size_t sz)
{
return malloc (sz);
}
-#endif
-
-#ifdef DEFINE_CALLOC
-void *
-_calloc_r (struct _reent *r, size_t a, size_t b)
-{
- return calloc (a, b);
-}
-#endif
-
-#ifdef DEFINE_FREE
-void
-_free_r (struct _reent *r, void *x)
-{
- free (x);
-}
-#endif
-
-#ifdef DEFINE_REALLOC
-void *
-_realloc_r (struct _reent *r, void *x, size_t sz)
-{
- return realloc (x, sz);
-}
-#endif
diff --git a/newlib/libc/machine/xstormy16/reallocr.c b/newlib/libc/machine/xstormy16/reallocr.c
new file mode 100644
index 000000000000..2bf538557b06
--- /dev/null
+++ b/newlib/libc/machine/xstormy16/reallocr.c
@@ -0,0 +1,7 @@
+#include <malloc.h>
+
+void *
+_realloc_r (struct _reent *r, void *x, size_t sz)
+{
+ return realloc (x, sz);
+}
--
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 to source files 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 ` Mike Frysinger [this message]
2022-03-02 1:36 ` [PATCH 5/6] newlib: xstormy16: move malloc multiplex logic from build to source files Mike Frysinger
2022-03-02 1:36 ` [PATCH 6/6] newlib: libc: move stdlib " 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-5-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).