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