]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
dc83f27a LP |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
dc83f27a LP |
7 | --> |
8 | ||
9 | <refentry id="sd_event_now" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
10 | ||
11 | <refentryinfo> | |
12 | <title>sd_event_now</title> | |
13 | <productname>systemd</productname> | |
dc83f27a LP |
14 | </refentryinfo> |
15 | ||
16 | <refmeta> | |
17 | <refentrytitle>sd_event_now</refentrytitle> | |
18 | <manvolnum>3</manvolnum> | |
19 | </refmeta> | |
20 | ||
21 | <refnamediv> | |
22 | <refname>sd_event_now</refname> | |
23 | ||
24 | <refpurpose>Retrieve current event loop iteration timestamp</refpurpose> | |
25 | </refnamediv> | |
26 | ||
27 | <refsynopsisdiv> | |
28 | <funcsynopsis> | |
29 | <funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> | |
30 | ||
31 | <funcprototype> | |
32 | <funcdef>int <function>sd_event_now</function></funcdef> | |
33 | <paramdef>sd_event *<parameter>event</parameter></paramdef> | |
34 | <paramdef>clockid_t <parameter>clock</parameter></paramdef> | |
35 | <paramdef>uint64_t *<parameter>usec</parameter></paramdef> | |
36 | </funcprototype> | |
37 | ||
38 | </funcsynopsis> | |
39 | </refsynopsisdiv> | |
40 | ||
41 | <refsect1> | |
42 | <title>Description</title> | |
43 | ||
f23e83b1 ZJS |
44 | <para><function>sd_event_now()</function> returns the time when |
45 | the most recent event loop iteration began. A timestamp | |
46 | is taken right after returning from the event sleep, and before | |
dc83f27a | 47 | dispatching any event sources. The <parameter>event</parameter> |
f23e83b1 | 48 | parameter specifies the event loop object to retrieve the timestamp |
dc83f27a LP |
49 | from. The <parameter>clock</parameter> parameter specifies the clock to |
50 | retrieve the timestamp for, and is one of | |
f23e83b1 | 51 | <constant>CLOCK_REALTIME</constant> (or equivalently |
dc83f27a | 52 | <constant>CLOCK_REALTIME_ALARM</constant>), |
f23e83b1 ZJS |
53 | <constant>CLOCK_MONOTONIC</constant>, or |
54 | <constant>CLOCK_BOOTTIME</constant> (or equivalently | |
55 | <constant>CLOCK_BOOTTIME_ALARM</constant>), see | |
56 | <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
dc83f27a LP |
57 | for more information on the various clocks. The retrieved |
58 | timestamp is stored in the <parameter>usec</parameter> parameter, | |
59 | in µs since the clock's epoch. If this function is invoked before | |
f23e83b1 | 60 | the first event loop iteration, the current time is returned, as |
dc83f27a LP |
61 | reported by <function>clock_gettime()</function>. To distinguish |
62 | this case from a regular invocation the return value will be | |
f23e83b1 ZJS |
63 | positive, and zero when the returned timestamp refers to an actual |
64 | event loop iteration.</para> | |
dc83f27a LP |
65 | </refsect1> |
66 | ||
67 | <refsect1> | |
68 | <title>Return Value</title> | |
69 | ||
70 | <para>If the first event loop iteration has not run yet | |
f23e83b1 ZJS |
71 | <function>sd_event_now()</function> writes current time to |
72 | <parameter>usec</parameter> and returns a positive return value. | |
73 | Otherwise, it will write the requested timestamp to <parameter>usec</parameter> | |
74 | and return 0. On failure, the call returns a negative errno-style | |
dc83f27a LP |
75 | error code.</para> |
76 | </refsect1> | |
77 | ||
78 | <refsect1> | |
79 | <title>Errors</title> | |
80 | ||
f23e83b1 | 81 | <para>Returned values may indicate the following problems:</para> |
dc83f27a LP |
82 | |
83 | <variablelist> | |
84 | <varlistentry> | |
85 | <term><constant>-EINVAL</constant></term> | |
86 | ||
87 | <listitem><para>An invalid parameter was | |
88 | passed.</para></listitem> | |
89 | ||
90 | </varlistentry> | |
91 | ||
2c86ba5a ZJS |
92 | <varlistentry> |
93 | <term><constant>-EOPNOTSUPP</constant></term> | |
94 | ||
95 | <listitem><para>Unsupported clock type. | |
96 | </para></listitem> | |
97 | </varlistentry> | |
98 | ||
dc83f27a LP |
99 | <varlistentry> |
100 | <term><constant>-ECHILD</constant></term> | |
101 | ||
102 | <listitem><para>The event loop object was created in a | |
103 | different process.</para></listitem> | |
104 | </varlistentry> | |
dc83f27a LP |
105 | </variablelist> |
106 | </refsect1> | |
107 | ||
108 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
109 | ||
110 | <refsect1> | |
111 | <title>See Also</title> | |
112 | ||
113 | <para> | |
114 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
115 | <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
116 | <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
117 | <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
118 | <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
119 | </para> | |
120 | </refsect1> | |
121 | ||
122 | </refentry> |