OpenOCD
time_support.h
Go to the documentation of this file.
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 
29 int64_t timeval_ms(void);
30 
31 struct duration {
32  struct timeval start;
33  struct timeval elapsed;
34 };
35 
37 int duration_start(struct duration *duration);
40 
42 float duration_elapsed(const struct duration *duration);
44 float duration_kbps(const struct duration *duration, size_t count);
45 
46 #endif /* OPENOCD_HELPER_TIME_SUPPORT_H */
struct timeval elapsed
Definition: time_support.h:33
struct timeval start
Definition: time_support.h:32
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
Definition: time_support.c:21
float duration_elapsed(const struct duration *duration)
Definition: time_support.c:83
int timeval_compare(const struct timeval *x, const struct timeval *y)
Definition: time_support.c:55
int timeval_add_time(struct timeval *result, long sec, long usec)
Definition: time_support.c:41
int duration_measure(struct duration *duration)
Update the duration->elapsed field to finish the duration measurement.
Definition: time_support.c:74
int duration_start(struct duration *duration)
Update the duration->start field to start the duration measurement.
Definition: time_support.c:69
int64_t timeval_ms(void)
float duration_kbps(const struct duration *duration, size_t count)
Definition: time_support.c:90
uint8_t count[4]
Definition: vdebug.c:22