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