Added memory backend

Updated by Viktor Reusch for the new l4re-base-25.08.0.

Co-authored-by: vreusch <viktor.reusch@barkhauseninstitut.org>
This commit is contained in:
Martin Kuettler
2023-10-23 10:35:55 +02:00
committed by vreusch
parent d8ad183432
commit 20d8c2c149
87 changed files with 2161 additions and 2012 deletions

View File

@@ -1,3 +1,3 @@
requires: xyz requires: libstdc++ libc_be_mem xyz
provides: abc provides: abc
maintainer: your@email.example.com maintainer: your@email.example.com

View File

@@ -8,6 +8,6 @@ SRC_C = main.c
SRC_CC = SRC_CC =
# list requirements of your program here # list requirements of your program here
REQUIRES_LIBS = REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -10,4 +10,6 @@ SRC_CC-$(CONFIG_CONS_USE_ASYNC_FE) += async_vcon_fe.cc
REQUIRES_LIBS = libstdc++ cxx_libc_io cxx_io REQUIRES_LIBS = libstdc++ cxx_libc_io cxx_io
REQUIRES_LIBS-$(CONFIG_CONS_USE_ASYNC_FE) = libpthread REQUIRES_LIBS-$(CONFIG_CONS_USE_ASYNC_FE) = libpthread
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,2 +1,2 @@
requires: stdlibs requires: stdlibs libstdc++ libc_be_mem
Maintainer: adam@os.inf.tu-dresden.de Maintainer: adam@os.inf.tu-dresden.de

View File

@@ -4,6 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_clntsrv-server ex_clntsrv-client TARGET = ex_clntsrv-server ex_clntsrv-client
SRC_CC_ex_clntsrv-server = server.cc SRC_CC_ex_clntsrv-server = server.cc
SRC_CC_ex_clntsrv-client = client.cc SRC_CC_ex_clntsrv-client = client.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,3 +1,5 @@
requires: libstdc++ libc_be_mem
# color, fractal, spectrum # color, fractal, spectrum
optional: l4re_c-util optional: l4re_c-util

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_fb_spectrum_c ex_fb_spectrum_cc TARGET = ex_fb_spectrum_c ex_fb_spectrum_cc
SRC_CC_ex_fb_spectrum_cc = spectrum.cc SRC_CC_ex_fb_spectrum_cc = spectrum.cc
SRC_C_ex_fb_spectrum_c = spectrum_c.c SRC_C_ex_fb_spectrum_c = spectrum_c.c
REQUIRES_LIBS = libevent l4re_c-util REQUIRES_LIBS = libevent l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,4 +1,4 @@
requires: stdlibs requires: stdlibs libstdc++ libc_be_mem
# input, led, uart # input, led, uart
optional: libstdc++ libio-vbus optional: libstdc++ libio-vbus

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_gpio_input TARGET = ex_gpio_input
SRC_CC = gpio_input.cc SRC_CC = gpio_input.cc
REQUIRES_LIBS = libstdc++ libio-vbus REQUIRES_LIBS = libio-vbus libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_gpio_led TARGET = ex_gpio_led
SRC_CC = gpio_led.cc SRC_CC = gpio_led.cc
REQUIRES_LIBS = libstdc++ libio-vbus REQUIRES_LIBS = libio-vbus libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,7 +1,7 @@
PKGDIR ?= .. PKGDIR ?= ..
L4DIR ?= $(PKGDIR)/../../.. L4DIR ?= $(PKGDIR)/../../..
REQUIRES_LIBS = libstdc++ libio-vbus drivers_uart libio REQUIRES_LIBS = libio-vbus drivers_uart libio libc_be_mem libstdc++
TARGET = rpi_uart TARGET = rpi_uart
SRC_CC = main.cc SRC_CC = main.cc

View File

@@ -1,4 +1,4 @@
requires: stdlibs requires: stdlibs libstdc++ libc_be_mem
# boost, cppunit, stdthread # boost, cppunit, stdthread
optional: libstdc++ optional: libstdc++

View File

@@ -4,6 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = inputtst TARGET = inputtst
SRC_C = main.c SRC_C = main.c
DEPENDS_PKGS = input DEPENDS_PKGS = input
REQUIRES_LIBS = input REQUIRES_LIBS = input libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_l4re_ma+rm_cc TARGET = ex_l4re_ma+rm_cc
SRC_CC = ma+rm.cc SRC_CC = ma+rm.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_periodic_task TARGET = ex_periodic_task
SRC_CC = main.cc SRC_CC = main.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,5 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_l4re_physmem_cc TARGET = ex_l4re_physmem_cc
SRC_CC = physmem.cc SRC_CC = physmem.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_l4re_ds_clnt ex_l4re_ds_srv TARGET = ex_l4re_ds_clnt ex_l4re_ds_srv
SRC_CC_ex_l4re_ds_clnt = ds_clnt.cc SRC_CC_ex_l4re_ds_clnt = ds_clnt.cc
SRC_CC_ex_l4re_ds_srv = ds_srv.cc SRC_CC_ex_l4re_ds_srv = ds_srv.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_l4re_ma+rm_c TARGET = ex_l4re_ma+rm_c
SRC_C = ma+rm.c SRC_C = ma+rm.c
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,6 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_smap-server ex_smap-client TARGET = ex_smap-server ex_smap-client
SRC_CC_ex_smap-server = server.cc SRC_CC_ex_smap-server = server.cc
SRC_CC_ex_smap-client = client.cc SRC_CC_ex_smap-client = client.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = uclibc_thread_safe TARGET = uclibc_thread_safe
SRC_CC = main.cc SRC_CC = main.cc
REQUIRES_LIBS = libpthread REQUIRES_LIBS = libpthread libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_libio TARGET = ex_libio
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = libio libirq REQUIRES_LIBS = libio libirq libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
SRC_C_ex_libirq_async = async_isr.c SRC_C_ex_libirq_async = async_isr.c
SRC_C_ex_libirq_loop = loop.c SRC_C_ex_libirq_loop = loop.c
TARGET = ex_libirq_async ex_libirq_loop TARGET = ex_libirq_async ex_libirq_loop
REQUIRES_LIBS = libirq libio REQUIRES_LIBS = libirq libio libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
SRC_C = main.c SRC_C = main.c
TARGET = rtc_test TARGET = rtc_test
DEPENDS_PKGS = rtc DEPENDS_PKGS = rtc libc_be_mem libstdc++
REQUIRES_LIBS = rtc REQUIRES_LIBS = rtc libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_shmc TARGET = ex_shmc
SRC_C = prodcons.c SRC_C = prodcons.c
REQUIRES_LIBS = shmc libpthread REQUIRES_LIBS = shmc libpthread libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,3 +1,5 @@
requires: libc_be_mem
# cyclichpet, eb_leds, eb_leds_gfx, hpet # cyclichpet, eb_leds, eb_leds_gfx, hpet
optional: libio optional: libio

