[PATCH 4/6] newlib: xstormy16: break up mallocr stubs

Mike Frysinger vapier@gentoo.org
Wed Mar 2 01:36:21 GMT 2022


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



More information about the Newlib mailing list