2022-06-26 22:58:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
2006-06-02 10:36:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Dominic Rath *
|
|
|
|
* Dominic.Rath@gmx.de *
|
2008-07-25 06:54:17 +00:00
|
|
|
* *
|
2009-07-17 19:54:25 +00:00
|
|
|
* Copyright (C) 2007,2008 Øyvind Harboe *
|
2008-07-25 06:54:17 +00:00
|
|
|
* oyvind.harboe@zylin.com *
|
2008-09-20 10:50:53 +00:00
|
|
|
* *
|
|
|
|
* Copyright (C) 2008 by Spencer Oliver *
|
|
|
|
* spen@spen-soft.co.uk *
|
2006-06-02 10:36:31 +00:00
|
|
|
***************************************************************************/
|
2012-01-30 14:31:21 +00:00
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#ifndef OPENOCD_HELPER_TIME_SUPPORT_H
|
|
|
|
#define OPENOCD_HELPER_TIME_SUPPORT_H
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2021-01-08 22:48:43 +00:00
|
|
|
#include <time.h>
|
2021-04-19 20:04:30 +00:00
|
|
|
#include "types.h"
|
2021-01-08 22:48:43 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
2008-04-09 05:55:23 +00:00
|
|
|
#endif
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2009-11-08 07:20:33 +00:00
|
|
|
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
|
2009-11-09 13:45:57 +00:00
|
|
|
int timeval_add_time(struct timeval *result, long sec, long usec);
|
2018-01-24 22:22:37 +00:00
|
|
|
int timeval_compare(const struct timeval *x, const struct timeval *y);
|
2006-06-02 10:36:31 +00:00
|
|
|
|
2012-02-06 11:27:04 +00:00
|
|
|
/** @returns gettimeofday() timeval as 64-bit in ms */
|
2009-11-09 13:45:57 +00:00
|
|
|
int64_t timeval_ms(void);
|
2009-11-08 07:20:33 +00:00
|
|
|
|
2012-01-30 14:31:21 +00:00
|
|
|
struct duration {
|
2007-03-15 13:36:44 +00:00
|
|
|
struct timeval start;
|
2009-11-08 07:20:33 +00:00
|
|
|
struct timeval elapsed;
|
|
|
|
};
|
|
|
|
|
2012-02-06 11:27:04 +00:00
|
|
|
/** Update the duration->start field to start the @a duration measurement. */
|
2009-11-08 07:20:33 +00:00
|
|
|
int duration_start(struct duration *duration);
|
2021-01-28 12:34:51 +00:00
|
|
|
/** Update the duration->elapsed field to finish the @a duration measurement. */
|
2009-11-08 07:20:33 +00:00
|
|
|
int duration_measure(struct duration *duration);
|
2007-03-15 13:36:44 +00:00
|
|
|
|
2012-02-06 11:27:04 +00:00
|
|
|
/** @returns Elapsed time in seconds. */
|
2016-02-13 09:54:52 +00:00
|
|
|
float duration_elapsed(const struct duration *duration);
|
2012-02-06 11:27:04 +00:00
|
|
|
/** @returns KB/sec for the elapsed @a duration and @a count bytes. */
|
2016-02-13 09:54:52 +00:00
|
|
|
float duration_kbps(const struct duration *duration, size_t count);
|
2007-03-15 13:36:44 +00:00
|
|
|
|
2015-09-21 19:07:46 +00:00
|
|
|
#endif /* OPENOCD_HELPER_TIME_SUPPORT_H */
|