chiark / gitweb /
tree-wide: remove Lennart's copyright lines
[elogind.git] / man / sd_event_now.xml
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 <!--
6   SPDX-License-Identifier: LGPL-2.1+
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>elogind</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;elogind/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
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
56     dispatching any event sources. The <parameter>event</parameter>
57     parameter specifies the event loop object to retrieve the timestamp
58     from. The <parameter>clock</parameter> parameter specifies the clock to
59     retrieve the timestamp for, and is one of
60     <constant>CLOCK_REALTIME</constant> (or equivalently
61     <constant>CLOCK_REALTIME_ALARM</constant>),
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>
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
69     the first event loop iteration, the current time is returned, as
70     reported by <function>clock_gettime()</function>. To distinguish
71     this case from a regular invocation the return value will be
72     positive, and zero when the returned timestamp refers to an actual
73     event loop iteration.</para>
74   </refsect1>
75
76   <refsect1>
77     <title>Return Value</title>
78
79     <para>If the first event loop iteration has not run yet
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
84     error code.</para>
85   </refsect1>
86
87   <refsect1>
88     <title>Errors</title>
89
90     <para>Returned values may indicate the following problems:</para>
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
101       <varlistentry>
102         <term><constant>-EOPNOTSUPP</constant></term>
103
104         <listitem><para>Unsupported clock type.
105         </para></listitem>
106       </varlistentry>
107
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>
114     </variablelist>
115   </refsect1>
116
117   <xi:include href="libelogind-pkgconfig.xml" />
118
119   <refsect1>
120     <title>See Also</title>
121
122     <para>
123       <!-- 0 /// elogind is in section 8
124       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
125       --><!-- else -->
126       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
127       <!-- // 0 -->
128       <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
129       <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130       <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131       <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
132     </para>
133   </refsect1>
134
135 </refentry>