]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_event_now.xml
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / man / sd_event_now.xml
CommitLineData
dc83f27a
LP
1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
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>
14
15 <authorgroup>
16 <author>
17 <contrib>Developer</contrib>
18 <firstname>Lennart</firstname>
19 <surname>Poettering</surname>
20 <email>lennart@poettering.net</email>
21 </author>
22 </authorgroup>
23 </refentryinfo>
24
25 <refmeta>
26 <refentrytitle>sd_event_now</refentrytitle>
27 <manvolnum>3</manvolnum>
28 </refmeta>
29
30 <refnamediv>
31 <refname>sd_event_now</refname>
32
33 <refpurpose>Retrieve current event loop iteration timestamp</refpurpose>
34 </refnamediv>
35
36 <refsynopsisdiv>
37 <funcsynopsis>
38 <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
39
40 <funcprototype>
41 <funcdef>int <function>sd_event_now</function></funcdef>
42 <paramdef>sd_event *<parameter>event</parameter></paramdef>
43 <paramdef>clockid_t <parameter>clock</parameter></paramdef>
44 <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
45 </funcprototype>
46
47 </funcsynopsis>
48 </refsynopsisdiv>
49
50 <refsect1>
51 <title>Description</title>
52
f23e83b1
ZJS
53 <para><function>sd_event_now()</function> returns the time when
54 the most recent event loop iteration began. A timestamp
55 is taken right after returning from the event sleep, and before
dc83f27a 56 dispatching any event sources. The <parameter>event</parameter>
f23e83b1 57 parameter specifies the event loop object to retrieve the timestamp
dc83f27a
LP
58 from. The <parameter>clock</parameter> parameter specifies the clock to
59 retrieve the timestamp for, and is one of
f23e83b1 60 <constant>CLOCK_REALTIME</constant> (or equivalently
dc83f27a 61 <constant>CLOCK_REALTIME_ALARM</constant>),
f23e83b1
ZJS
62 <constant>CLOCK_MONOTONIC</constant>, or
63 <constant>CLOCK_BOOTTIME</constant> (or equivalently
64 <constant>CLOCK_BOOTTIME_ALARM</constant>), see
65 <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
dc83f27a
LP
66 for more information on the various clocks. The retrieved
67 timestamp is stored in the <parameter>usec</parameter> parameter,
68 in µs since the clock's epoch. If this function is invoked before
f23e83b1 69 the first event loop iteration, the current time is returned, as
dc83f27a
LP
70 reported by <function>clock_gettime()</function>. To distinguish
71 this case from a regular invocation the return value will be
f23e83b1
ZJS
72 positive, and zero when the returned timestamp refers to an actual
73 event loop iteration.</para>
dc83f27a
LP
74 </refsect1>
75
76 <refsect1>
77 <title>Return Value</title>
78
79 <para>If the first event loop iteration has not run yet
f23e83b1
ZJS
80 <function>sd_event_now()</function> writes current time to
81 <parameter>usec</parameter> and returns a positive return value.
82 Otherwise, it will write the requested timestamp to <parameter>usec</parameter>
83 and return 0. On failure, the call returns a negative errno-style
dc83f27a
LP
84 error code.</para>
85 </refsect1>
86
87 <refsect1>
88 <title>Errors</title>
89
f23e83b1 90 <para>Returned values may indicate the following problems:</para>
dc83f27a
LP
91
92 <variablelist>
93 <varlistentry>
94 <term><constant>-EINVAL</constant></term>
95
96 <listitem><para>An invalid parameter was
97 passed.</para></listitem>
98
99 </varlistentry>
100
2c86ba5a
ZJS
101 <varlistentry>
102 <term><constant>-EOPNOTSUPP</constant></term>
103
104 <listitem><para>Unsupported clock type.
105 </para></listitem>
106 </varlistentry>
107
dc83f27a
LP
108 <varlistentry>
109 <term><constant>-ECHILD</constant></term>
110
111 <listitem><para>The event loop object was created in a
112 different process.</para></listitem>
113 </varlistentry>
dc83f27a
LP
114 </variablelist>
115 </refsect1>
116
117 <xi:include href="libsystemd-pkgconfig.xml" />
118
119 <refsect1>
120 <title>See Also</title>
121
122 <para>
123 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
124 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
125 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
126 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
127 <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
128 </para>
129 </refsect1>
130
131</refentry>