|
Packit |
6c4009 |
# Copyright (C) 1991-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
# This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
# Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
# License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
# <http://www.gnu.org/licenses/>.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#
|
|
Packit |
6c4009 |
# Makefile for malloc routines
|
|
Packit |
6c4009 |
#
|
|
Packit |
6c4009 |
subdir := malloc
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include ../Makeconfig
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
dist-headers := malloc.h
|
|
Packit |
6c4009 |
headers := $(dist-headers) obstack.h mcheck.h
|
|
Packit |
6c4009 |
tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
|
|
Packit |
6c4009 |
tst-mcheck tst-mallocfork tst-trim1 \
|
|
Packit |
6c4009 |
tst-malloc-usable tst-realloc tst-reallocarray tst-posix_memalign \
|
|
Packit |
6c4009 |
tst-pvalloc tst-memalign tst-mallopt \
|
|
Packit |
6c4009 |
tst-malloc-backtrace tst-malloc-thread-exit \
|
|
Packit |
6c4009 |
tst-malloc-thread-fail tst-malloc-fork-deadlock \
|
|
Packit |
6c4009 |
tst-mallocfork2 \
|
|
Packit |
6c4009 |
tst-interpose-nothread \
|
|
Packit |
6c4009 |
tst-interpose-thread \
|
|
Packit |
6c4009 |
tst-alloc_buffer \
|
|
Packit |
6c4009 |
tst-malloc-tcache-leak \
|
|
Packit |
6c4009 |
tst-malloc_info \
|
|
Packit |
6c4009 |
tst-malloc-too-large \
|
|
Packit |
6c4009 |
tst-malloc-stats-cancellation \
|
|
Packit Service |
7494cb |
tst-tcfree1 tst-tcfree2 tst-tcfree3 \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tests-static := \
|
|
Packit |
6c4009 |
tst-interpose-static-nothread \
|
|
Packit |
6c4009 |
tst-interpose-static-thread \
|
|
Packit |
6c4009 |
tst-malloc-usable-static \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tests-internal := tst-mallocstate tst-scratch_buffer
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The dynarray framework is only available inside glibc.
|
|
Packit |
6c4009 |
tests-internal += \
|
|
Packit |
6c4009 |
tst-dynarray \
|
|
Packit |
6c4009 |
tst-dynarray-fail \
|
|
Packit |
6c4009 |
tst-dynarray-at-fail \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifneq (no,$(have-tunables))
|
|
Packit Service |
6de65a |
tests += tst-malloc-usable-tunables
|
|
Packit |
6c4009 |
tests-static += tst-malloc-usable-static-tunables
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tests += $(tests-static)
|
|
Packit |
6c4009 |
test-srcs = tst-mtrace
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
routines = malloc morecore mcheck mtrace obstack reallocarray \
|
|
Packit |
6c4009 |
scratch_buffer_grow scratch_buffer_grow_preserve \
|
|
Packit |
6c4009 |
scratch_buffer_set_array_size \
|
|
Packit |
6c4009 |
dynarray_at_failure \
|
|
Packit |
6c4009 |
dynarray_emplace_enlarge \
|
|
Packit |
6c4009 |
dynarray_finalize \
|
|
Packit |
6c4009 |
dynarray_resize \
|
|
Packit |
6c4009 |
dynarray_resize_clear \
|
|
Packit |
6c4009 |
alloc_buffer_alloc_array \
|
|
Packit |
6c4009 |
alloc_buffer_allocate \
|
|
Packit |
6c4009 |
alloc_buffer_copy_bytes \
|
|
Packit |
6c4009 |
alloc_buffer_copy_string \
|
|
Packit |
6c4009 |
alloc_buffer_create_failure \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
install-lib := libmcheck.a
|
|
Packit |
6c4009 |
non-lib.a := libmcheck.a
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Additional library.
|
|
Packit |
6c4009 |
extra-libs = libmemusage
|
|
Packit |
6c4009 |
extra-libs-others = $(extra-libs)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Helper objects for some tests.
|
|
Packit |
6c4009 |
extra-tests-objs += \
|
|
Packit |
6c4009 |
tst-interpose-aux-nothread.o \
|
|
Packit |
6c4009 |
tst-interpose-aux-thread.o \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
test-extras = \
|
|
Packit |
6c4009 |
tst-interpose-aux-nothread \
|
|
Packit |
6c4009 |
tst-interpose-aux-thread \
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
libmemusage-routines = memusage
|
|
Packit |
6c4009 |
libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-backtrace: $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-thread-exit: $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-thread-fail: $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-fork-deadlock: $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-stats-cancellation: $(shared-thread-library)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Export the __malloc_initialize_hook variable to libc.so.
|
|
Packit |
6c4009 |
LDFLAGS-tst-mallocstate = -rdynamic
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# These should be removed by `make clean'.
|
|
Packit |
6c4009 |
extra-objs = mcheck-init.o libmcheck.a
|
|
Packit |
6c4009 |
others-extras = mcheck-init.o
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Include the cleanup handler.
|
|
Packit |
6c4009 |
aux := set-freeres thread-freeres
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The Perl script to analyze the output of the mtrace functions.
|
|
Packit |
6c4009 |
ifneq ($(PERL),no)
|
|
Packit |
6c4009 |
install-bin-script = mtrace
|
|
Packit |
6c4009 |
generated += mtrace
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The Perl script will print addresses and to do this nicely we must know
|
|
Packit |
6c4009 |
# whether we are on a 32 or 64 bit machine.
|
|
Packit |
6c4009 |
ifneq ($(findstring wordsize-32,$(config-sysdirs)),)
|
|
Packit |
6c4009 |
address-width=10
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
address-width=18
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Unless we get a test for the availability of libgd which also works
|
|
Packit |
6c4009 |
# for cross-compiling we disable the memusagestat generation in this
|
|
Packit |
6c4009 |
# situation.
|
|
Packit |
6c4009 |
ifneq ($(cross-compiling),yes)
|
|
Packit |
6c4009 |
# If the gd library is available we build the `memusagestat' program.
|
|
Packit |
6c4009 |
ifneq ($(LIBGD),no)
|
|
Packit |
6c4009 |
others: $(objpfx)memusage
|
|
Packit |
6c4009 |
install-bin = memusagestat
|
|
Packit |
6c4009 |
install-bin-script += memusage
|
|
Packit |
6c4009 |
generated += memusagestat memusage
|
|
Packit |
6c4009 |
extra-objs += memusagestat.o
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The configure.ac check for libgd and its headers did not use $SYSINCLUDES.
|
|
Packit |
6c4009 |
# The directory specified by --with-headers usually contains only the basic
|
|
Packit |
6c4009 |
# kernel interface headers, not something like libgd. So the simplest thing
|
|
Packit |
6c4009 |
# is to presume that the standard system headers will be ok for this file.
|
|
Packit |
6c4009 |
$(objpfx)memusagestat.o: sysincludes = # nothing
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Another goal which can be used to override the configure decision.
|
|
Packit |
6c4009 |
.PHONY: do-memusagestat
|
|
Packit |
6c4009 |
do-memusagestat: $(objpfx)memusagestat
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
memusagestat-modules = memusagestat
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
cpp-srcs-left := $(memusagestat-modules)
|
|
Packit |
6c4009 |
lib := memusagestat
|
|
Packit |
6c4009 |
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
|
|
Packit |
6c4009 |
|
|
Packit Service |
6de65a |
$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
|
|
Packit Service |
6de65a |
$(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(run-built-tests),yes)
|
|
Packit |
6c4009 |
ifeq (yes,$(build-shared))
|
|
Packit |
6c4009 |
ifneq ($(PERL),no)
|
|
Packit |
6c4009 |
tests-special += $(objpfx)tst-mtrace.out
|
|
Packit |
6c4009 |
tests-special += $(objpfx)tst-dynarray-mem.out
|
|
Packit |
6c4009 |
tests-special += $(objpfx)tst-dynarray-fail-mem.out
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
include ../Rules
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
CFLAGS-mcheck-init.c += $(PIC-ccflag)
|
|
Packit |
6c4009 |
CFLAGS-obstack.c += $(uses-callbacks)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
|
|
Packit |
6c4009 |
-rm -f $@
|
|
Packit |
6c4009 |
$(patsubst %/,cd % &&,$(objpfx)) \
|
|
Packit |
6c4009 |
$(LN_S) $(
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
lib: $(objpfx)libmcheck.a
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(run-built-tests),yes)
|
|
Packit |
6c4009 |
ifeq (yes,$(build-shared))
|
|
Packit |
6c4009 |
ifneq ($(PERL),no)
|
|
Packit |
6c4009 |
$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
|
|
Packit |
6c4009 |
$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
|
|
Packit |
6c4009 |
'$(run-program-env)' '$(test-program-prefix-after-env)' > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tst-mcheck-ENV = MALLOC_CHECK_=3
|
|
Packit |
6c4009 |
tst-malloc-usable-ENV = MALLOC_CHECK_=3
|
|
Packit |
6c4009 |
tst-malloc-usable-static-ENV = $(tst-malloc-usable-ENV)
|
|
Packit |
6c4009 |
tst-malloc-usable-tunables-ENV = GLIBC_TUNABLES=glibc.malloc.check=3
|
|
Packit |
6c4009 |
tst-malloc-usable-static-tunables-ENV = $(tst-malloc-usable-tunables-ENV)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ifeq ($(experimental-malloc),yes)
|
|
Packit |
6c4009 |
CPPFLAGS-malloc.c += -DUSE_TCACHE=1
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
CPPFLAGS-malloc.c += -DUSE_TCACHE=0
|
|
Packit |
6c4009 |
endif
|
|
Packit |
6c4009 |
# Uncomment this for test releases. For public releases it is too expensive.
|
|
Packit |
6c4009 |
#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)mtrace: mtrace.pl
|
|
Packit |
6c4009 |
rm -f $@.new
|
|
Packit |
6c4009 |
sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
|
|
Packit |
6c4009 |
-e 's|@VERSION@|$(version)|' \
|
|
Packit |
6c4009 |
-e 's|@PKGVERSION@|$(PKGVERSION)|' \
|
|
Packit |
6c4009 |
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
|
|
Packit |
6c4009 |
&& rm -f $@ && mv $@.new $@ && chmod +x $@
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)memusage: memusage.sh
|
|
Packit |
6c4009 |
rm -f $@.new
|
|
Packit |
6c4009 |
sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
|
|
Packit |
6c4009 |
-e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
|
|
Packit |
6c4009 |
-e 's|@PKGVERSION@|$(PKGVERSION)|' \
|
|
Packit |
6c4009 |
-e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
|
|
Packit |
6c4009 |
&& rm -f $@ && mv $@.new $@ && chmod +x $@
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The implementation uses `dlsym'
|
|
Packit |
6c4009 |
$(objpfx)libmemusage.so: $(libdl)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Extra dependencies
|
|
Packit |
6c4009 |
$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Compile the tests with a flag which suppresses the mallopt call in
|
|
Packit |
6c4009 |
# the test skeleton.
|
|
Packit |
6c4009 |
$(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-nothread: $(objpfx)tst-interpose-aux-nothread.o
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-thread: \
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-static-nothread: $(objpfx)tst-interpose-aux-nothread.o
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-static-thread: \
|
|
Packit |
6c4009 |
$(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tst-dynarray-ENV = MALLOC_TRACE=$(objpfx)tst-dynarray.mtrace
|
|
Packit |
6c4009 |
$(objpfx)tst-dynarray-mem.out: $(objpfx)tst-dynarray.out
|
|
Packit |
6c4009 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray.mtrace > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
tst-dynarray-fail-ENV = MALLOC_TRACE=$(objpfx)tst-dynarray-fail.mtrace
|
|
Packit |
6c4009 |
$(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out
|
|
Packit |
6c4009 |
$(common-objpfx)malloc/mtrace $(objpfx)tst-dynarray-fail.mtrace > $@; \
|
|
Packit |
6c4009 |
$(evaluate-test)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc-tcache-leak: $(shared-thread-library)
|
|
Packit |
6c4009 |
$(objpfx)tst-malloc_info: $(shared-thread-library)
|