aboutsummaryrefslogtreecommitdiff
path: root/c_emulator/riscv_sail.h
diff options
context:
space:
mode:
authorAlexander Richardson <alexrichardson@google.com>2023-06-15 06:28:49 -0700
committerGitHub <noreply@github.com>2023-06-15 08:28:49 -0500
commit9b477812019a78510ebc7f4c7b7efbf378e64a42 (patch)
treec338d406fff3c7a06df1a24c1ce895fa6f21b1fd /c_emulator/riscv_sail.h
parent2d214136ce4da767d926bc18ff53478181bc729b (diff)
downloadsail-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_sail.h')
-rw-r--r--c_emulator/riscv_sail.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/c_emulator/riscv_sail.h b/c_emulator/riscv_sail.h
index bc5ce04..da29c2b 100644
--- a/c_emulator/riscv_sail.h
+++ b/c_emulator/riscv_sail.h
@@ -6,7 +6,9 @@ typedef int unit;
#define UNIT 0
typedef uint64_t mach_bits;
-struct zMisa {mach_bits zMisa_chunk_0;};
+struct zMisa {
+ mach_bits zMisa_chunk_0;
+};
extern struct zMisa zmisa;
void model_init(void);
@@ -17,9 +19,9 @@ bool zstep(sail_int);
unit ztick_clock(unit);
unit ztick_platform(unit);
-unit z_set_Misa_C(struct zMisa*, mach_bits);
-unit z_set_Misa_D(struct zMisa*, mach_bits);
-unit z_set_Misa_F(struct zMisa*, mach_bits);
+unit z_set_Misa_C(struct zMisa *, mach_bits);
+unit z_set_Misa_D(struct zMisa *, mach_bits);
+unit z_set_Misa_F(struct zMisa *, mach_bits);
#ifdef RVFI_DII
unit zext_rvfi_init(unit);
@@ -54,11 +56,9 @@ extern uint32_t zcur_privilege;
extern mach_bits zPC;
-extern mach_bits
- zx1, zx2, zx3, zx4, zx5, zx6, zx7,
- zx8, zx9, zx10, zx11, zx12, zx13, zx14, zx15,
- zx16, zx17, zx18, zx19, zx20, zx21, zx22, zx23,
- zx24, zx25, zx26, zx27, zx28, zx29, zx30, zx31;
+extern mach_bits zx1, zx2, zx3, zx4, zx5, zx6, zx7, zx8, zx9, zx10, zx11, zx12,
+ zx13, zx14, zx15, zx16, zx17, zx18, zx19, zx20, zx21, zx22, zx23, zx24,
+ zx25, zx26, zx27, zx28, zx29, zx30, zx31;
extern mach_bits zmstatus;
extern mach_bits zmepc, zmtval;
@@ -66,7 +66,9 @@ extern mach_bits zsepc, zstval;
extern mach_bits zfloat_result, zfloat_fflags;
-struct zMcause {mach_bits zMcause_chunk_0;};
+struct zMcause {
+ mach_bits zMcause_chunk_0;
+};
extern struct zMcause zmcause, zscause;
extern mach_bits zminstret;