blob: b8df7c31c747737a0f60577d80efa90591131ce1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#ifndef _PCILIB_TIMING_H
#define _PCILIB_TIMING_H
#include <sys/time.h>
#include <pcilib.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Add the specified number of microseconds to the time stored in \p tv
* @param[in,out] tv - timestamp
* @param[in] timeout - number of microseconds to add
* @return - error code or 0 for correctness
*/
int pcilib_add_timeout(struct timeval *tv, pcilib_timeout_t timeout);
/**
* Computes the deadline by adding the specified number of microseconds to the current timestamp
* @param[out] tv - the deadline
* @param[in] timeout - number of microseconds to add
* @return - error code or 0 for correctness
*/
int pcilib_calc_deadline(struct timeval *tv, pcilib_timeout_t timeout);
/**
* Check if we are within \p timeout microseconds before the specified deadline or already past it
* @param[in] tv - the deadline
* @param[in] timeout - maximum number of microseconds before deadline
* @return - 1 if we are within \p timeout microseconds before deadline or past it, 0 - otherwise
*/
int pcilib_check_deadline(struct timeval *tv, pcilib_timeout_t timeout);
/**
* Compute the remaining time to deadline
* @param[in] tv - the deadline
* @return - number of microseconds until deadline or 0 if we are already past it
*/
pcilib_timeout_t pcilib_calc_time_to_deadline(struct timeval *tv);
/**
* Executes sleep until the specified deadline
* Real-time capabilities are not used. TThe sleep could wake slightly after the specified deadline.
* @param[in] tv - the deadline
* @return - error code or 0 for correctness
*/
int pcilib_sleep_until_deadline(struct timeval *tv);
/**
* Computes the number of microseconds between 2 timestamps.
* This function expects that \p tve is after \p tvs.
* @param[in] tve - the end of the time interval
* @param[in] tvs - the beginning of the time interval
* @return - number of microseconds between two timestamps
*/
pcilib_timeout_t pcilib_timediff(struct timeval *tve, struct timeval *tvs);
/**
* Compares two timestamps
* @param[in] tv1 - the first timestamp
* @param[in] tv2 - the second timestamp
* @return - 0 if timestamps are equal, 1 if the first timestamp is after the second, or -1 if the second is after the first.
*/
int pcilib_timecmp(struct timeval *tv1, struct timeval *tv2);
#ifdef __cplusplus
}
#endif
#endif /* _PCILIB_TIMING_H */
|