summaryrefslogtreecommitdiffstats
path: root/pcilib/timing.h
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-03-02 10:28:04 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-03-02 10:28:04 +0100
commit8e7c95957ee73d6c11ef28f7c0e2319a11103783 (patch)
tree83df220932b3d88e071eda4c756e485dd48d50e9 /pcilib/timing.h
parent8719b84a95805d109e21c20f05a0164315e1b38a (diff)
parent867bddcf7be374221a04b7ae89f93a5f5d703ee6 (diff)
downloadpcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.gz
pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.bz2
pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.xz
pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.zip
Merge with http://ufo.kit.edu/ufo/log/csa/pcitool 362 revision
Diffstat (limited to 'pcilib/timing.h')
-rw-r--r--pcilib/timing.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/pcilib/timing.h b/pcilib/timing.h
index 630df44..b8df7c3 100644
--- a/pcilib/timing.h
+++ b/pcilib/timing.h
@@ -8,14 +8,63 @@
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);
-int pcilib_check_deadline(struct timeval *tve, pcilib_timeout_t timeout);
-pcilib_timeout_t pcilib_calc_time_to_deadline(struct timeval *tve);
+
+/**
+ * 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);
-int pcilib_timecmp(struct timeval *tv1, struct timeval *tv2);
+
+/**
+ * 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
}