aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / argus / lane_b.mk
| 1 | # ARGUS-0 lane B: event ABI + ring transport. C only, no outside library. |
| 2 | # Run from native/argus: make -f lane_b.mk test-event fuzz-event test-ring bench-ring |
| 3 | # |
| 4 | # test-event ABI layout, round trip, known-answer digests, malformed input, secret-negative |
| 5 | # fuzz-event 1,000,000 random / bit-flipped buffers through decode (ASan + UBSan) |
| 6 | # test-ring watermarks, drop reporting, 10M-event two-thread SPSC run |
| 7 | # test-ring-tsan the same SPSC run (1M events) under ThreadSanitizer |
| 8 | # bench-ring push latency p50/p99, pops/s, saturation points, footprint |
| 9 | # |
| 10 | # macOS note (2026-09-28, macOS 26.6.2 + Apple clang 17): AddressSanitizer and |
| 11 | # ThreadSanitizer runtimes hang / crash on an empty program, so on that Mac run |
| 12 | # make -f lane_b.mk SANFLAGS="-fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" fuzz-event |
| 13 | # and run the ASan fuzz + test-ring-tsan on Linux. |
| 14 | |
| 15 | CC ?= cc |
| 16 | CFLAGS ?= -std=gnu11 -O2 -Wall -Wextra -Werror -fstack-protector-strong |
| 17 | SANFLAGS ?= -fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all |
| 18 | TSANFLAGS ?= -fsanitize=thread -fno-omit-frame-pointer |
| 19 | LANE_B_OUT ?= out/lane_b |
| 20 | # TSan on Linux aarch64 needs ASLR off ("unexpected memory mapping" otherwise). |
| 21 | TSAN_RUN ?= $(shell [ "$$(uname -s)" = Linux ] && command -v setarch >/dev/null 2>&1 && echo setarch $$(uname -m) -R) |
| 22 | |
| 23 | LANE_B_SRC = argus_event.c argus_ring.c sha256.c |
| 24 | LANE_B_HDR = argus_abi.h sha256.h |
| 25 | |
| 26 | $(LANE_B_OUT): |
| 27 | mkdir -p $(LANE_B_OUT) |
| 28 | |
| 29 | $(LANE_B_OUT)/test_argus_event: tests/test_argus_event.c $(LANE_B_SRC) $(LANE_B_HDR) | $(LANE_B_OUT) |
| 30 | $(CC) $(CFLAGS) -I. -o $@ tests/test_argus_event.c $(LANE_B_SRC) |
| 31 | |
| 32 | $(LANE_B_OUT)/fuzz_argus_event: tests/fuzz_argus_event.c $(LANE_B_SRC) $(LANE_B_HDR) | $(LANE_B_OUT) |
| 33 | $(CC) $(CFLAGS) $(SANFLAGS) -I. -o $@ tests/fuzz_argus_event.c $(LANE_B_SRC) |
| 34 | |
| 35 | $(LANE_B_OUT)/test_argus_ring: tests/test_argus_ring.c $(LANE_B_SRC) $(LANE_B_HDR) | $(LANE_B_OUT) |
| 36 | $(CC) $(CFLAGS) -pthread -I. -o $@ tests/test_argus_ring.c $(LANE_B_SRC) |
| 37 | |
| 38 | $(LANE_B_OUT)/test_argus_ring_tsan: tests/test_argus_ring.c $(LANE_B_SRC) $(LANE_B_HDR) | $(LANE_B_OUT) |
| 39 | $(CC) $(CFLAGS) $(TSANFLAGS) -pthread -I. -o $@ tests/test_argus_ring.c $(LANE_B_SRC) |
| 40 | |
| 41 | $(LANE_B_OUT)/bench_argus_ring: tests/bench_argus_ring.c $(LANE_B_SRC) $(LANE_B_HDR) | $(LANE_B_OUT) |
| 42 | $(CC) $(CFLAGS) -pthread -I. -o $@ tests/bench_argus_ring.c $(LANE_B_SRC) |
| 43 | |
| 44 | test-event: $(LANE_B_OUT)/test_argus_event |
| 45 | ./$(LANE_B_OUT)/test_argus_event |
| 46 | |
| 47 | fuzz-event: $(LANE_B_OUT)/fuzz_argus_event |
| 48 | ./$(LANE_B_OUT)/fuzz_argus_event 1000000 |
| 49 | |
| 50 | test-ring: $(LANE_B_OUT)/test_argus_ring |
| 51 | ./$(LANE_B_OUT)/test_argus_ring 10000000 |
| 52 | |
| 53 | test-ring-tsan: $(LANE_B_OUT)/test_argus_ring_tsan |
| 54 | $(TSAN_RUN) ./$(LANE_B_OUT)/test_argus_ring_tsan 1000000 |
| 55 | |
| 56 | bench-ring: $(LANE_B_OUT)/bench_argus_ring |
| 57 | ./$(LANE_B_OUT)/bench_argus_ring |
| 58 | |
| 59 | lane-b-clean: |
| 60 | rm -rf $(LANE_B_OUT) |
| 61 | |
| 62 | .PHONY: test-event fuzz-event test-ring test-ring-tsan bench-ring lane-b-clean |