Skip to content

Commit

Permalink
Fix building the RVFI model as C++
Browse files Browse the repository at this point in the history
While changing surrounding lines also remove two unused variables.
  • Loading branch information
arichardson committed Feb 28, 2025
1 parent 100edef commit a3111ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion c_emulator/riscv_sail.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ extern bool zrvfi_int_data_present;
void zrvfi_get_int_data(sail_bits *rop, unit);
extern bool zrvfi_mem_data_present;
void zrvfi_get_mem_data(sail_bits *rop, unit);
mach_bits zrvfi_get_v2_trace_sizze(unit);
void zrvfi_get_v2_support_packet(sail_bits *rop, unit);

// Debugging prints
Expand Down
20 changes: 10 additions & 10 deletions c_emulator/riscv_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ void rvfi_send_trace(unsigned version)
if (version == 1) {
get_and_send_rvfi_packet(zrvfi_get_exec_packet_v1);
} else if (version == 2) {
mach_bits trace_size = zrvfi_get_v2_trace_sizze(UNIT);
get_and_send_rvfi_packet(zrvfi_get_exec_packet_v2);
if (zrvfi_int_data_present)
get_and_send_rvfi_packet(zrvfi_get_int_data);
Expand All @@ -698,9 +697,6 @@ void run_sail(void)
/* initialize the step number */
mach_int step_no = 0;
int insn_cnt = 0;
#ifdef RVFI_DII
bool need_instr = true;
#endif

struct timeval interval_start;
if (gettimeofday(&interval_start, NULL) < 0) {
Expand Down Expand Up @@ -779,12 +775,15 @@ void run_sail(void)
(intmax_t)insn);
exit(1);
}
rvfi_trace_version
= insn; // From now on send traces in the requested format
// From now on send traces in the requested format
rvfi_trace_version = insn;
struct {
char msg[8];
uint64_t version;
} version_response = {"version=", rvfi_trace_version};
} version_response = {
{'v', 'e', 'r', 's', 'i', 'o', 'n', '='},
rvfi_trace_version
};
if (write(rvfi_dii_sock, &version_response, sizeof(version_response))
!= sizeof(version_response)) {
fprintf(stderr, "Sending version response failed: %s\n",
Expand Down Expand Up @@ -924,9 +923,10 @@ int main(int argc, char **argv)
strerror(errno));
return 1;
}
struct sockaddr_in addr = {.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = htons(rvfi_dii_port)};
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons(rvfi_dii_port);
if (bind(listen_sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
fprintf(stderr, "Unable to set bind socket: %s\n", strerror(errno));
return 1;
Expand Down

0 comments on commit a3111ed

Please sign in to comment.