From b2fbde0fc230a3c2b36148d191ac2e539701a05e Mon Sep 17 00:00:00 2001 From: huntedbytheirs Date: Thu, 3 Sep 2026 20:50:20 -0400 Subject: [PATCH] build: wire malloc/string/ctype sources and tests --- Makefile.am | 58 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 67f2252..4e831ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,11 +59,35 @@ VLIBC_CORE_SRCS = \ src/string/strcmp.c \ src/string/memcpy.c \ src/string/memmove.c \ - src/string/memset.c + src/string/memset.c \ + src/string/strcat.c \ + src/string/strchr.c \ + src/string/strcoll.c \ + src/string/strcpy.c \ + src/string/strdup.c \ + src/string/memchr.c \ + src/string/memcmp.c \ + src/string/strncmp.c \ + src/string/strncpy.c \ + src/string/strnlen.c \ + src/string/strsignal.c \ + src/string/strspn.c \ + src/string/strstr.c \ + src/string/strtok.c \ + src/malloc/malloc.c \ + src/ctype/ctype.c # Profile-gated sources, EXISTING gates preserved (strlcpy/strlcat stay L2 -# BSD, strcasestr stays L3 GNU — NOT promoted). -VLIBC_LEVEL2_SRCS = src/string/strlcpy.c src/string/strlcat.c +# BSD, strcasestr stays L3 GNU — NOT promoted). Task 8/9 additions: stpcpy.c +# (stpcpy/stpncpy) and memccpy.c are WHOLE-FILE L2-gated (#if VLIBC_LEVEL_GE(2) +# around the entire body), and isascii.c/toascii.c hold only L2 symbols +# (the header gates their declarations) — all four must be omitted from a +# level-1 profile, so they join the GE_2 conditional list. Files with L1 +# bodies plus small L2 sections (strcoll.c, strdup.c) stay in VLIBC_CORE_SRCS +# and self-gate at level 1. +VLIBC_LEVEL2_SRCS = src/string/strlcpy.c src/string/strlcat.c \ + src/string/stpcpy.c src/string/memccpy.c \ + src/ctype/isascii.c src/ctype/toascii.c VLIBC_LEVEL3_SRCS = src/string/strcasestr.c vlibc_lib_LTLIBRARIES = libvlibc.la @@ -88,6 +112,7 @@ vlibc_include_HEADERS = \ include/errno.h \ include/setjmp.h \ include/assert.h \ + include/ctype.h \ include/cpio.h \ include/float.h \ include/iso646.h \ @@ -99,6 +124,7 @@ vlibc_include_HEADERS = \ include/stdbool.h \ include/stdckdint.h \ include/stdint.h \ + include/stdlib.h \ include/stdnoreturn.h \ include/tar.h \ include/tgmath.h \ @@ -232,7 +258,7 @@ VLIBC_TEST_CFLAGS = -DVLIBC_LEVEL=$(VLIBC_TEST_LEVEL) -fno-stack-protector \ -fno-pic -fno-pie check_PROGRAMS = test_syscall test_strerror test_setjmp test_headers \ - test_startup + test_startup test_malloc test_string test_ctype test_syscall_SOURCES = tests/syscall_test.c test_syscall_CFLAGS = $(VLIBC_TEST_CFLAGS) @@ -264,10 +290,31 @@ test_startup_DEPENDENCIES = crt1.o libvlibc-check.a test_startup_LINK = $(VLIBC_TEST_LINK) test_startup_LDADD = $(VLIBC_TEST_LDADD) +test_malloc_SOURCES = tests/test_malloc.c +test_malloc_CFLAGS = $(VLIBC_TEST_CFLAGS) +test_malloc_DEPENDENCIES = crt1.o libvlibc-check.a +test_malloc_LINK = $(VLIBC_TEST_LINK) +test_malloc_LDADD = $(VLIBC_TEST_LDADD) + +test_string_SOURCES = tests/test_string.c +test_string_CFLAGS = $(VLIBC_TEST_CFLAGS) +test_string_DEPENDENCIES = crt1.o libvlibc-check.a +test_string_LINK = $(VLIBC_TEST_LINK) +test_string_LDADD = $(VLIBC_TEST_LDADD) + +test_ctype_SOURCES = tests/test_ctype.c +test_ctype_CFLAGS = $(VLIBC_TEST_CFLAGS) +test_ctype_DEPENDENCIES = crt1.o libvlibc-check.a +test_ctype_LINK = $(VLIBC_TEST_LINK) +test_ctype_LDADD = $(VLIBC_TEST_LDADD) + # test_startup's default mode exits 42 by design, so it is NOT a bare TESTS # entry; tests/startup_modes.sh runs its full mode matrix and the -f failure -# scenarios of the other four binaries. +# scenarios of the other binaries. test_malloc/test_string/test_ctype default +# to the happy mode (exit 0 on all-pass) and are bare TESTS entries; their +# -f/-p modes stay runnable by hand. TESTS = test_syscall test_strerror test_setjmp test_headers \ + test_malloc test_string test_ctype \ tests/startup_modes.sh CLEANFILES = crt1.o libvlibc-check.a $(VLIBC_CHECK_OBJECTS) @@ -283,6 +330,7 @@ EXTRA_DIST = \ src/internal/atomic.h \ src/internal/errno.h \ src/internal/libc.h \ + src/internal/malloc.h \ src/internal/syscall.h \ src/internal/types.h \ src/start/start.h \