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 SPDX-License-Identifier: LGPL-2.1+
8 Copyright 2015 Lennart Poettering
11 <refentry id="sd_event_now" xmlns:xi="http://www.w3.org/2001/XInclude">
14 <title>sd_event_now</title>
15 <productname>elogind</productname>
19 <contrib>Developer</contrib>
20 <firstname>Lennart</firstname>
21 <surname>Poettering</surname>
22 <email>lennart@poettering.net</email>
28 <refentrytitle>sd_event_now</refentrytitle>
29 <manvolnum>3</manvolnum>
33 <refname>sd_event_now</refname>
35 <refpurpose>Retrieve current event loop iteration timestamp</refpurpose>
40 <funcsynopsisinfo>#include <elogind/sd-event.h></funcsynopsisinfo>
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>
53 <title>Description</title>
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>
79 <title>Return Value</title>
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
92 <para>Returned values may indicate the following problems:</para>
96 <term><constant>-EINVAL</constant></term>
98 <listitem><para>An invalid parameter was
99 passed.</para></listitem>
104 <term><constant>-EOPNOTSUPP</constant></term>
106 <listitem><para>Unsupported clock type.
111 <term><constant>-ECHILD</constant></term>
113 <listitem><para>The event loop object was created in a
114 different process.</para></listitem>
119 <xi:include href="libelogind-pkgconfig.xml" />
122 <title>See Also</title>
125 <!-- 0 /// elogind is in section 8
126 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
128 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
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>