helper: util: rewrite command 'ms' as COMMAND_HANDLER
Use full 64 bits in output; no reason to truncate at 32 bits. Change-Id: I433815a381e147731ff0da2c805170649a9bcf38 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7487 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
This commit is contained in:
parent
80fc9fabc6
commit
842a12f4ca
|
@ -13,28 +13,21 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "time_support.h"
|
#include "time_support.h"
|
||||||
|
|
||||||
static int jim_util_ms(Jim_Interp *interp,
|
COMMAND_HANDLER(handler_util_ms)
|
||||||
int argc,
|
|
||||||
Jim_Obj * const *argv)
|
|
||||||
{
|
{
|
||||||
if (argc != 1) {
|
if (CMD_ARGC != 0)
|
||||||
Jim_WrongNumArgs(interp, 1, argv, "ls ?dir?");
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||||
return JIM_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cast from 64 to 32 bit int works for 2's-compliment
|
command_print(CMD, "%" PRId64, timeval_ms());
|
||||||
* when calculating differences*/
|
|
||||||
Jim_SetResult(interp, Jim_NewIntObj(interp, (int)timeval_ms()));
|
|
||||||
|
|
||||||
return JIM_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct command_registration util_command_handlers[] = {
|
static const struct command_registration util_command_handlers[] = {
|
||||||
/* jim handlers */
|
|
||||||
{
|
{
|
||||||
.name = "ms",
|
.name = "ms",
|
||||||
.mode = COMMAND_ANY,
|
.mode = COMMAND_ANY,
|
||||||
.jim_handler = jim_util_ms,
|
.handler = handler_util_ms,
|
||||||
.help =
|
.help =
|
||||||
"Returns ever increasing milliseconds. Used to calculate differences in time.",
|
"Returns ever increasing milliseconds. Used to calculate differences in time.",
|
||||||
.usage = "",
|
.usage = "",
|
||||||
|
|
Loading…
Reference in New Issue