Debian Codegraph @

tapset/linux/timestamp_gtod.stp

raw
1 // timestamp tapset -- gettimeofday variants
2 // Copyright (C) 2005-2009 Red Hat Inc.
3 // Copyright (C) 2006 Intel Corporation.
4 //
5 // This file is part of systemtap, and is free software. You can
6 // redistribute it and/or modify it under the terms of the GNU General
7 // Public License (GPL); either version 2, or (at your option) any
8 // later version.
9
10 %{
11 #define STAP_NEED_GETTIMEOFDAY 1
12 %}
13
14
15 /**
16 * sfunction gettimeofday_ns - Number of nanoseconds since UNIX epoch
17 *
18 * Description: This function returns the number of nanoseconds
19 * since the UNIX epoch.
20 */
21 function gettimeofday_ns:long () %{ /* pure */ /* unprivileged */
22 /* NOTE: we can't use do_gettimeofday because we could be called from a
23 * context where xtime_lock is already held. See bug #2525. */
24 STAP_RETVALUE = _stp_gettimeofday_ns();
25 if (STAP_RETVALUE < 0)
26 CONTEXT->last_error = "gettimeofday not initialized";
27 %}
28
29 /**
30 * sfunction gettimeofday_us - Number of microseconds since UNIX epoch
31 *
32 * Description: This function returns the number of microseconds
33 * since the UNIX epoch.
34 */
35 function gettimeofday_us:long () {
36 return gettimeofday_ns() / 1000;
37 }
38
39 /**
40 * sfunction gettimeofday_ms - Number of milliseconds since UNIX epoch
41 *
42 * Description: This function returns the number of milliseconds
43 * since the UNIX epoch.
44 */
45 function gettimeofday_ms:long () {
46 return gettimeofday_ns() / 1000000;
47 }
48
49 /**
50 * sfunction gettimeofday_s - Number of seconds since UNIX epoch
51 *
52 * Description: This function returns the number of seconds since
53 * the UNIX epoch.
54 */
55 function gettimeofday_s:long () {
56 return gettimeofday_ns() / 1000000000;
57 }