flash/nor/at91samd: Use 32-bit register writes for ST-Link compat
[fw/openocd] / src / helper / time_support.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
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  ***************************************************************************/
13
14 #ifndef OPENOCD_HELPER_TIME_SUPPORT_H
15 #define OPENOCD_HELPER_TIME_SUPPORT_H
16
17 #include <time.h>
18 #include "types.h"
19
20 #ifdef HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #endif
23
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);
27
28 /** @returns gettimeofday() timeval as 64-bit in ms */
29 int64_t timeval_ms(void);
30
31 struct duration {
32         struct timeval start;
33         struct timeval elapsed;
34 };
35
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);
40
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);
45
46 #endif /* OPENOCD_HELPER_TIME_SUPPORT_H */