]> git.gag.com Git - fw/openocd/blob - src/helper/util.c
rtos: Support looking up .lto_priv.0 appended to symbol name
[fw/openocd] / src / helper / util.c
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         },
42         COMMAND_REGISTRATION_DONE
43 };
44
45 int util_init(struct command_context *cmd_ctx)
46 {
47         return register_commands(cmd_ctx, NULL, util_command_handlers);
48 }