Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 line
1.9 KiB

  1. # GNU make / gmake. Native target requires an illumos 64-bit compiler + headers.
  2. CC = gcc
  3. CPPFLAGS = -D__EXTENSIONS__ -D_POSIX_C_SOURCE=200809L -Isrc
  4. CFLAGS = -std=c99 -m64 -O2 -Wall -Wextra -Werror -Wformat=2
  5. LDLIBS = -lkstat -lrt
  6. SOURCES = src/main.c src/core.c src/config.c src/support.c src/illumos.c
  7. TESTFLAGS = -std=c99 -O1 -g -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Isrc -Wall -Wextra -Werror -Wformat=2 -pedantic
  8. .PHONY: all native-check test test-sanitize portability clean
  9. all: o6h-memory-guard
  10. native-check:
  11. @test "`uname -s`" = SunOS || { echo "Native build requires SmartOS/illumos; use make test and make portability here."; exit 1; }
  12. o6h-memory-guard: $(SOURCES) src/guard.h | native-check
  13. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(SOURCES) $(LDLIBS)
  14. test-guard: tests/test_guard.c src/core.c src/config.c src/guard.h
  15. $(CC) $(TESTFLAGS) -o $@ tests/test_guard.c src/core.c src/config.c
  16. test-runtime: tests/test_runtime.c src/main.c src/core.c src/config.c src/guard.h
  17. $(CC) $(TESTFLAGS) -o $@ tests/test_runtime.c src/core.c src/config.c
  18. test: test-guard test-runtime
  19. ./test-guard
  20. ./test-runtime
  21. test-sanitize:
  22. $(CC) $(TESTFLAGS) -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-guard tests/test_guard.c src/core.c src/config.c
  23. ./test-sanitize-guard
  24. $(CC) $(TESTFLAGS) -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-runtime tests/test_runtime.c src/core.c src/config.c
  25. ./test-sanitize-runtime
  26. # Local API sketches only: NOT real illumos headers, ABI, linking or runtime validation.
  27. portability:
  28. $(CC) $(TESTFLAGS) -Itests/api-sketch -fsyntax-only $(SOURCES)
  29. @for source in $(SOURCES); do $(CC) $(TESTFLAGS) -Itests/api-sketch -fanalyzer -c $$source -o /dev/null || exit 1; done
  30. sh -n install.sh
  31. xmllint --nonet --noout smf/o6h-memory-guard.xml
  32. clean:
  33. rm -f o6h-memory-guard test-guard test-runtime test-sanitize-guard test-sanitize-runtime