summaryrefslogtreecommitdiffstats
path: root/tapset/timestamp.stp
blob: 67e2e73aa4e3a50754de64e9542a99e9a76808fd (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
// timestamp tapset
// Copyright (C) 2005-2006 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.


%{
#include <linux/time.h>
%}


// return processor cycle counter (if any)
function get_cycles:long () %{ /* pure */
  cycles_t c = get_cycles();
  THIS->__retvalue = (int64_t) c;
%}


// return in microseconds since epoch
function gettimeofday_us:long () %{ /* pure */
  struct timeval tm;
  do_gettimeofday (& tm);
  THIS->__retvalue = (tm.tv_sec * 1000000ULL) + (tm.tv_usec);
%}

// return in milliseconds since epoch
function gettimeofday_ms:long () %{ /* pure */
  struct timeval tm;
  do_gettimeofday (& tm);
  THIS->__retvalue = (tm.tv_sec * 1000ULL) + (tm.tv_usec / 1000);
%}

// return in seconds since epoch
function gettimeofday_s:long () %{ /* pure */
  struct timeval tm;
  do_gettimeofday (& tm);
  THIS->__retvalue = tm.tv_sec;
%}

// likewise jiffies, monotonic_clock ...