| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="sd_event_now" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>sd_event_now</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>sd_event_now</refentrytitle> |
| 15 |
<manvolnum>3</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>sd_event_now</refname> |
| 20 |
|
| 21 |
<refpurpose>Retrieve current event loop iteration timestamp</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<funcsynopsis> |
| 26 |
<funcsynopsisinfo>#include <systemd/sd-event.h></funcsynopsisinfo> |
| 27 |
|
| 28 |
<funcprototype> |
| 29 |
<funcdef>int <function>sd_event_now</function></funcdef> |
| 30 |
<paramdef>sd_event *<parameter>event</parameter></paramdef> |
| 31 |
<paramdef>clockid_t <parameter>clock</parameter></paramdef> |
| 32 |
<paramdef>uint64_t *<parameter>ret</parameter></paramdef> |
| 33 |
</funcprototype> |
| 34 |
|
| 35 |
</funcsynopsis> |
| 36 |
</refsynopsisdiv> |
| 37 |
|
| 38 |
<refsect1> |
| 39 |
<title>Description</title> |
| 40 |
|
| 41 |
<para><function>sd_event_now()</function> returns the time when |
| 42 |
the most recent event loop iteration began. A timestamp |
| 43 |
is taken right after returning from the event sleep, and before |
| 44 |
dispatching any event sources. The <parameter>event</parameter> |
| 45 |
parameter specifies the event loop object to retrieve the timestamp |
| 46 |
from. The <parameter>clock</parameter> parameter specifies the clock to |
| 47 |
retrieve the timestamp for, and is one of |
| 48 |
<constant>CLOCK_REALTIME</constant> (or equivalently |
| 49 |
<constant>CLOCK_REALTIME_ALARM</constant>), |
| 50 |
<constant>CLOCK_MONOTONIC</constant>, or |
| 51 |
<constant>CLOCK_BOOTTIME</constant> (or equivalently |
| 52 |
<constant>CLOCK_BOOTTIME_ALARM</constant>), see |
| 53 |
<citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry> |
| 54 |
for more information on the various clocks. The retrieved |
| 55 |
timestamp is stored in the <parameter>ret</parameter> parameter, |
| 56 |
in μs since the clock's epoch. If this function is invoked before |
| 57 |
the first event loop iteration, the current time is returned, as |
| 58 |
reported by <function>clock_gettime()</function>. To distinguish |
| 59 |
this case from a regular invocation the return value will be |
| 60 |
positive, and zero when the returned timestamp refers to an actual |
| 61 |
event loop iteration.</para> |
| 62 |
</refsect1> |
| 63 |
|
| 64 |
<refsect1> |
| 65 |
<title>Return Value</title> |
| 66 |
|
| 67 |
<para>If the first event loop iteration has not run yet <function>sd_event_now()</function> writes |
| 68 |
current time to <parameter>ret</parameter> and returns a positive return value. Otherwise, it will |
| 69 |
write the requested timestamp to <parameter>ret</parameter> and return 0. On failure, the call returns a |
| 70 |
negative errno-style error code.</para> |
| 71 |
|
| 72 |
<refsect2> |
| 73 |
<title>Errors</title> |
| 74 |
|
| 75 |
<para>Returned values may indicate the following problems:</para> |
| 76 |
|
| 77 |
<variablelist> |
| 78 |
<varlistentry> |
| 79 |
<term><constant>-EINVAL</constant></term> |
| 80 |
|
| 81 |
<listitem><para>An invalid parameter was passed.</para></listitem> |
| 82 |
|
| 83 |
</varlistentry> |
| 84 |
|
| 85 |
<varlistentry> |
| 86 |
<term><constant>-EOPNOTSUPP</constant></term> |
| 87 |
|
| 88 |
<listitem><para>Unsupported clock type.</para></listitem> |
| 89 |
</varlistentry> |
| 90 |
|
| 91 |
<varlistentry> |
| 92 |
<term><constant>-ECHILD</constant></term> |
| 93 |
|
| 94 |
<listitem><para>The event loop object was created in a different process, library or module instance.</para></listitem> |
| 95 |
</varlistentry> |
| 96 |
</variablelist> |
| 97 |
</refsect2> |
| 98 |
</refsect1> |
| 99 |
|
| 100 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 101 |
|
| 102 |
<refsect1> |
| 103 |
<title>History</title> |
| 104 |
<para><function>sd_event_now()</function> was added in version 229.</para> |
| 105 |
</refsect1> |
| 106 |
|
| 107 |
<refsect1> |
| 108 |
<title>See Also</title> |
| 109 |
|
| 110 |
<para><simplelist type="inline"> |
| 111 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 112 |
<member><citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 113 |
<member><citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 114 |
<member><citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 115 |
<member><citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry></member> |
| 116 |
</simplelist></para> |
| 117 |
</refsect1> |
| 118 |
|
| 119 |
</refentry> |