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