public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Michael Frysinger <vapier@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] newlib: move nano-malloc logic from build to source files
Date: Wed,  9 Mar 2022 09:43:58 +0000 (GMT)	[thread overview]
Message-ID: <20220309094358.63ED13858D28@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d7b16b0576e0b1b9915d7b572c60e3e58d3614ea

commit d7b16b0576e0b1b9915d7b572c60e3e58d3614ea
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Mon Feb 28 23:46:52 2022 -0500

    newlib: move nano-malloc logic from build to source files
    
    Simplify the build system logic a bit by moving the mallocr.c ->
    nano-mallocr.c redirection from the Makefile to the source files.
    This allows for consistent object name usage regardless of the
    configuration options used in case a machine dir wants to define
    its own override.

Diff:
---
 newlib/libc/stdlib/Makefile.am | 92 +++++++++++++++---------------------------
 newlib/libc/stdlib/Makefile.in | 88 +++++++++++++++-------------------------
 newlib/libc/stdlib/mallocr.c   |  3 ++
 3 files changed, 67 insertions(+), 116 deletions(-)

diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am
index 50e22d90c..950ad98ac 100644
--- a/newlib/libc/stdlib/Makefile.am
+++ b/newlib/libc/stdlib/Makefile.am
@@ -83,34 +83,6 @@ GENERAL_SOURCES += \
 	wcstold.c
 endif # HAVE_LONG_DOUBLE
 
-if NEWLIB_NANO_MALLOC
-MALIGNR=nano-malignr
-MALLOPTR=nano-malloptr
-PVALLOCR=nano-pvallocr
-VALLOCR=nano-vallocr
-FREER=nano-freer
-REALLOCR=nano-reallocr
-CALLOCR=nano-callocr
-CFREER=nano-cfreer
-MALLINFOR=nano-mallinfor
-MALLSTATSR=nano-mallstatsr
-MSIZER=nano-msizer
-MALLOCR=nano-mallocr
-else
-MALIGNR=malignr
-MALLOPTR=malloptr
-PVALLOCR=pvallocr
-VALLOCR=vallocr
-FREER=freer
-REALLOCR=reallocr
-CALLOCR=callocr
-CFREER=cfreer
-MALLINFOR=mallinfor
-MALLSTATSR=mallstatsr
-MSIZER=msizer
-MALLOCR=mallocr
-endif
-
 EXTENDED_SOURCES = \
 	arc4random.c	\
 	arc4random_uniform.c \
@@ -162,10 +134,10 @@ ELIX_2_SOURCES = \
 	wctob.c
 
 ELIX_2_OBJS = \
-	$(lpfx)$(MALIGNR).o	\
-	$(lpfx)$(MALLOPTR).o \
-	$(lpfx)$(PVALLOCR).o	\
-	$(lpfx)$(VALLOCR).o
+	$(lpfx)malignr.o	\
+	$(lpfx)malloptr.o \
+	$(lpfx)pvallocr.o	\
+	$(lpfx)vallocr.o
 
 ELIX_3_SOURCES = \
 	putenv.c	\
@@ -196,10 +168,10 @@ endif
 endif
 
 # Because of how libtool moves objects around, mallocr must be built last.
-LIBADD_OBJS = $(lpfx)$(FREER).o $(lpfx)$(REALLOCR).o \
-	$(lpfx)$(CALLOCR).o $(lpfx)$(CFREER).o \
-	$(lpfx)$(MALLINFOR).o $(lpfx)$(MALLSTATSR).o \
-	$(lpfx)$(MSIZER).o $(lpfx)$(MALLOCR).o
+LIBADD_OBJS = $(lpfx)freer.o $(lpfx)reallocr.o \
+	$(lpfx)callocr.o $(lpfx)cfreer.o \
+	$(lpfx)mallinfor.o $(lpfx)mallstatsr.o \
+	$(lpfx)msizer.o $(lpfx)mallocr.o
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
@@ -208,41 +180,41 @@ lib_a_CFLAGS = $(AM_CFLAGS)
 lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
 LIB_COMPILE = $(AM_V_CC)$(COMPILE)
 