View File

@@ -3,5 +3,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = cat TARGET = cat
SRC_C = cat.c SRC_C = cat.c
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_eb_leds TARGET = ex_eb_leds
SRC_C = eb_leds.c SRC_C = eb_leds.c
REQUIRES_LIBS = libio REQUIRES_LIBS = libio libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,5 +3,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = reboot TARGET = reboot
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_hello_shared TARGET = ex_hello_shared
MODE = shared MODE = shared
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,4 +1,4 @@
requires: stdlibs requires: stdlibs libc_be_mem
# aliens, isr, singlestep, start-with-exc, utcb-ipc, vm-tz # aliens, isr, singlestep, start-with-exc, utcb-ipc, vm-tz
optional: l4re_c-util optional: l4re_c-util

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_aliens TARGET = ex_aliens
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,5 +3,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = dump_obj TARGET = dump_obj
SRC_CC = dump_obj.cc SRC_CC = dump_obj.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_ipc1 TARGET = ex_ipc1
SRC_C = ipc_example.c SRC_C = ipc_example.c
REQUIRES_LIBS = libpthread REQUIRES_LIBS = libpthread libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_isr TARGET = ex_isr
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_map_irq_client ex_map_irq_server TARGET = ex_map_irq_client ex_map_irq_server
SRC_CC_ex_map_irq_client = client.cc SRC_CC_ex_map_irq_client = client.cc
SRC_CC_ex_map_irq_server = server.cc SRC_CC_ex_map_irq_server = server.cc
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_thread_migrate ex_thread_migrate_irq TARGET = ex_thread_migrate ex_thread_migrate_irq
SRC_CC_ex_thread_migrate = thread_migrate.cc SRC_CC_ex_thread_migrate = thread_migrate.cc
SRC_CC_ex_thread_migrate_irq = thread_migrate_irq.cc SRC_CC_ex_thread_migrate_irq = thread_migrate_irq.cc
REQUIRES_LIBS = libpthread REQUIRES_LIBS = libpthread libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_singlestep TARGET = ex_singlestep
SYSTEMS = x86-l4f amd64-l4f SYSTEMS = x86-l4f amd64-l4f
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_start-with-exc TARGET = ex_start-with-exc
SYSTEMS = x86-l4f arm-l4f arm64-l4f SYSTEMS = x86-l4f arm-l4f arm64-l4f
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,6 +1,9 @@
PKGDIR ?= .. PKGDIR ?= ..
L4DIR ?= $(PKGDIR)/../../.. L4DIR ?= $(PKGDIR)/../../..
REQUIRES_LIBS = libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS)
TARGET = ex_timeouts TARGET = ex_timeouts
SRC_C = main.c SRC_C = main.c

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_uirq TARGET = ex_uirq
SRC_CC = ex_uirq.cc SRC_CC = ex_uirq.cc
REQUIRES_LIBS = libstdc++ libpthread REQUIRES_LIBS = libc_be_mem libstdc++ libpthread
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -2,7 +2,7 @@ PKGDIR ?= ..
L4DIR ?= $(PKGDIR)/../../.. L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_utcb_ipc TARGET = ex_utcb_ipc
REQUIRES_LIBS = l4re_c-util REQUIRES_LIBS = l4re_c-util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
SRC_C = main.c SRC_C = main.c

View File

@@ -3,7 +3,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = ex_vcpu TARGET = ex_vcpu
SRC_CC = vcpu.cc SRC_CC = vcpu.cc
REQUIRES_LIBS = libvcpu cxx_io cxx_libc_io REQUIRES_LIBS = libvcpu cxx_io cxx_libc_io libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -5,7 +5,7 @@ TARGET = ex_vmtest
SYSTEMS = x86-l4f amd64-l4f SYSTEMS = x86-l4f amd64-l4f
SRC_S = guest.S SRC_S = guest.S
SRC_CC = vm.cc vmx.cc svm.cc main.cc SRC_CC = vm.cc vmx.cc svm.cc main.cc
REQUIRES_LIBS = libvcpu l4util REQUIRES_LIBS = libvcpu l4util libc_be_mem libstdc++
DEPENDS_PKGS = $(REQUIRES_LIBS) DEPENDS_PKGS = $(REQUIRES_LIBS)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,2 +1,2 @@
requires: libdrivers-lcd x86emu_int10 stdlibs libio-vbus requires: libdrivers-lcd x86emu_int10 stdlibs libio-vbus libstdc++ libc_be_mem
maintainer: adam@os.inf.tu-dresden.de maintainer: adam@os.inf.tu-dresden.de

View File

@@ -11,7 +11,7 @@ REQUIRES_LIBS_x86-l4f = x86emu_int10
REQUIRES_LIBS_amd64-l4f = x86emu_int10 REQUIRES_LIBS_amd64-l4f = x86emu_int10
REQUIRES_LIBS_arm-l4f = libdrivers-lcd REQUIRES_LIBS_arm-l4f = libdrivers-lcd
REQUIRES_LIBS_arm64-l4f = libdrivers-lcd REQUIRES_LIBS_arm64-l4f = libdrivers-lcd
REQUIRES_LIBS = libc_support_misc libio-vbus REQUIRES_LIBS = libc_support_misc libio-vbus libc_be_mem libstdc++
DEFINES = -DSPLASHNAME=gimp_image \ DEFINES = -DSPLASHNAME=gimp_image \
-DSPLASHNAME_RUN_LENGTH_DECODE=GIMP_IMAGE_RUN_LENGTH_DECODE -DSPLASHNAME_RUN_LENGTH_DECODE=GIMP_IMAGE_RUN_LENGTH_DECODE

