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 #include "util.h"
16 
17 COMMAND_HANDLER(handler_util_ms)
18 {
19  if (CMD_ARGC != 0)
21 
22  command_print(CMD, "%" PRId64, timeval_ms());
23 
24  return ERROR_OK;
25 }
26 
27 static const struct command_registration util_command_handlers[] = {
28  {
29  .name = "ms",
30  .mode = COMMAND_ANY,
31  .handler = handler_util_ms,
32  .help =
33  "Returns ever increasing milliseconds. Used to calculate differences in time.",
34  .usage = "",
35  },
37 };
38 
39 int util_init(struct command_context *cmd_ctx)
40 {
42 }
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:402
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
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:274
@ COMMAND_ANY
Definition: command.h:42
#define ERROR_OK
Definition: log.h:164
const char * name
Definition: command.h:235
int64_t timeval_ms(void)
#define NULL
Definition: usb.h:16
static const struct command_registration util_command_handlers[]
Definition: util.c:27
COMMAND_HANDLER(handler_util_ms)
Definition: util.c:17
int util_init(struct command_context *cmd_ctx)
Definition: util.c:39