summaryrefslogtreecommitdiffstats
path: root/tapset/timestamp_functions.stp
diff options
context:
space:
mode:
Diffstat (limited to 'tapset/timestamp_functions.stp')
-rw-r--r--tapset/timestamp_functions.stp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tapset/timestamp_functions.stp b/tapset/timestamp_functions.stp
new file mode 100644
index 00000000..f8e1ea4e
--- /dev/null
+++ b/tapset/timestamp_functions.stp
@@ -0,0 +1,19 @@
+%{
+#include <linux/time.h>
+%}
+
+// return in milliseconds since epoch
+function gettimeofday_ms () %{
+ struct timeval tm;
+ do_gettimeofday (& tm);
+ THIS->__retvalue = (tm.tv_sec * 1000) + (tm.tv_usec / 1000);
+%}
+
+// return in seconds since epoch
+function gettimeofday_s () %{
+ struct timeval tm;
+ do_gettimeofday (& tm);
+ THIS->__retvalue = tm.tv_sec;
+%}
+
+// likewise jiffies, monotonic_clock ...