From 92e9e649459f45a5514f2c27219a25a3aaeeccbf Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 6 Jan 2019 12:32:44 -0500 Subject: [PATCH] Update CONTRIBUTING.md and make valtest --- CONTRIBUTING.md | 23 +++++++++++++++++++++++ Makefile | 6 +++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ecfc1f0..4a4911b6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,29 @@ may require changes before being merged. For janet code, the use lisp indentation with 2 spaces. One can use janet.vim to do this indentation, or approximate as close as possible. +## C style + +For changes to the VM and Core code, you will probably need to know C. Janet is programmed with +a subset of C99 that works with Microsoft Visual C++. This means most of C99 but with the following +omissions. + +* No Variable Length Arrays (yes these may work in newer MSVC compilers) +* No `restrict` +* Certain functions in the standard library are not always available + +In practice, this means programming for both MSVC on one hand and everything else on the other. +The code must also build with emscripten, even if some features are not available, although +this is not a priority. + +Code should compile warning free and run valgrind clean. I find that these two criteria are some +of the easiest ways to protect against a large number of bugs in an unsafe language like C. To check for +valgrind errors, run `make valtest` and check the output for undefined or flagged behavior. + +## Janet style + +All janet code in the project should be formatted similar to the code in core.janet. +The auto formatting from janet.vim will work well. + ## Suggesting Changes To suggest changes, open an issue on GitHub. Check GitHub for other issues diff --git a/Makefile b/Makefile index 0b8c56c7..d298fba4 100644 --- a/Makefile +++ b/Makefile @@ -136,15 +136,15 @@ repl: $(JANET_TARGET) debug: $(JANET_TARGET) $(DEBUGGER) ./$(JANET_TARGET) +VALGRIND_COMMAND=valgrind --leak-check=full + valgrind: $(JANET_TARGET) - valgrind --leak-check=full -v ./$(JANET_TARGET) + $(VALGRIND_COMMAND) ./$(JANET_TARGET) test: $(JANET_TARGET) $(TEST_PROGRAMS) for f in build/*.out; do "$$f" || exit; done for f in test/*.janet; do ./$(JANET_TARGET) "$$f" || exit; done -VALGRIND_COMMAND=valgrind --leak-check=full -v - valtest: $(JANET_TARGET) $(TEST_PROGRAMS) for f in build/*.out; do $(VALGRIND_COMMAND) "$$f" || exit; done for f in test/*.janet; do $(VALGRIND_COMMAND) ./$(JANET_TARGET) "$$f" || exit; done