File: timestamp_gtod.stp

package info (click to toggle)
systemtap 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,436 kB
  • sloc: cpp: 72,388; ansic: 58,430; xml: 47,797; exp: 40,417; sh: 10,793; python: 2,759; perl: 2,252; tcl: 1,305; makefile: 1,119; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (57 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download | duplicates (8)
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
// timestamp tapset -- gettimeofday variants
// Copyright (C) 2005-2009 Red Hat Inc.
// Copyright (C) 2006 Intel Corporation.
//
// 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.

%{
#define STAP_NEED_GETTIMEOFDAY 1
%}


/**
 * sfunction gettimeofday_ns - Number of nanoseconds since UNIX epoch
 *
 * Description: This function returns the number of nanoseconds
 * since the UNIX epoch.
 */
function gettimeofday_ns:long () %{ /* pure */ /* unprivileged */
  /* NOTE: we can't use do_gettimeofday because we could be called from a
   * context where xtime_lock is already held.  See bug #2525. */
  STAP_RETVALUE = _stp_gettimeofday_ns();
  if (STAP_RETVALUE < 0)
    CONTEXT->last_error = "gettimeofday not initialized";
%}

/**
 * sfunction gettimeofday_us - Number of microseconds since UNIX epoch
 *
 * Description: This function returns the number of microseconds
 * since the UNIX epoch.
 */
function gettimeofday_us:long () {
  return gettimeofday_ns() / 1000;
}

/**
 * sfunction gettimeofday_ms - Number of milliseconds since UNIX epoch
 *
 * Description: This function returns the number of milliseconds
 * since the UNIX epoch.
 */
function gettimeofday_ms:long () {
  return gettimeofday_ns() / 1000000;
}

/**
 * sfunction gettimeofday_s - Number of seconds since UNIX epoch
 *
 * Description: This function returns the number of seconds since
 * the UNIX epoch.
 */
function gettimeofday_s:long () {
  return gettimeofday_ns() / 1000000000;
}