Some of these changes actually fix broken comparisons which could
occasionally fail. Others just clean up the code and make it more clear.
Change-Id: I6c398bdc45fa0d2716f48a74822457d1351f81a5
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4380
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
ftbytes += presto->retval;
gettimeofday(&now, NULL);
ftbytes += presto->retval;
gettimeofday(&now, NULL);
- if ((now.tv_sec > timeout.tv_sec) ||
- ((now.tv_sec == timeout.tv_sec) && (now.tv_usec > timeout.tv_usec)))
+ if (timeval_compare(&now, &timeout) > 0)
gettimeofday(&now, NULL);
gettimeofday(&now, NULL);
- if (sample_count >= max_num_samples ||
- (now.tv_sec >= timeout.tv_sec && now.tv_usec >= timeout.tv_usec)) {
+ if (sample_count >= max_num_samples || timeval_compare(&now, &timeout) > 0) {
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
#include "embeddedice.h"
#include "register.h"
#include "embeddedice.h"
#include "register.h"
+#include <helper/time_support.h>
uint8_t field2_out[1];
int retval;
uint32_t hsact;
uint8_t field2_out[1];
int retval;
uint32_t hsact;
+ struct timeval timeout_end;
if (hsbit == EICE_COMM_CTRL_WBIT)
hsact = 1;
if (hsbit == EICE_COMM_CTRL_WBIT)
hsact = 1;
fields[2].in_value = NULL;
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
fields[2].in_value = NULL;
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
- gettimeofday(&lap, NULL);
+ gettimeofday(&timeout_end, NULL);
+ timeval_add_time(&timeout_end, 0, timeout * 1000);
do {
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
retval = jtag_execute_queue();
do {
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE);
retval = jtag_execute_queue();
return ERROR_OK;
gettimeofday(&now, NULL);
return ERROR_OK;
gettimeofday(&now, NULL);
- } while ((uint32_t)((now.tv_sec - lap.tv_sec) * 1000
- + (now.tv_usec - lap.tv_usec) / 1000) <= timeout);
+ } while (timeval_compare(&now, &timeout_end) <= 0);
LOG_ERROR("embeddedice handshake timeout");
return ERROR_TARGET_TIMEOUT;
LOG_ERROR("embeddedice handshake timeout");
return ERROR_TARGET_TIMEOUT;
samples[sample_count++] = reg_value;
gettimeofday(&now, NULL);
samples[sample_count++] = reg_value;
gettimeofday(&now, NULL);
- if ((sample_count >= max_num_samples) ||
- ((now.tv_sec >= timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec))) {
+ if ((sample_count >= max_num_samples) || timeval_compare(&now, &timeout) > 0) {
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
int target_register_timer_callback(int (*callback)(void *priv), int time_ms, int periodic, void *priv)
{
struct target_timer_callback **callbacks_p = &target_timer_callbacks;
int target_register_timer_callback(int (*callback)(void *priv), int time_ms, int periodic, void *priv)
{
struct target_timer_callback **callbacks_p = &target_timer_callbacks;
if (callback == NULL)
return ERROR_COMMAND_SYNTAX_ERROR;
if (callback == NULL)
return ERROR_COMMAND_SYNTAX_ERROR;
(*callbacks_p)->time_ms = time_ms;
(*callbacks_p)->removed = false;
(*callbacks_p)->time_ms = time_ms;
(*callbacks_p)->removed = false;
- gettimeofday(&now, NULL);
- (*callbacks_p)->when.tv_usec = now.tv_usec + (time_ms % 1000) * 1000;
- time_ms -= (time_ms % 1000);
- (*callbacks_p)->when.tv_sec = now.tv_sec + (time_ms / 1000);
- if ((*callbacks_p)->when.tv_usec > 1000000) {
- (*callbacks_p)->when.tv_usec = (*callbacks_p)->when.tv_usec - 1000000;
- (*callbacks_p)->when.tv_sec += 1;
- }
+ gettimeofday(&(*callbacks_p)->when, NULL);
+ timeval_add_time(&(*callbacks_p)->when, 0, time_ms * 1000);
(*callbacks_p)->priv = priv;
(*callbacks_p)->next = NULL;
(*callbacks_p)->priv = priv;
(*callbacks_p)->next = NULL;
static int target_timer_callback_periodic_restart(
struct target_timer_callback *cb, struct timeval *now)
{
static int target_timer_callback_periodic_restart(
struct target_timer_callback *cb, struct timeval *now)
{
- int time_ms = cb->time_ms;
- cb->when.tv_usec = now->tv_usec + (time_ms % 1000) * 1000;
- time_ms -= (time_ms % 1000);
- cb->when.tv_sec = now->tv_sec + time_ms / 1000;
- if (cb->when.tv_usec > 1000000) {
- cb->when.tv_usec = cb->when.tv_usec - 1000000;
- cb->when.tv_sec += 1;
- }
+ cb->when = *now;
+ timeval_add_time(&cb->when, 0, cb->time_ms * 1000L);
bool call_it = (*callback)->callback &&
((!checktime && (*callback)->periodic) ||
bool call_it = (*callback)->callback &&
((!checktime && (*callback)->periodic) ||
- now.tv_sec > (*callback)->when.tv_sec ||
- (now.tv_sec == (*callback)->when.tv_sec &&
- now.tv_usec >= (*callback)->when.tv_usec));
+ timeval_compare(&now, &(*callback)->when) >= 0);
if (call_it)
target_call_timer_callback(*callback, &now);
if (call_it)
target_call_timer_callback(*callback, &now);
break;
gettimeofday(&now, NULL);
break;
gettimeofday(&now, NULL);
- if ((sample_count >= max_num_samples) ||
- ((now.tv_sec >= timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec))) {
+ if ((sample_count >= max_num_samples) || timeval_compare(&now, &timeout) >= 0) {
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
LOG_INFO("Profiling completed. %" PRIu32 " samples.", sample_count);
break;
}
}
gettimeofday(&now, NULL);
}
gettimeofday(&now, NULL);
- if ((now.tv_sec > timeout.tv_sec) ||
- ((now.tv_sec == timeout.tv_sec) && (now.tv_usec > timeout.tv_usec))) {
+ if (timeval_compare(&now, &timeout) > 0) {
LOG_ERROR("time out reading TX register");
return ERROR_TARGET_TIMEOUT;
}
LOG_ERROR("time out reading TX register");
return ERROR_TARGET_TIMEOUT;
}
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)