OpenOCD
util.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2010 by Øyvind Harboe *
5  ***************************************************************************/
6 
7 /* this file contains various functionality useful to standalone systems */
8 
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12 
13 #include "log.h"
14 #include "time_support.h"
15 
16 static int jim_util_ms(Jim_Interp *interp,
17  int argc,
18  Jim_Obj * const *argv)
19 {
20  if (argc != 1) {
21  Jim_WrongNumArgs(interp, 1, argv, "ls ?dir?");
22  return JIM_ERR;
23  }
24 
25  /* Cast from 64 to 32 bit int works for 2's-compliment
26  * when calculating differences*/
27  Jim_SetResult(interp, Jim_NewIntObj(interp, (int)timeval_ms()));
28 
29  return JIM_OK;
30 }
31 
32 static const struct command_registration util_command_handlers[] = {
33  /* jim handlers */
34  {
35  .name = "ms",
36  .mode = COMMAND_ANY,
37  .jim_handler = jim_util_ms,
38  .help =
39  "Returns ever increasing milliseconds. Used to calculate differences in time.",
40  .usage = "",
41  },
43 };
44 
45 int util_init(struct command_context *cmd_ctx)
46 {
48 }
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
Definition: command.h:268
@ COMMAND_ANY
Definition: command.h:42
const char * name
Definition: command.h:229
int64_t timeval_ms(void)
#define NULL
Definition: usb.h:16
static int jim_util_ms(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Definition: util.c:16
static const struct command_registration util_command_handlers[]
Definition: util.c:32
int util_init(struct command_context *cmd_ctx)
Definition: util.c:45