View File

@@ -1,2 +1,2 @@
requires: stdlibs requires: stdlibs libstdc++ libc_be_mem
Maintainer: adam@os.inf.tu-dresden.de Maintainer: adam@os.inf.tu-dresden.de

View File

@@ -4,4 +4,6 @@ L4DIR ?= $(PKGDIR)/../..
TARGET = hello TARGET = hello
SRC_C = main.c SRC_C = main.c
REQUIRES_LIBS = libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -2,6 +2,8 @@
#MODE := shared #MODE := shared
TARGET = io TARGET = io
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
DEFINES-$(CONFIG_L4IO_PCIID_DB) += -DCONFIG_L4IO_PCIID_DB DEFINES-$(CONFIG_L4IO_PCIID_DB) += -DCONFIG_L4IO_PCIID_DB
SUBDIRS = drivers SUBDIRS = drivers

View File

@@ -1,2 +1,2 @@
requires: stdlibs requires: stdlibs libstdc++ libc_be_mem
Maintainer: adam@l4re.org Maintainer: adam@l4re.org

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../..
TARGET = ipcbench ipcbench_parallel \ TARGET = ipcbench ipcbench_parallel \
ipcbench_client ipcbench_server \ ipcbench_client ipcbench_server \
syscallbench syscallbench_parallel syscallbench syscallbench_parallel
REQUIRES_LIBS = libpthread REQUIRES_LIBS = libc_be_mem libstdc++ libpthread
SRC_C_ipcbench = ipcbench.c ipc_common.c SRC_C_ipcbench = ipcbench.c ipc_common.c
SRC_C_ipcbench_parallel = ipcbench_parallel.c ipc_common.c SRC_C_ipcbench_parallel = ipcbench_parallel.c ipc_common.c
SRC_C_ipcbench_client = ipcclient.c SRC_C_ipcbench_client = ipcclient.c

View File

@@ -29,7 +29,7 @@ DEFINES += -DL4_CXX_NO_EXCEPTION_BACKTRACE -DL4_LOADER_RELOC_BASE=$(DEFAULT_RELO
REQUIRES_LIBS := cxx_io cxx_libc_io libc_minimal libsupc++_minimal libloader \ REQUIRES_LIBS := cxx_io cxx_libc_io libc_minimal libsupc++_minimal libloader \
libc_minimal_l4re libumalloc libc_minimal_l4re libumalloc
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc --wrap=aligned_alloc --wrap=calloc
CXXFLAGS += $(CXXFLAGS_LOW_LEVEL) CXXFLAGS += $(CXXFLAGS_LOW_LEVEL)
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -24,23 +24,26 @@ struct Vfs_init
cxx::Static_container<L4Re::Vfs::File_factory_t<L4Re::Namespace, L4Re::Core::Ns_dir> > ns_dir; cxx::Static_container<L4Re::Vfs::File_factory_t<L4Re::Namespace, L4Re::Core::Ns_dir> > ns_dir;
cxx::Static_container<L4Re::Vfs::File_factory_t<L4::Vcon, L4Re::Core::Vcon_stream> > vcon_stream; cxx::Static_container<L4Re::Vfs::File_factory_t<L4::Vcon, L4Re::Core::Vcon_stream> > vcon_stream;
// This is part of an ugly hack to avoid calling malloc here.
char fac_items[3*sizeof(Vfs::File_factory_item)];
Vfs_init() Vfs_init()
{ {
vfs.construct(); vfs.construct();
__rtld_l4re_env_posix_vfs_ops = vfs; __rtld_l4re_env_posix_vfs_ops = vfs;
ns_dir.construct(); ns_dir.construct();
auto ns_ptr = cxx::ref_ptr(ns_dir.get()); auto ns_ptr = cxx::ref_ptr(ns_dir.get());
vfs->register_file_factory(ns_ptr); vfs->register_file_factory(ns_ptr, &fac_items[0]);
ns_ptr.release(); // prevent deletion of static object ns_ptr.release(); // prevent deletion of static object
ro_file.construct(); ro_file.construct();
auto ro_ptr = cxx::ref_ptr(ro_file.get()); auto ro_ptr = cxx::ref_ptr(ro_file.get());
vfs->register_file_factory(ro_ptr); vfs->register_file_factory(ro_ptr, &fac_items[sizeof(Vfs::File_factory_item)]);
ro_ptr.release(); // prevent deletion of static object ro_ptr.release(); // prevent deletion of static object
vcon_stream.construct(); vcon_stream.construct();
auto vcon_ptr = cxx::ref_ptr(vcon_stream.get()); auto vcon_ptr = cxx::ref_ptr(vcon_stream.get());
vfs->register_file_factory(vcon_ptr); vfs->register_file_factory(vcon_ptr, &fac_items[2*sizeof(Vfs::File_factory_item)]);
vcon_ptr.release(); // prevent deletion of static object vcon_ptr.release(); // prevent deletion of static object
} }
}; };

View File

