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">
6 This file is part of elogind.
8 Copyright 2015 Lennart Poettering
10 elogind is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 elogind is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_event_now" xmlns:xi="http://www.w3.org/2001/XInclude">
27 <title>sd_event_now</title>
28 <productname>elogind</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_event_now</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_event_now</refname>
48 <refpurpose>Retrieve current event loop iteration timestamp</refpurpose>
53 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
56 <funcdef>int <function>sd_event_now</function></funcdef>
57 <paramdef>sd_event *<parameter>event</parameter></paramdef>
58 <paramdef>clockid_t <parameter>clock</parameter></paramdef>
59 <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
66 <title>Description</title>
68 <para><function>sd_event_now()</function> returns the timestamp
69 the most recent event loop iteration began. This timestamp is
70 taken right after returning from the event sleep, and before
71 dispatching any event sources. The <parameter>event</parameter>
72 parameter takes the even loop object to retrieve the timestamp
73 from. The <parameter>clock</parameter> parameter specifies the clock to
74 retrieve the timestamp for, and is one of
75 <constant>CLOCK_REALTIME</constant> (or its equivalent
76 <constant>CLOCK_REALTIME_ALARM</constant>),
77 <constant>CLOCK_MONOTONIC</constant> or
78 <constant>CLOCK_BOOTTIME</constant> (or its equivalent
79 <constant>CLOCK_BOOTTIME_ALARM</constant>), see <citerefentry
80 project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
81 for more information on the various clocks. The retrieved
82 timestamp is stored in the <parameter>usec</parameter> parameter,
83 in µs since the clock's epoch. If this function is invoked before
84 the first event loop iteration the current time is returned, as
85 reported by <function>clock_gettime()</function>. To distinguish
86 this case from a regular invocation the return value will be
87 positive non-zero in this case, while it is zero when the returned
88 timestamp refers to the actual event loop iteration.</para>
92 <title>Return Value</title>
94 <para>If the first event loop iteration has not run yet
95 <function>sd_event_now()</function> returns the requested
96 timestamp in <parameter>usec</parameter> and returns a positive,
97 non-zero return value. Otherwise, on success it will return the
98 iteration's timestamp in <parameter>usec</parameter> and 0 as
99 return value. On failure, the call returns a negative errno-style
104 <title>Errors</title>
106 <para>Returned errors may indicate the following problems:</para>
110 <term><constant>-EINVAL</constant></term>
112 <listitem><para>An invalid parameter was
113 passed.</para></listitem>
118 <term><constant>-EOPNOTSUPP</constant></term>
120 <listitem><para>Unsupported clock type.
125 <term><constant>-ECHILD</constant></term>
127 <listitem><para>The event loop object was created in a
128 different process.</para></listitem>
133 <xi:include href="libelogind-pkgconfig.xml" />
136 <title>See Also</title>
139 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
140 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
141 <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
142 <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
143 <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>