From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 0E80B385841C for ; Wed, 2 Mar 2022 01:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0E80B385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 9F2F8342D37; Wed, 2 Mar 2022 01:36:32 +0000 (UTC) From: Mike Frysinger 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 Message-Id: <20220302013623.368-6-vapier@gentoo.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302013623.368-1-vapier@gentoo.org> References: <20220302013623.368-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2022 01:36:34 -0000 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