mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
The tree's 3DS layer (the custom crt0 and link spec, system and memory setup, svchax, the old GPU command layer and the 3dsx/CIA launchers) lives under os/ctr, beside os/gekko and os/wiiu. The linear heap allocator is C: the same first-fit pool, so buffers land where they did, with live allocations found by address in an open-addressing table instead of a per-allocation tree node, and list nodes taken from cache-line-aligned slabs and reused. On the same trace it runs about half the instructions and practically no malloc/free calls. With the whole heap allocated, a further allocation now fails instead of starting the heap over and handing out its first address again, and the free-space queries no longer fault. samples/frontend/ctr_linear checks placement, alignment, coalescing, the full-heap case and pages handed back from the heap's end.
29 lines
796 B
Makefile
29 lines
796 B
Makefile
# os/ctr/ctr_linear.c, the 3DS linear heap allocator, against a stand-in
|
|
# <3ds.h> and a linear heap at an address it hands out but never
|
|
# touches. Builds for Linux and, with CC=x86_64-w64-mingw32-gcc EXE=.exe
|
|
# RUNNER=wine, for Windows.
|
|
TARGET := ctr_linear_test$(EXE)
|
|
CORE_DIR := ../../..
|
|
|
|
SOURCES := ctr_linear_test.c $(CORE_DIR)/os/ctr/ctr_linear.c
|
|
|
|
CFLAGS += -std=c89 -Wall -g1 -O1 -I. -I$(CORE_DIR)/libretro-common/include
|
|
|
|
ifneq ($(SANITIZER),)
|
|
CFLAGS := -fsanitize=$(SANITIZER) -fno-omit-frame-pointer $(CFLAGS)
|
|
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
|
|
endif
|
|
|
|
all: $(TARGET)
|
|
|
|
$(TARGET): $(SOURCES) 3ds.h 3ds/types.h
|
|
$(CC) $(CFLAGS) -o $@ $(SOURCES) $(LDFLAGS)
|
|
|
|
check: all
|
|
$(RUNNER) ./$(TARGET)
|
|
|
|
clean:
|
|
rm -f ctr_linear_test ctr_linear_test.exe
|
|
|
|
.PHONY: all check clean
|