-$(lpfx)$(MALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC -c $< -o $@
 
-$(lpfx)$(FREER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_FREE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)freer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_FREE -c $< -o $@
 
-$(lpfx)$(REALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)reallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_REALLOC -c $< -o $@
 
-$(lpfx)$(CALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)callocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_CALLOC -c $< -o $@
 
-$(lpfx)$(CFREER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_CFREE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)cfreer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_CFREE -c $< -o $@
 
-$(lpfx)$(MALIGNR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)malignr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MEMALIGN -c $< -o $@
 
-$(lpfx)$(VALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)vallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_VALLOC -c $< -o $@
 
-$(lpfx)$(PVALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)pvallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_PVALLOC -c $< -o $@
 
-$(lpfx)$(MALLINFOR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallinfor.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLINFO -c $< -o $@
 
-$(lpfx)$(MALLSTATSR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallstatsr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC_STATS -c $< -o $@
 
-$(lpfx)$(MSIZER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)msizer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $< -o $@
 
-$(lpfx)$(MALLOPTR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)malloptr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOPT -c $< -o $@
 
 $(lpfx)dtoa.o: dtoa.c mprec.h
 $(lpfx)ldtoa.o: ldtoa.c mprec.h gdtoa.h
diff --git a/newlib/libc/stdlib/Makefile.in b/newlib/libc/stdlib/Makefile.in
index 9b873ef55..b201e0555 100644
--- a/newlib/libc/stdlib/Makefile.in
+++ b/newlib/libc/stdlib/Makefile.in
@@ -402,30 +402,6 @@ GENERAL_SOURCES = __adjust.c __atexit.c __call_atexit.c __exp10.c \
 	strtoimax.c strtol.c strtoul.c strtoumax.c utoa.c wcstod.c \
 	wcstoimax.c wcstol.c wcstoul.c wcstoumax.c wcstombs.c \
 	wcstombs_r.c wctomb.c wctomb_r.c $(am__append_1)
-@NEWLIB_NANO_MALLOC_FALSE@MALIGNR = malignr
-@NEWLIB_NANO_MALLOC_TRUE@MALIGNR = nano-malignr
-@NEWLIB_NANO_MALLOC_FALSE@MALLOPTR = malloptr
-@NEWLIB_NANO_MALLOC_TRUE@MALLOPTR = nano-malloptr
-@NEWLIB_NANO_MALLOC_FALSE@PVALLOCR = pvallocr
-@NEWLIB_NANO_MALLOC_TRUE@PVALLOCR = nano-pvallocr
-@NEWLIB_NANO_MALLOC_FALSE@VALLOCR = vallocr
-@NEWLIB_NANO_MALLOC_TRUE@VALLOCR = nano-vallocr
-@NEWLIB_NANO_MALLOC_FALSE@FREER = freer
-@NEWLIB_NANO_MALLOC_TRUE@FREER = nano-freer
-@NEWLIB_NANO_MALLOC_FALSE@REALLOCR = reallocr
-@NEWLIB_NANO_MALLOC_TRUE@REALLOCR = nano-reallocr
-@NEWLIB_NANO_MALLOC_FALSE@CALLOCR = callocr
-@NEWLIB_NANO_MALLOC_TRUE@CALLOCR = nano-callocr
-@NEWLIB_NANO_MALLOC_FALSE@CFREER = cfreer
-@NEWLIB_NANO_MALLOC_TRUE@CFREER = nano-cfreer
-@NEWLIB_NANO_MALLOC_FALSE@MALLINFOR = mallinfor
-@NEWLIB_NANO_MALLOC_TRUE@MALLINFOR = nano-mallinfor
-@NEWLIB_NANO_MALLOC_FALSE@MALLSTATSR = mallstatsr
-@NEWLIB_NANO_MALLOC_TRUE@MALLSTATSR = nano-mallstatsr
-@NEWLIB_NANO_MALLOC_FALSE@MSIZER = msizer
-@NEWLIB_NANO_MALLOC_TRUE@MSIZER = nano-msizer
-@NEWLIB_NANO_MALLOC_FALSE@MALLOCR = mallocr
-@NEWLIB_NANO_MALLOC_TRUE@MALLOCR = nano-mallocr
 EXTENDED_SOURCES = \
 	arc4random.c	\
 	arc4random_uniform.c \
@@ -477,10 +453,10 @@ ELIX_2_SOURCES = \
 	wctob.c
 
 ELIX_2_OBJS = \
-	$(lpfx)$(MALIGNR).o	\
-	$(lpfx)$(MALLOPTR).o \
-	$(lpfx)$(PVALLOCR).o	\
-	$(lpfx)$(VALLOCR).o
+	$(lpfx)malignr.o	\
+	$(lpfx)malloptr.o \
+	$(lpfx)pvallocr.o	\
+	$(lpfx)vallocr.o
 
 ELIX_3_SOURCES = \
 	putenv.c	\
@@ -502,10 +478,10 @@ ELIX_4_SOURCES = \
 @ELIX_LEVEL_1_TRUE@ELIX_OBJS = 
 
 # Because of how libtool moves objects around, mallocr must be built last.
-LIBADD_OBJS = $(lpfx)$(FREER).o $(lpfx)$(REALLOCR).o \
-	$(lpfx)$(CALLOCR).o $(lpfx)$(CFREER).o \
-	$(lpfx)$(MALLINFOR).o $(lpfx)$(MALLSTATSR).o \
-	$(lpfx)$(MSIZER).o $(lpfx)$(MALLOCR).o
+LIBADD_OBJS = $(lpfx)freer.o $(lpfx)reallocr.o \
+	$(lpfx)callocr.o $(lpfx)cfreer.o \
+	$(lpfx)mallinfor.o $(lpfx)mallstatsr.o \
+	$(lpfx)msizer.o $(lpfx)mallocr.o
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
@@ -1499,41 +1475,41 @@ uninstall-am:
 .PRECIOUS: Makefile
 
 
-$(lpfx)$(MALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC -c $< -o $@
 
-$(lpfx)$(FREER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_FREE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)freer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_FREE -c $< -o $@
 
-$(lpfx)$(REALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)reallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_REALLOC -c $< -o $@
 
-$(lpfx)$(CALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)callocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_CALLOC -c $< -o $@
 
-$(lpfx)$(CFREER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_CFREE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)cfreer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_CFREE -c $< -o $@
 
-$(lpfx)$(MALIGNR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)malignr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MEMALIGN -c $< -o $@
 
-$(lpfx)$(VALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)vallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_VALLOC -c $< -o $@
 
-$(lpfx)$(PVALLOCR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)pvallocr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_PVALLOC -c $< -o $@
 
-$(lpfx)$(MALLINFOR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallinfor.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLINFO -c $< -o $@
 
-$(lpfx)$(MALLSTATSR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)mallstatsr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC_STATS -c $< -o $@
 
-$(lpfx)$(MSIZER).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)msizer.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $< -o $@
 
-$(lpfx)$(MALLOPTR).o: $(MALLOCR).c
-	$(LIB_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/$(MALLOCR).c -o $@
+$(lpfx)malloptr.o: mallocr.c
+	$(LIB_COMPILE) -DDEFINE_MALLOPT -c $< -o $@
 
 $(lpfx)dtoa.o: dtoa.c mprec.h
 $(lpfx)ldtoa.o: ldtoa.c mprec.h gdtoa.h
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index 6167433c8..4b53997a3 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -1,5 +1,8 @@
+#include <newlib.h>
 #ifdef MALLOC_PROVIDED
 int _dummy_mallocr = 1;
+#elif defined(_NANO_MALLOC)
+# include "nano-mallocr.c"
 #else
 /* ---------- To make a malloc.h, start cutting here ------------ */


                 reply	other threads:[~2022-03-09  9:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220309094358.63ED13858D28@sourceware.org \
    --to=vapier@sourceware.org \
    --cc=newlib-cvs@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).