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 4576C385800E for ; Wed, 2 Mar 2022 01:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4576C385800E 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 D4D97342D37; Wed, 2 Mar 2022 01:36:34 +0000 (UTC) From: Mike Frysinger To: newlib@sourceware.org Subject: [PATCH 6/6] newlib: libc: move stdlib multiplex logic from build to source files Date: Tue, 1 Mar 2022 20:36:23 -0500 Message-Id: <20220302013623.368-7-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.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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:37 -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. 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. Also take the opportunity to clean up the unnecessary header deps in here. Automake provides dependency generation for free now. --- newlib/libc/stdlib/Makefile.am | 92 ++----------- newlib/libc/stdlib/Makefile.in | 230 ++++++++++++++++---------------- newlib/libc/stdlib/callocr.c | 2 + newlib/libc/stdlib/cfreer.c | 2 + newlib/libc/stdlib/freer.c | 2 + newlib/libc/stdlib/malignr.c | 2 + newlib/libc/stdlib/mallinfor.c | 2 + newlib/libc/stdlib/mallocr.c | 2 + newlib/libc/stdlib/malloptr.c | 2 + newlib/libc/stdlib/mallstatsr.c | 2 + newlib/libc/stdlib/msizer.c | 2 + newlib/libc/stdlib/pvallocr.c | 2 + newlib/libc/stdlib/reallocr.c | 2 + newlib/libc/stdlib/vallocr.c | 2 + 14 files changed, 153 insertions(+), 193 deletions(-) create mode 100644 newlib/libc/stdlib/callocr.c create mode 100644 newlib/libc/stdlib/cfreer.c create mode 100644 newlib/libc/stdlib/freer.c create mode 100644 newlib/libc/stdlib/malignr.c create mode 100644 newlib/libc/stdlib/mallinfor.c create mode 100644 newlib/libc/stdlib/mallocr.c create mode 100644 newlib/libc/stdlib/malloptr.c create mode 100644 newlib/libc/stdlib/mallstatsr.c create mode 100644 newlib/libc/stdlib/msizer.c create mode 100644 newlib/libc/stdlib/pvallocr.c create mode 100644 newlib/libc/stdlib/reallocr.c create mode 100644 newlib/libc/stdlib/vallocr.c diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am index cb2fbe850b85..b06b66014b79 100644 --- a/newlib/libc/stdlib/Makefile.am +++ b/newlib/libc/stdlib/Makefile.am @@ -19,6 +19,8 @@ GENERAL_SOURCES = \ atoi.c \ atol.c \ calloc.c \ + callocr.c \ + cfreer.c \ div.c \ dtoa.c \ dtoastub.c \ @@ -26,6 +28,7 @@ GENERAL_SOURCES = \ envlock.c \ eprintf.c \ exit.c \ + freer.c \ gdtoa-gethex.c \ gdtoa-hexnan.c \ getenv.c \ @@ -40,7 +43,10 @@ GENERAL_SOURCES = \ gdtoa-gdtoa.c \ gdtoa-dmisc.c \ gdtoa-gmisc.c \ + mallinfor.c \ malloc.c \ + mallocr.c \ + mallstatsr.c \ mblen.c \ mblen_r.c \ mbstowcs.c \ @@ -49,6 +55,7 @@ GENERAL_SOURCES = \ mbtowc_r.c \ mlock.c \ mprec.c \ + msizer.c \ mstats.c \ on_exit_args.c \ quick_exit.c \ @@ -58,6 +65,7 @@ GENERAL_SOURCES = \ realloc.c \ reallocarray.c \ reallocf.c \ + reallocr.c \ sb_charsets.c \ strtod.c \ strtoimax.c \ @@ -121,24 +129,22 @@ ELIX_2_SOURCES = \ getsubopt.c \ l64a.c \ malign.c \ + malignr.c \ + malloptr.c \ mbrlen.c \ mbrtowc.c \ mbsinit.c \ mbsnrtowcs.c \ mbsrtowcs.c \ on_exit.c \ + pvallocr.c \ valloc.c \ + vallocr.c \ wcrtomb.c \ wcsnrtombs.c \ wcsrtombs.c \ wctob.c -ELIX_2_OBJS = \ - $(lpfx)malignr.o \ - $(lpfx)malloptr.o \ - $(lpfx)pvallocr.o \ - $(lpfx)vallocr.o - ELIX_3_SOURCES = \ putenv.c \ putenv_r.c \ @@ -151,91 +157,19 @@ ELIX_4_SOURCES = \ if ELIX_LEVEL_1 ELIX_SOURCES = -ELIX_OBJS = else if ELIX_LEVEL_2 ELIX_SOURCES = $(ELIX_2_SOURCES) -ELIX_OBJS = $(ELIX_2_OBJS) else if ELIX_LEVEL_3 ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES) -ELIX_OBJS = $(ELIX_2_OBJS) else ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES) $(ELIX_4_SOURCES) -ELIX_OBJS = $(ELIX_2_OBJS) endif 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 - noinst_LIBRARIES = lib.a lib_a_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES) -lib_a_LIBADD = $(LIBADD_OBJS) $(ELIX_OBJS) +lib_a_LIBADD = 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 $< -o $@ - -$(lpfx)freer.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_FREE -c $< -o $@ - -$(lpfx)reallocr.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_REALLOC -c $< -o $@ - -$(lpfx)callocr.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_CALLOC -c $< -o $@ - -$(lpfx)cfreer.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_CFREE -c $< -o $@ - -$(lpfx)malignr.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_MEMALIGN -c $< -o $@ - -$(lpfx)vallocr.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_VALLOC -c $< -o $@ - -$(lpfx)pvallocr.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_PVALLOC -c $< -o $@ - -$(lpfx)mallinfor.o: _mallocr.c - $(LIB_COMPILE) -DDEFINE_MALLINFO -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 $< -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 -$(lpfx)gdtoa-ldtoa.o: gdtoa-ldtoa.c mprec.h gdtoaimp.h gdtoa.h -$(lpfx)gdtoa-gdtoa.o: gdtoa-gdtoa.c mprec.h gdtoaimp.h gdtoa.h -$(lpfx)gdtoa-dmisc.o: gdtoa-dmisc.c mprec.h gdtoaimp.h gdtoa.h -$(lpfx)gdtoa-gmisc.o: gdtoa-gmisc.c mprec.h gdtoaimp.h gdtoa.h -$(lpfx)ecvtbuf.o: ecvtbuf.c mprec.h -$(lpfx)mbtowc_r.o: mbtowc_r.c mbctype.h -$(lpfx)mprec.o: mprec.c mprec.h -$(lpfx)strtod.o: strtod.c mprec.h -$(lpfx)gdtoa-gethex.o: gdtoa-gethex.c mprec.h -$(lpfx)gdtoa-hexnan.o: gdtoa-hexnan.c mprec.h -$(lpfx)wctomb_r.o: wctomb_r.c mbctype.h -$(lpfx)drand48.o: drand48.c rand48.h -$(lpfx)erand48.o: erand48.c rand48.h -$(lpfx)jrand48.o: jrand48.c rand48.h -$(lpfx)lcong48.o: lcong48.c rand48.h -$(lpfx)lrand48.o: lrand48.c rand48.h -$(lpfx)mrand48.o: mrand48.c rand48.h -$(lpfx)nrand48.o: nrand48.c rand48.h -$(lpfx)rand48.o: rand48.c rand48.h -$(lpfx)seed48.o: seed48.c rand48.h -$(lpfx)srand48.o: srand48.c rand48.h diff --git a/newlib/libc/stdlib/callocr.c b/newlib/libc/stdlib/callocr.c new file mode 100644 index 000000000000..80fee60db585 --- /dev/null +++ b/newlib/libc/stdlib/callocr.c @@ -0,0 +1,2 @@ +#define DEFINE_CALLOC +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/cfreer.c b/newlib/libc/stdlib/cfreer.c new file mode 100644 index 000000000000..a644664ae59c --- /dev/null +++ b/newlib/libc/stdlib/cfreer.c @@ -0,0 +1,2 @@ +#define DEFINE_CFREE +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/freer.c b/newlib/libc/stdlib/freer.c new file mode 100644 index 000000000000..1418d0c8f257 --- /dev/null +++ b/newlib/libc/stdlib/freer.c @@ -0,0 +1,2 @@ +#define DEFINE_FREE +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/malignr.c b/newlib/libc/stdlib/malignr.c new file mode 100644 index 000000000000..c48fbad0c4d9 --- /dev/null +++ b/newlib/libc/stdlib/malignr.c @@ -0,0 +1,2 @@ +#define DEFINE_MEMALIGN +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/mallinfor.c b/newlib/libc/stdlib/mallinfor.c new file mode 100644 index 000000000000..dc1a55d9d20a --- /dev/null +++ b/newlib/libc/stdlib/mallinfor.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLINFO +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c new file mode 100644 index 000000000000..c2ab1caadce1 --- /dev/null +++ b/newlib/libc/stdlib/mallocr.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLOC +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/malloptr.c b/newlib/libc/stdlib/malloptr.c new file mode 100644 index 000000000000..f67be247d75b --- /dev/null +++ b/newlib/libc/stdlib/malloptr.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLOPT +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/mallstatsr.c b/newlib/libc/stdlib/mallstatsr.c new file mode 100644 index 000000000000..15cd7379de95 --- /dev/null +++ b/newlib/libc/stdlib/mallstatsr.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLOC_STATS +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/msizer.c b/newlib/libc/stdlib/msizer.c new file mode 100644 index 000000000000..1d683f485027 --- /dev/null +++ b/newlib/libc/stdlib/msizer.c @@ -0,0 +1,2 @@ +#define DEFINE_MALLOC_USABLE_SIZE +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/pvallocr.c b/newlib/libc/stdlib/pvallocr.c new file mode 100644 index 000000000000..afc203860143 --- /dev/null +++ b/newlib/libc/stdlib/pvallocr.c @@ -0,0 +1,2 @@ +#define DEFINE_PVALLOC +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/reallocr.c b/newlib/libc/stdlib/reallocr.c new file mode 100644 index 000000000000..45c21d2d2d7c --- /dev/null +++ b/newlib/libc/stdlib/reallocr.c @@ -0,0 +1,2 @@ +#define DEFINE_REALLOC +#include "_mallocr.c" diff --git a/newlib/libc/stdlib/vallocr.c b/newlib/libc/stdlib/vallocr.c new file mode 100644 index 000000000000..9f05700a4e8f --- /dev/null +++ b/newlib/libc/stdlib/vallocr.c @@ -0,0 +1,2 @@ +#define DEFINE_VALLOC +#include "_mallocr.c" -- 2.34.1