@@ -134,6 +134,7 @@ public:
L4Re::Vfs::File_system_list file_system_list() noexcept override; L4Re::Vfs::File_system_list file_system_list() noexcept override;
int register_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept override; int register_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept override;
int register_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f, void *x) noexcept;
int unregister_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept override; int unregister_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept override;
Ref_ptr<L4Re::Vfs::File_factory> get_file_factory(int proto) noexcept override; Ref_ptr<L4Re::Vfs::File_factory> get_file_factory(int proto) noexcept override;
Ref_ptr<L4Re::Vfs::File_factory> get_file_factory(char const *proto_name) noexcept override; Ref_ptr<L4Re::Vfs::File_factory> get_file_factory(char const *proto_name) noexcept override;
@@ -144,14 +145,6 @@ public:
void *malloc(size_t size) noexcept override { return Vfs_config::malloc(size); } void *malloc(size_t size) noexcept override { return Vfs_config::malloc(size); }
void free(void *m) noexcept override { Vfs_config::free(m); } void free(void *m) noexcept override { Vfs_config::free(m); }
private:
Root_mount_tree _root_mount;
L4Re::Core::Env_dir _root;
Ref_ptr<L4Re::Vfs::File> _cwd;
Fd_store fds;
L4Re::Vfs::File_system *_fs_registry;
struct File_factory_item : cxx::H_list_item_t<File_factory_item> struct File_factory_item : cxx::H_list_item_t<File_factory_item>
{ {
cxx::Ref_ptr<L4Re::Vfs::File_factory> f; cxx::Ref_ptr<L4Re::Vfs::File_factory> f;
@@ -163,6 +156,14 @@ private:
File_factory_item &operator = (File_factory_item const &) = delete; File_factory_item &operator = (File_factory_item const &) = delete;
}; };
private:
Root_mount_tree _root_mount;
L4Re::Core::Env_dir _root;
Ref_ptr<L4Re::Vfs::File> _cwd;
Fd_store fds;
L4Re::Vfs::File_system *_fs_registry;
cxx::H_list_t<File_factory_item> _file_factories; cxx::H_list_t<File_factory_item> _file_factories;
l4_addr_t _anon_offset; l4_addr_t _anon_offset;
@@ -272,6 +273,20 @@ Vfs::register_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept
return 0; return 0;
} }
int
Vfs::register_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f, void *x) noexcept
{
if (!f)
return -EINVAL;
if (!x)
return -ENOMEM;
auto ff = new (x, cxx::Nothrow()) File_factory_item(f);
_file_factories.push_front(ff);
return 0;
}
int int
Vfs::unregister_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept Vfs::unregister_file_factory(cxx::Ref_ptr<L4Re::Vfs::File_factory> f) noexcept
{ {

View File

@@ -14,3 +14,5 @@ CXXFLAGS += -fvisibility=hidden
# No exception information as unwinder code might use malloc and friends # No exception information as unwinder code might use malloc and friends
DEFINES += -DNOT_IN_libc -DL4_NO_RTTI DEFINES += -DNOT_IN_libc -DL4_NO_RTTI
CXXFLAGS += -include libc-symbols.h -fno-exceptions -fno-rtti CXXFLAGS += -include libc-symbols.h -fno-exceptions -fno-rtti
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc

View File

@@ -21,7 +21,7 @@
extern int weak_function __libc_free_aligned(void *ptr) attribute_hidden; extern int weak_function __libc_free_aligned(void *ptr) attribute_hidden;
#ifdef L_malloc #ifdef L_malloc
void *malloc(size_t size) void *__wrap_malloc(size_t size)
{ {
void *result; void *result;
@@ -80,7 +80,7 @@ void * calloc(size_t nmemb, size_t lsize)
#endif #endif
#ifdef L_realloc #ifdef L_realloc
void *realloc(void *ptr, size_t size) void *__wrap_realloc(void *ptr, size_t size)
{ {
void *newptr = NULL; void *newptr = NULL;
@@ -102,7 +102,7 @@ void *realloc(void *ptr, size_t size)
#endif #endif
#ifdef L_free #ifdef L_free
void free(void *ptr) void __wrap_free(void *ptr)
{ {
if (unlikely(ptr == NULL)) if (unlikely(ptr == NULL))
return; return;

View File

@@ -268,7 +268,7 @@ void attribute_hidden __malloc_consolidate(mstate av)
/* ------------------------------ free ------------------------------ */ /* ------------------------------ free ------------------------------ */
void free(void* mem) void __wrap_free(void* mem)
{ {
mstate av; mstate av;
@@ -414,4 +414,4 @@ void free(void* mem)
} }
/* glibc compatibilty */ /* glibc compatibilty */
weak_alias(free, __libc_free) weak_alias(__wrap_free, __libc_free)

View File

@@ -16,6 +16,7 @@
#include "malloc.h" #include "malloc.h"
void __wrap_free(void *);
__UCLIBC_MUTEX_INIT(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); __UCLIBC_MUTEX_INIT(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
@@ -707,7 +708,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
if (old_size >= MINSIZE) { if (old_size >= MINSIZE) {
size_t tt = av->trim_threshold; size_t tt = av->trim_threshold;
av->trim_threshold = (size_t)(-1); av->trim_threshold = (size_t)(-1);
free(chunk2mem(old_top)); __wrap_free(chunk2mem(old_top));
av->trim_threshold = tt; av->trim_threshold = tt;
} }
} }
@@ -800,7 +801,7 @@ static int __malloc_largebin_index(unsigned long sz)
/* ------------------------------ malloc ------------------------------ */ /* ------------------------------ malloc ------------------------------ */
void* malloc(size_t bytes) void* __wrap_malloc(size_t bytes)
{ {
mstate av; mstate av;
@@ -1161,4 +1162,4 @@ DONE:
} }
/* glibc compatibilty */ /* glibc compatibilty */
weak_alias(malloc, __libc_malloc) weak_alias(__wrap_malloc, __libc_malloc)

View File

@@ -18,7 +18,7 @@
/* ------------------------------ realloc ------------------------------ */ /* ------------------------------ realloc ------------------------------ */
void* realloc(void* oldmem, size_t bytes) void* __wrap_realloc(void* oldmem, size_t bytes)
{ {
mstate av; mstate av;
@@ -239,4 +239,4 @@ void* realloc(void* oldmem, size_t bytes)
} }
/* glibc compatibilty */ /* glibc compatibilty */
weak_alias(realloc, __libc_realloc) weak_alias(__wrap_realloc, __libc_realloc)

View File

@@ -266,7 +266,7 @@ __free_to_heap (void *mem, struct heap_free_area **heap
} }
void void
free (void *mem) __wrap_free (void *mem)
{ {
free_to_heap (mem, &__malloc_heap, &__malloc_heap_lock); free_to_heap (mem, &__malloc_heap, &__malloc_heap_lock);
} }

View File

@@ -194,7 +194,7 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
} }
void * void *
malloc (size_t size) __wrap_malloc (size_t size)
{ {
void *mem; void *mem;
#ifdef MALLOC_DEBUGGING #ifdef MALLOC_DEBUGGING

View File

@@ -21,7 +21,7 @@
void * void *
realloc (void *mem, size_t new_size) __wrap_realloc (void *mem, size_t new_size)
{ {
size_t size; size_t size;
char *base_mem; char *base_mem;

View File

@@ -1,6 +1,6 @@
Provides: libc_be_socket_noop libc_be_l4re libc_support_misc Provides: libc_be_socket_noop libc_be_l4re libc_support_misc
libc_be_fs_noop libc_be_math libc_be_l4refile libinitcwd libc_be_fs_noop libc_be_math libc_be_l4refile libinitcwd
libc_be_minimal_log_io libmount libc_be_sig libc_be_minimal_log_io libmount libc_be_sig
libc_be_sem_noop libc_be_static_heap libc_be_sem_noop libc_be_static_heap libc_be_mem
Requires: l4re libl4re-vfs libc-headers Requires: l4re libl4re-vfs libc-headers
Maintainer: adam@os.inf.tu-dresden.de Maintainer: adam@os.inf.tu-dresden.de

View File

@@ -0,0 +1,12 @@
PKGDIR ?= ../..
L4DIR ?= $(PKGDIR)/../../..
TARGET = libc_be_mem.a libc_be_mem.so
LINK_INCR = libc_be_mem.a
PC_FILENAME = libc_be_mem
REQUIRES_LIBS = l4re
SRC_CC = mem.cc
include $(L4DIR)/mk/lib.mk
LDFLAGS := $(filter-out -gc-sections,$(LDFLAGS))

View File

@@ -0,0 +1,32 @@
/**
* \file libc_backends/l4re_mem/mem.cc
*/
/*
* (c) 2004-2009 Technische Universität Dresden
* This file is part of TUD:OS and distributed under the terms of the
* GNU Lesser General Public License 2.1.
* Please see the COPYING-LGPL-2.1 file for details.
*/
#include <stdlib.h>
#include <l4/sys/kdebug.h>
void *malloc(size_t size) throw()
{
void *data = 0;
enter_kdebug("malloc");
return (void*)data;
}
void free(void *p) throw()
{
if (p)
enter_kdebug("free");
}
void *realloc(void *p, size_t size) throw()
{
void *data = 0;
enter_kdebug("realloc");
return (void*)data;
}

View File

@@ -28,6 +28,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdbool.h> #include <stdbool.h>
void *__wrap_malloc();
// Common logic for version locks. // Common logic for version locks.
struct version_lock struct version_lock
{ {
@@ -402,7 +404,7 @@ btree_allocate_node (struct btree *t, bool inner)
// No free node available, allocate a new one. // No free node available, allocate a new one.
struct btree_node *new_node struct btree_node *new_node
= (struct btree_node *) (malloc (sizeof (struct btree_node))); = (struct btree_node *) (__wrap_malloc (sizeof (struct btree_node)));
version_lock_initialize_locked_exclusive ( version_lock_initialize_locked_exclusive (
&(new_node->version_lock)); // initialize the node in locked state. &(new_node->version_lock)); // initialize the node in locked state.
new_node->entry_count = 0; new_node->entry_count = 0;

View File

@@ -28,6 +28,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdbool.h> #include <stdbool.h>
void *__wrap_malloc();
// Common logic for version locks. // Common logic for version locks.
struct version_lock struct version_lock
{ {
@@ -402,7 +404,7 @@ btree_allocate_node (struct btree *t, bool inner)
// No free node available, allocate a new one. // No free node available, allocate a new one.
struct btree_node *new_node struct btree_node *new_node
= (struct btree_node *) (malloc (sizeof (struct btree_node))); = (struct btree_node *) (__wrap_malloc (sizeof (struct btree_node)));
version_lock_initialize_locked_exclusive ( version_lock_initialize_locked_exclusive (
&(new_node->version_lock)); // initialize the node in locked state. &(new_node->version_lock)); // initialize the node in locked state.
new_node->entry_count = 0; new_node->entry_count = 0;

View File

@@ -28,6 +28,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdbool.h> #include <stdbool.h>
void *__wrap_malloc(size_t);
void __wrap_free(void *);
// Common logic for version locks. // Common logic for version locks.
struct version_lock struct version_lock
{ {
@@ -362,7 +365,7 @@ btree_destroy (struct btree *t)
while (t->free_list) while (t->free_list)
{ {
struct btree_node *next = t->free_list->content.children[0].child; struct btree_node *next = t->free_list->content.children[0].child;
free (t->free_list); __wrap_free (t->free_list);
t->free_list = next; t->free_list = next;
} }
} }
@@ -401,7 +404,7 @@ btree_allocate_node (struct btree *t, bool inner)
// No free node available, allocate a new one. // No free node available, allocate a new one.
struct btree_node *new_node struct btree_node *new_node
= (struct btree_node *) malloc (sizeof (struct btree_node)); = (struct btree_node *) __wrap_malloc (sizeof (struct btree_node));
// Initialize the node in locked state. // Initialize the node in locked state.
version_lock_initialize_locked_exclusive (&new_node->version_lock); version_lock_initialize_locked_exclusive (&new_node->version_lock);
new_node->entry_count = 0; new_node->entry_count = 0;

View File

@@ -37,14 +37,16 @@
#include <new> #include <new>
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -85,13 +87,18 @@ namespace
{ {
public: public:
pool(); pool();
pool(char*, int);
_GLIBCXX_NODISCARD void *allocate (std::size_t); _GLIBCXX_NODISCARD void *allocate (std::size_t);
void free (void *); void free (void *);
bool in_pool (void *); bool in_pool (void *);
bool mem_static;
private: private:
void init();
struct free_entry { struct free_entry {
std::size_t size; std::size_t size;
free_entry *next; free_entry *next;
@@ -121,6 +128,22 @@ namespace
arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception)); + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
arena = (char *)malloc (arena_size); arena = (char *)malloc (arena_size);
mem_static = false;
init();
}
pool::pool(char * storage, int size)
{
arena_size = size;
arena = storage;
mem_static = true;
init();
}
void pool::init()
{
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -259,7 +282,10 @@ namespace
&& p < arena + arena_size); && p < arena + arena_size);
} }
pool emergency_pool; int const emergency_pool_size = EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception);
char emergency_pool_storage[emergency_pool_size];
pool emergency_pool{emergency_pool_storage, emergency_pool_size};
} }
namespace __gnu_cxx namespace __gnu_cxx
@@ -267,7 +293,8 @@ namespace __gnu_cxx
void void
__freeres() __freeres()
{ {
if (emergency_pool.arena) // why is this not a destructor?
if (emergency_pool.arena and not emergency_pool.mem_static)
{ {
::free(emergency_pool.arena); ::free(emergency_pool.arena);
emergency_pool.arena = 0; emergency_pool.arena = 0;
@@ -281,7 +308,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
void *ret; void *ret;
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
ret = malloc (thrown_size); ret = __wrap_malloc (thrown_size);
if (!ret) if (!ret)
ret = emergency_pool.allocate (thrown_size); ret = emergency_pool.allocate (thrown_size);
@@ -312,7 +339,7 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
__cxa_dependent_exception *ret; __cxa_dependent_exception *ret;
ret = static_cast<__cxa_dependent_exception*> ret = static_cast<__cxa_dependent_exception*>
(malloc (sizeof (__cxa_dependent_exception))); (__wrap_malloc(sizeof (__cxa_dependent_exception)));
if (!ret) if (!ret)
ret = static_cast <__cxa_dependent_exception*> ret = static_cast <__cxa_dependent_exception*>

View File

@@ -37,14 +37,16 @@
#include <new> #include <new>
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -120,7 +122,7 @@ namespace
// to make this tunable. // to make this tunable.
arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception)); + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -281,7 +283,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
void *ret; void *ret;
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
ret = malloc (thrown_size); ret = __wrap_malloc (thrown_size);
if (!ret) if (!ret)
ret = emergency_pool.allocate (thrown_size); ret = emergency_pool.allocate (thrown_size);
@@ -312,7 +314,7 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
__cxa_dependent_exception *ret; __cxa_dependent_exception *ret;
ret = static_cast<__cxa_dependent_exception*> ret = static_cast<__cxa_dependent_exception*>
(malloc (sizeof (__cxa_dependent_exception))); (__wrap_malloc (sizeof (__cxa_dependent_exception)));
if (!ret) if (!ret)
ret = static_cast <__cxa_dependent_exception*> ret = static_cast <__cxa_dependent_exception*>

View File

@@ -37,14 +37,16 @@
#include <new> #include <new>
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -120,7 +122,7 @@ namespace
// to make this tunable. // to make this tunable.
arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception)); + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -281,7 +283,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
void *ret; void *ret;
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
ret = malloc (thrown_size); ret = __wrap_malloc (thrown_size);
if (!ret) if (!ret)
ret = emergency_pool.allocate (thrown_size); ret = emergency_pool.allocate (thrown_size);
@@ -312,7 +314,7 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
__cxa_dependent_exception *ret; __cxa_dependent_exception *ret;
ret = static_cast<__cxa_dependent_exception*> ret = static_cast<__cxa_dependent_exception*>
(malloc (sizeof (__cxa_dependent_exception))); (__wrap_malloc (sizeof (__cxa_dependent_exception)));
if (!ret) if (!ret)
ret = static_cast <__cxa_dependent_exception*> ret = static_cast <__cxa_dependent_exception*>

View File

@@ -73,14 +73,16 @@
// - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE. // - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE.
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
using std::memset; using std::memset;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -236,7 +238,7 @@ namespace
arena_size = buffer_size_in_bytes(obj_count, obj_size); arena_size = buffer_size_in_bytes(obj_count, obj_size);
if (arena_size == 0) if (arena_size == 0)
return; return;
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -399,7 +401,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept
{ {
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
void *ret = malloc (thrown_size); void *ret = __wrap_malloc (thrown_size);
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)
@@ -431,7 +433,7 @@ __cxxabiv1::__cxa_free_exception(void *vptr) noexcept
extern "C" __cxa_dependent_exception* extern "C" __cxa_dependent_exception*
__cxxabiv1::__cxa_allocate_dependent_exception() noexcept __cxxabiv1::__cxa_allocate_dependent_exception() noexcept
{ {
void *ret = malloc (sizeof (__cxa_dependent_exception)); void *ret = __wrap_malloc (sizeof (__cxa_dependent_exception));
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)

View File

@@ -73,14 +73,16 @@
// - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE. // - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE.
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -236,7 +238,7 @@ namespace
arena_size = buffer_size_in_bytes(obj_count, obj_size); arena_size = buffer_size_in_bytes(obj_count, obj_size);
if (arena_size == 0) if (arena_size == 0)
return; return;
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -399,7 +401,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept
{ {
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
void *ret = malloc (thrown_size); void *ret = __wrap_malloc (thrown_size);
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)
@@ -431,7 +433,7 @@ __cxxabiv1::__cxa_free_exception(void *vptr) noexcept
extern "C" __cxa_dependent_exception* extern "C" __cxa_dependent_exception*
__cxxabiv1::__cxa_allocate_dependent_exception() noexcept __cxxabiv1::__cxa_allocate_dependent_exception() noexcept
{ {
void *ret = malloc (sizeof (__cxa_dependent_exception)); void *ret = __wrap_malloc (sizeof (__cxa_dependent_exception));
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)

View File

@@ -1,5 +1,5 @@
// -*- C++ -*- Allocate exception objects. // -*- C++ -*- Allocate exception objects.
// Copyright (C) 2001-2025 Free Software Foundation, Inc. // Copyright (C) 2001-2024 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@@ -73,14 +73,16 @@
// - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE. // - Tunable glibcxx.eh_pool.obj_size overrides EMERGENCY_OBJ_SIZE.
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -236,7 +238,7 @@ namespace
arena_size = buffer_size_in_bytes(obj_count, obj_size); arena_size = buffer_size_in_bytes(obj_count, obj_size);
if (arena_size == 0) if (arena_size == 0)
return; return;
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -399,7 +401,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) noexcept
{ {
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
void *ret = malloc (thrown_size); void *ret = __wrap_malloc (thrown_size);
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)
@@ -431,7 +433,7 @@ __cxxabiv1::__cxa_free_exception(void *vptr) noexcept
extern "C" __cxa_dependent_exception* extern "C" __cxa_dependent_exception*
__cxxabiv1::__cxa_allocate_dependent_exception() noexcept __cxxabiv1::__cxa_allocate_dependent_exception() noexcept
{ {
void *ret = malloc (sizeof (__cxa_dependent_exception)); void *ret = __wrap_malloc (sizeof (__cxa_dependent_exception));
#if USE_POOL #if USE_POOL
if (!ret) if (!ret)

View File

@@ -37,14 +37,16 @@
#include <new> #include <new>
#if _GLIBCXX_HOSTED #if _GLIBCXX_HOSTED
using std::free; //using std::free;
using std::malloc; //using std::malloc;
extern "C" void *__wrap_malloc (std::size_t);
extern "C" void __wrap_free(void *);
using std::memset; using std::memset;
#else #else
// In a freestanding environment, these functions may not be available // In a freestanding environment, these functions may not be available
// -- but for now, we assume that they are. // -- but for now, we assume that they are.
extern "C" void *malloc (std::size_t); extern "C" void *__wrap_malloc (std::size_t);
extern "C" void free(void *); extern "C" void __wrap_free(void *);
extern "C" void *memset (void *, int, std::size_t); extern "C" void *memset (void *, int, std::size_t);
#endif #endif
@@ -120,7 +122,7 @@ namespace
// to make this tunable. // to make this tunable.
arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
+ EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception)); + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
arena = (char *)malloc (arena_size); arena = (char *)__wrap_malloc (arena_size);
if (!arena) if (!arena)
{ {
// If the allocation failed go without an emergency pool. // If the allocation failed go without an emergency pool.
@@ -281,7 +283,7 @@ __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
void *ret; void *ret;
thrown_size += sizeof (__cxa_refcounted_exception); thrown_size += sizeof (__cxa_refcounted_exception);
ret = malloc (thrown_size); ret = __wrap_malloc (thrown_size);
if (!ret) if (!ret)
ret = emergency_pool.allocate (thrown_size); ret = emergency_pool.allocate (thrown_size);
@@ -312,7 +314,7 @@ __cxxabiv1::__cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW
__cxa_dependent_exception *ret; __cxa_dependent_exception *ret;
ret = static_cast<__cxa_dependent_exception*> ret = static_cast<__cxa_dependent_exception*>
(malloc (sizeof (__cxa_dependent_exception))); (__wrap_malloc (sizeof (__cxa_dependent_exception)));
if (!ret) if (!ret)
ret = static_cast <__cxa_dependent_exception*> ret = static_cast <__cxa_dependent_exception*>

View File

@@ -994,6 +994,8 @@ static void *realloc(void *ptr, size_t size)
} // namespace umalloc } // namespace umalloc
L4_BEGIN_DECLS
/** /**
* Standard-compliant malloc implementation. * Standard-compliant malloc implementation.
* *
@@ -1001,7 +1003,7 @@ static void *realloc(void *ptr, size_t size)
* *
* \return Valid allocated memory or nullptr if the allocation failed. * \return Valid allocated memory or nullptr if the allocation failed.
*/ */
void *malloc(size_t size) noexcept void *__wrap_malloc(size_t size) noexcept
{ {
auto ptr = umalloc::alloc(size); auto ptr = umalloc::alloc(size);
if (!ptr) if (!ptr)
@@ -1018,7 +1020,7 @@ void *malloc(size_t size) noexcept
* *
* \return Valid allocated memory or nullptr if the allocation failed. * \return Valid allocated memory or nullptr if the allocation failed.
*/ */
void *aligned_alloc(size_t alignment, size_t size) noexcept void *__wrap_aligned_alloc(size_t alignment, size_t size) noexcept
{ {
auto ptr = umalloc::alloc(size, alignment); auto ptr = umalloc::alloc(size, alignment);
if (!ptr) if (!ptr)
@@ -1032,7 +1034,7 @@ void *aligned_alloc(size_t alignment, size_t size) noexcept
* *
* \param ptr Previously allocated valid memory. * \param ptr Previously allocated valid memory.
*/ */
void free(void *ptr) noexcept void __wrap_free(void *ptr) noexcept
{ {
if (ptr) if (ptr)
umalloc::dealloc(ptr); umalloc::dealloc(ptr);
@@ -1046,7 +1048,7 @@ void free(void *ptr) noexcept
* *
* \return Valid allocated memory or nullptr if the allocation failed. * \return Valid allocated memory or nullptr if the allocation failed.
*/ */
void *calloc(size_t nmemb, size_t size) noexcept void *__wrap_calloc(size_t nmemb, size_t size) noexcept
{ {
// Avoid multiplication overflow. // Avoid multiplication overflow.
if ((size > 0) && (nmemb > std::numeric_limits<typeof(nmemb)>::max() / size)) if ((size > 0) && (nmemb > std::numeric_limits<typeof(nmemb)>::max() / size))
@@ -1073,7 +1075,7 @@ void *calloc(size_t nmemb, size_t size) noexcept
* \return Valid reallocated memory or nullptr if the reallocation failed. * \return Valid reallocated memory or nullptr if the reallocation failed.
* (in which case the previously allocated memory is not touched). * (in which case the previously allocated memory is not touched).
*/ */
void *realloc(void *ptr, size_t size) noexcept void *__wrap_realloc(void *ptr, size_t size) noexcept
{ {
if (!ptr) if (!ptr)
return malloc(size); return malloc(size);
@@ -1084,3 +1086,5 @@ void *realloc(void *ptr, size_t size) noexcept
return ptr; return ptr;
} }
L4_END_DECLS

View File

@@ -4,7 +4,7 @@ L4DIR ?= $(PKGDIR)/../../..
TARGET = lua TARGET = lua
SRC_C = lua.c SRC_C = lua.c
REQUIRES_LIBS = lua libc_support_misc libc_be_fs_noop libc_be_sig REQUIRES_LIBS = lua libc_support_misc libc_be_fs_noop libc_be_sig
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
vpath %.c $(PKGDIR)/lib/contrib/src vpath %.c $(PKGDIR)/lib/contrib/src
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -10,6 +10,8 @@ $(GENERAL_D_LOC): $(PKGDIR)/lib/build/Makefile
PKGNAME_DIRNAME := lua-c++ PKGNAME_DIRNAME := lua-c++
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
# Difference to other version # Difference to other version
# WARNINGS EXCEPTION: CFLAGS is used here for C++ files (instead of the usual # WARNINGS EXCEPTION: CFLAGS is used here for C++ files (instead of the usual

View File

@@ -25,6 +25,7 @@ CAN_PIE_arm := y
CAN_PIE_arm64 := y CAN_PIE_arm64 := y
BID_CAN_PIE = $(CAN_PIE_$(ARCH)) BID_CAN_PIE = $(CAN_PIE_$(ARCH))
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc --wrap=aligned_alloc --wrap=calloc
REQUIRES_LIBS := libkproxy libloader libsigma0 \ REQUIRES_LIBS := libkproxy libloader libsigma0 \
cxx_io cxx_libc_io libsupc++_minimal \ cxx_io cxx_libc_io libsupc++_minimal \
libc_minimal libc_minimal_l4re libumalloc libc_minimal libc_minimal_l4re libumalloc

View File

@@ -6,4 +6,6 @@ SRC_CC = ned-prompt.cc
REQUIRES_LIBS := readline REQUIRES_LIBS := readline
DEPENDS_PKGS := readline DEPENDS_PKGS := readline
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -14,5 +14,6 @@ SRC_CC += lua_sleep.cc
REQUIRES_LIBS := libloader lua++ libc_support_misc cxx_libc_io cxx_io REQUIRES_LIBS := libloader lua++ libc_support_misc cxx_libc_io cxx_io
DEFAULT_HEAP_SIZE := 0x20000 DEFAULT_HEAP_SIZE := 0x20000
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -4,5 +4,6 @@ L4DIR ?= $(PKGDIR)/../..
TARGET = backtracer TARGET = backtracer
SRC_CC = backtracer.cc SRC_CC = backtracer.cc
REQUIRES_LIBS = stdlibs libunwind libstdc++ REQUIRES_LIBS = stdlibs libunwind libstdc++
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -10,5 +10,6 @@ LDFLAGS +=
#CPPFLAGS += -fPIC #CPPFLAGS += -fPIC
REQUIRES_LIBS := libloader libkproxy cxx_libc_io cxx_io REQUIRES_LIBS := libloader libkproxy cxx_libc_io cxx_io
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -1,4 +1,4 @@
provides: libmag mag-input-libinput mag-input-event mag-client_fb mag-mag_client mag-session_manager provides: libmag mag-input-libinput mag-input-event mag-client_fb mag-mag_client mag-session_manager
requires: l4re libc stdlibs-sh input l4util mag-gfx libstdc++ requires: l4re libc stdlibs-sh input l4util mag-gfx libstdc++
lua++ lua++ libc_be_mem
Maintainer: warg@os.inf.tu-dresden.de Maintainer: warg@os.inf.tu-dresden.de

View File

@@ -15,7 +15,7 @@ STATIC_PLUGINS += mag-input-event
STATIC_PLUGINS += mag-client_fb STATIC_PLUGINS += mag-client_fb
STATIC_PLUGINS += mag-mag_client STATIC_PLUGINS += mag-mag_client
REQUIRES_LIBS:= libsupc++ libdl mag-gfx lua++ cxx_libc_io cxx_io REQUIRES_LIBS:= libsupc++ libdl mag-gfx lua++ cxx_libc_io cxx_io libc_be_mem libstdc++
REQUIRES_LIBS += $(STATIC_PLUGINS) REQUIRES_LIBS += $(STATIC_PLUGINS)
#LDFLAGS += --export-dynamic #LDFLAGS += --export-dynamic

View File

@@ -1,4 +1,4 @@
provides: rtc rtc_libc_be provides: rtc rtc_libc_be
requires: stdlibs libio cxx_libc_io cxx_io libstdc++ requires: stdlibs libio cxx_libc_io cxx_io libstdc++ libc_be_mem
optional: drivers-frst i2c-server optional: drivers-frst i2c-server
Maintainer: adam.lackorzynski@kernkonzept.com Maintainer: adam.lackorzynski@kernkonzept.com

View File

@@ -9,6 +9,6 @@ SRC_CC_arm64-l4f = pl031.cc
SRC_CC = main.cc SRC_CC = main.cc
SRC_CC-$(CONFIG_RTC_DS3231) += ds3231.cc SRC_CC-$(CONFIG_RTC_DS3231) += ds3231.cc
SRC_CC-$(CONFIG_RTC_PCF85063A) += pcf85063a.cc SRC_CC-$(CONFIG_RTC_PCF85063A) += pcf85063a.cc
REQUIRES_LIBS = libio cxx_libc_io cxx_io libstdc++ REQUIRES_LIBS = libio cxx_libc_io cxx_io libc_be_mem libstdc++
include $(L4DIR)/mk/prog.mk include $(L4DIR)/mk/prog.mk

View File

@@ -5,6 +5,7 @@ TARGET = l4vio_switch
REQUIRES_LIBS = libstdc++ l4virtio REQUIRES_LIBS = libstdc++ l4virtio
REQUIRES_LIBS-$(CONFIG_VNS_IXL) += ixl REQUIRES_LIBS-$(CONFIG_VNS_IXL) += ixl
LDFLAGS += --wrap=malloc --wrap=free --wrap=realloc
SRC_CC-$(CONFIG_VNS_PORT_FILTER) += filter.cc SRC_CC-$(CONFIG_VNS_PORT_FILTER) += filter.cc