diff options
author | Alexander Richardson <alexrichardson@google.com> | 2023-06-15 06:28:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-15 08:28:49 -0500 |
commit | 9b477812019a78510ebc7f4c7b7efbf378e64a42 (patch) | |
tree | c338d406fff3c7a06df1a24c1ce895fa6f21b1fd /c_emulator/riscv_prelude.c | |
parent | 2d214136ce4da767d926bc18ff53478181bc729b (diff) | |
download | sail-riscv-9b477812019a78510ebc7f4c7b7efbf378e64a42.zip sail-riscv-9b477812019a78510ebc7f4c7b7efbf378e64a42.tar.gz sail-riscv-9b477812019a78510ebc7f4c7b7efbf378e64a42.tar.bz2 |
Add a clang-format configuration and reformat C code (#261)
* Add a clang-format configuration and reformat C code
From my testing it turns out the built-in WebKit style is the closest to
the current style. I added a few config options to further reduce the
diff and I think the current output looks reasonable.
In the future it would be good to add a CI and pre-commit check to enforce
that all C code is consistently formatted to reduce the need for reviewers
to look for formatting issues.
* Fix formatting of commented-out reservation debug code
Use an empty-by-default macro instead of commented-out fprintf calls.
This way clang-format can format the calls sensibly and it's easier
to enable the debug prints.
* Improve formatting of fprintf call in set_config_print()
Clang-format does not like long string literals, so split this manually
to format the call sensibly.
* Fix formatting of function pointer typedef
Clang-format gets this wrong `*` is part of the typedef.
* Improve formatting of getopt_long call
* Fix odd fprintf continuation by splitting long string literal
Diffstat (limited to 'c_emulator/riscv_prelude.c')
-rw-r--r-- | c_emulator/riscv_prelude.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/c_emulator/riscv_prelude.c b/c_emulator/riscv_prelude.c index 92f8415..cd2ab70 100644 --- a/c_emulator/riscv_prelude.c +++ b/c_emulator/riscv_prelude.c @@ -9,25 +9,29 @@ unit print_string(sail_string prefix, sail_string msg) unit print_instr(sail_string s) { - if (config_print_instr) printf("%s\n", s); + if (config_print_instr) + printf("%s\n", s); return UNIT; } unit print_reg(sail_string s) { - if (config_print_reg) printf("%s\n", s); + if (config_print_reg) + printf("%s\n", s); return UNIT; } unit print_mem_access(sail_string s) { - if (config_print_mem_access) printf("%s\n", s); + if (config_print_mem_access) + printf("%s\n", s); return UNIT; } unit print_platform(sail_string s) { - if (config_print_platform) printf("%s\n", s); + if (config_print_platform) + printf("%s\n", s); return UNIT; } |