diff options
author | Andreas Färber <afaerber@suse.de> | 2016-05-22 04:34:04 +0200 |
---|---|---|
committer | Andreas Fritiofson <andreas.fritiofson@gmail.com> | 2016-07-19 10:45:16 +0100 |
commit | f19ac83152b54a204b8148815a538d868973e1e1 (patch) | |
tree | 381a04c00bd20dd508d6020f869ea3dd160de933 /src/target | |
parent | f4496b25e3040e29b9bc78dd5bf8ac8128c09a1e (diff) | |
download | riscv-openocd-f19ac83152b54a204b8148815a538d868973e1e1.zip riscv-openocd-f19ac83152b54a204b8148815a538d868973e1e1.tar.gz riscv-openocd-f19ac83152b54a204b8148815a538d868973e1e1.tar.bz2 |
Fix usage of timeval_ms()
First, fix the timeval_ms() implementation to not have K&R but ANSI
argument semantics by adding a missing void.
timeval_ms() returns an int64_t, not uint64_t or long long. Consistently
use int64_t for variables and PRI*64 as format string.
While at it, change a few related variables to bool for clarity.
Note that timeval_ms() may return a negative error code, but not a
single caller checks for that.
Change-Id: I27cf83e75b3e9a8913f6c43e98a281bea77aac13
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-on: http://openocd.zylin.com/3499
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/adi_v5_jtag.c | 2 | ||||
-rw-r--r-- | src/target/arm11.c | 4 | ||||
-rw-r--r-- | src/target/arm11_dbgtap.c | 10 | ||||
-rw-r--r-- | src/target/arm720t.c | 2 | ||||
-rw-r--r-- | src/target/arm7_9_common.c | 4 | ||||
-rw-r--r-- | src/target/arm920t.c | 4 | ||||
-rw-r--r-- | src/target/arm926ejs.c | 6 | ||||
-rw-r--r-- | src/target/mips32_pracc.c | 4 | ||||
-rw-r--r-- | src/target/target.c | 20 | ||||
-rw-r--r-- | src/target/target.h | 2 |
10 files changed, 29 insertions, 29 deletions
diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c index 272d308..36d5cad 100644 --- a/src/target/adi_v5_jtag.c +++ b/src/target/adi_v5_jtag.c @@ -357,7 +357,7 @@ static int jtagdp_overrun_check(struct adiv5_dap *dap) int retval; struct dap_cmd *el, *tmp, *prev = NULL; int found_wait = 0; - uint64_t time_now; + int64_t time_now; LIST_HEAD(replay_list); /* make sure all queued transactions are complete */ diff --git a/src/target/arm11.c b/src/target/arm11.c index 32c244f..5f16073 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -390,7 +390,7 @@ static int arm11_halt(struct target *target) break; - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); if (i >= 1000) { @@ -512,7 +512,7 @@ static int arm11_resume(struct target *target, int current, break; - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); if (i >= 1000) { diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index 96e6891..2232b3e 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -408,7 +408,7 @@ int arm11_run_instr_no_data(struct arm11_common *arm11, if (flag) break; - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); @@ -491,7 +491,7 @@ int arm11_run_instr_data_to_core(struct arm11_common *arm11, JTAG_DEBUG("DTR Ready %d nRetry %d", Ready, nRetry); - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); @@ -523,7 +523,7 @@ int arm11_run_instr_data_to_core(struct arm11_common *arm11, JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d", (unsigned) Data, Ready, nRetry); - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); @@ -787,7 +787,7 @@ int arm11_run_instr_data_from_core(struct arm11_common *arm11, JTAG_DEBUG("DTR Data %08x Ready %d nRetry %d", (unsigned) Data, Ready, nRetry); - long long then = 0; + int64_t then = 0; if (i == 1000) then = timeval_ms(); @@ -922,7 +922,7 @@ int arm11_sc7_run(struct arm11_common *arm11, struct arm11_sc7_action *actions, if (Ready) break; - long long then = 0; + int64_t then = 0; if (i_n == 1000) then = timeval_ms(); diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 49b72fe..3991e19 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -336,7 +336,7 @@ static int arm720t_soft_reset_halt(struct target *target) if (retval != ERROR_OK) return retval; - long long then = timeval_ms(); + int64_t then = timeval_ms(); int timeout; while (!(timeout = ((timeval_ms()-then) > 1000))) { if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) { diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 6ee2b92..c1d5c79 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -634,8 +634,8 @@ int arm7_9_execute_sys_speed(struct target *target) if (retval != ERROR_OK) return retval; - long long then = timeval_ms(); - int timeout; + int64_t then = timeval_ms(); + bool timeout; while (!(timeout = ((timeval_ms()-then) > 1000))) { /* read debug status register */ embeddedice_read_reg(dbg_stat); diff --git a/src/target/arm920t.c b/src/target/arm920t.c index aafc44a..2c96d19 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -751,8 +751,8 @@ int arm920t_soft_reset_halt(struct target *target) if (retval != ERROR_OK) return retval; - long long then = timeval_ms(); - int timeout; + int64_t then = timeval_ms(); + bool timeout; while (!(timeout = ((timeval_ms()-then) > 1000))) { if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) { embeddedice_read_reg(dbg_stat); diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 397859b..d7c043e 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -87,7 +87,7 @@ static int arm926ejs_cp15_read(struct target *target, uint32_t op1, uint32_t op2 jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE); - long long then = timeval_ms(); + int64_t then = timeval_ms(); for (;;) { /* rescan with NOP, to wait for the access to complete */ @@ -173,7 +173,7 @@ static int arm926ejs_cp15_write(struct target *target, uint32_t op1, uint32_t op jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE); - long long then = timeval_ms(); + int64_t then = timeval_ms(); for (;;) { /* rescan with NOP, to wait for the access to complete */ @@ -546,7 +546,7 @@ int arm926ejs_soft_reset_halt(struct target *target) if (retval != ERROR_OK) return retval; - long long then = timeval_ms(); + int64_t then = timeval_ms(); int timeout; while (!(timeout = ((timeval_ms()-then) > 1000))) { if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) { diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c index 5c27f0a..7cc0424 100644 --- a/src/target/mips32_pracc.c +++ b/src/target/mips32_pracc.c @@ -86,7 +86,7 @@ struct mips32_pracc_context { static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl) { uint32_t ejtag_ctrl; - long long then = timeval_ms(); + int64_t then = timeval_ms(); /* wait for the PrAcc to become "1" */ mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL); @@ -100,7 +100,7 @@ static int wait_for_pracc_rw(struct mips_ejtag *ejtag_info, uint32_t *ctrl) if (ejtag_ctrl & EJTAG_CTRL_PRACC) break; - int timeout = timeval_ms() - then; + int64_t timeout = timeval_ms() - then; if (timeout > 1000) { LOG_DEBUG("DEBUGMODULE: No memory access in progress!"); return ERROR_JTAG_DEVICE_ERROR; diff --git a/src/target/target.c b/src/target/target.c index d71828c..084aea8 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -532,7 +532,7 @@ int target_poll(struct target *target) if (target->state == TARGET_HALTED) target->halt_issued = false; else { - long long t = timeval_ms() - target->halt_issued_time; + int64_t t = timeval_ms() - target->halt_issued_time; if (t > DEFAULT_HALT_TIMEOUT) { target->halt_issued = false; LOG_INFO("Halt timed out, wake up GDB."); @@ -2446,9 +2446,9 @@ static int sense_handler(void) if (powerRestored) runPowerRestore = 1; - long long current = timeval_ms(); - static long long lastPower; - int waitMore = lastPower + 2000 > current; + int64_t current = timeval_ms(); + static int64_t lastPower; + bool waitMore = lastPower + 2000 > current; if (powerDropout && !waitMore) { runPowerDropout = 1; lastPower = current; @@ -2461,7 +2461,7 @@ static int sense_handler(void) int srstDeasserted; srstDeasserted = prevSrstAsserted && !srstAsserted; - static long long lastSrst; + static int64_t lastSrst; waitMore = lastSrst + 2000 > current; if (srstDeasserted && !waitMore) { runSrstDeasserted = 1; @@ -2771,8 +2771,8 @@ COMMAND_HANDLER(handle_wait_halt_command) int target_wait_state(struct target *target, enum target_state state, int ms) { int retval; - long long then = 0, cur; - int once = 1; + int64_t then = 0, cur; + bool once = true; for (;;) { retval = target_poll(target); @@ -2782,7 +2782,7 @@ int target_wait_state(struct target *target, enum target_state state, int ms) break; cur = timeval_ms(); if (once) { - once = 0; + once = false; then = timeval_ms(); LOG_DEBUG("waiting for target %s...", Jim_Nvp_value2name_simple(nvp_target_state, state)->name); @@ -5664,7 +5664,7 @@ COMMAND_HANDLER(handle_fast_load_command) return ERROR_FAIL; } int i; - int ms = timeval_ms(); + int64_t ms = timeval_ms(); int size = 0; int retval = ERROR_OK; for (i = 0; i < fastload_num; i++) { @@ -5678,7 +5678,7 @@ COMMAND_HANDLER(handle_fast_load_command) size += fastload[i].length; } if (retval == ERROR_OK) { - int after = timeval_ms(); + int64_t after = timeval_ms(); command_print(CMD_CTX, "Loaded image %f kBytes/s", (float)(size/1024.0)/((float)(after-ms)/1000.0)); } return retval; diff --git a/src/target/target.h b/src/target/target.h index bce3110..0cee117 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -175,7 +175,7 @@ struct target { int display; /* display async info in telnet session. Do not display * lots of halted/resumed info when stepping in debugger. */ bool halt_issued; /* did we transition to halted state? */ - long long halt_issued_time; /* Note time when halt was issued */ + int64_t halt_issued_time; /* Note time when halt was issued */ bool dbgbase_set; /* By default the debug base is not set */ uint32_t dbgbase; /* Really a Cortex-A specific option, but there is no |