flash/nor/rp2040: check target halted before flash operation
[openocd.git] / src / helper / time_support.h
blobc984296819a3c7149e265ef38559b34202e13795
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2006 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
6 * *
7 * Copyright (C) 2007,2008 Øyvind Harboe *
8 * oyvind.harboe@zylin.com *
9 * *
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
17 #include <time.h>
18 #include "types.h"
20 #ifdef HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #endif
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);
31 struct duration {
32 struct timeval start;
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 */