1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2006 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
10 * Copyright (C) 2008 by Spencer Oliver *
11 * spen@spen-soft.co.uk *
12 ***************************************************************************/
14 #ifndef OPENOCD_HELPER_TIME_SUPPORT_H
15 #define OPENOCD_HELPER_TIME_SUPPORT_H
20 #ifdef HAVE_SYS_TIME_H
24 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
25 int timeval_add_time(struct timeval *result, long sec, long usec);
26 int timeval_compare(const struct timeval *x, const struct timeval *y);
28 /** @returns gettimeofday() timeval as 64-bit in ms */
29 int64_t timeval_ms(void);
33 struct timeval elapsed;
36 /** Update the duration->start field to start the @a duration measurement. */
37 int duration_start(struct duration *duration);
38 /** Update the duration->elapsed field to finish the @a duration measurement. */
39 int duration_measure(struct duration *duration);
41 /** @returns Elapsed time in seconds. */
42 float duration_elapsed(const struct duration *duration);
43 /** @returns KB/sec for the elapsed @a duration and @a count bytes. */
44 float duration_kbps(const struct duration *duration, size_t count);
46 #endif /* OPENOCD_HELPER_TIME_SUPPORT_H */