dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<!--
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering This file is part of systemd.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering Copyright 2015 Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering systemd is free software; you can redistribute it and/or modify it
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering under the terms of the GNU Lesser General Public License as published by
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering (at your option) any later version.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering systemd is distributed in the hope that it will be useful, but
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering Lesser General Public License for more details.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering You should have received a copy of the GNU Lesser General Public License
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering-->
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering<refentry id="sd_event_now" xmlns:xi="http://www.w3.org/2001/XInclude">
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refentryinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <title>sd_event_now</title>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <productname>systemd</productname>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <authorgroup>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <author>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <contrib>Developer</contrib>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <firstname>Lennart</firstname>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <surname>Poettering</surname>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <email>lennart@poettering.net</email>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </author>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </authorgroup>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refentryinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refmeta>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refentrytitle>sd_event_now</refentrytitle>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <manvolnum>3</manvolnum>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refmeta>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refnamediv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refname>sd_event_now</refname>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refpurpose>Retrieve current event loop iteration timestamp</refpurpose>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refnamediv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsynopsisdiv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcsynopsis>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcsynopsisinfo>#include &lt;systemd/sd-event.h&gt;</funcsynopsisinfo>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <funcdef>int <function>sd_event_now</function></funcdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <paramdef>sd_event *<parameter>event</parameter></paramdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <paramdef>clockid_t <parameter>clock</parameter></paramdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <paramdef>uint64_t *<parameter>usec</parameter></paramdef>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </funcprototype>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </funcsynopsis>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsynopsisdiv>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <title>Description</title>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <para><function>sd_event_now()</function> returns the time when
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek the most recent event loop iteration began. A timestamp
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek is taken right after returning from the event sleep, and before
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering dispatching any event sources. The <parameter>event</parameter>
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek parameter specifies the event loop object to retrieve the timestamp
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering from. The <parameter>clock</parameter> parameter specifies the clock to
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering retrieve the timestamp for, and is one of
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <constant>CLOCK_REALTIME</constant> (or equivalently
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <constant>CLOCK_REALTIME_ALARM</constant>),
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <constant>CLOCK_MONOTONIC</constant>, or
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <constant>CLOCK_BOOTTIME</constant> (or equivalently
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <constant>CLOCK_BOOTTIME_ALARM</constant>), see
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering for more information on the various clocks. The retrieved
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering timestamp is stored in the <parameter>usec</parameter> parameter,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering in µs since the clock's epoch. If this function is invoked before
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek the first event loop iteration, the current time is returned, as
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering reported by <function>clock_gettime()</function>. To distinguish
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering this case from a regular invocation the return value will be
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek positive, and zero when the returned timestamp refers to an actual
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek event loop iteration.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <title>Return Value</title>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>If the first event loop iteration has not run yet
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <function>sd_event_now()</function> writes current time to
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <parameter>usec</parameter> and returns a positive return value.
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek Otherwise, it will write the requested timestamp to <parameter>usec</parameter>
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek and return 0. On failure, the call returns a negative errno-style
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering error code.</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <title>Errors</title>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
f23e83b156da8966e43e303dced5439503450d21Zbigniew Jędrzejewski-Szmek <para>Returned values may indicate the following problems:</para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <variablelist>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <term><constant>-EINVAL</constant></term>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <listitem><para>An invalid parameter was
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering passed.</para></listitem>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek <varlistentry>
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek <term><constant>-EOPNOTSUPP</constant></term>
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek <listitem><para>Unsupported clock type.
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek </para></listitem>
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek </varlistentry>
2c86ba5a51b29e41bdfde6771d93cc5317b253cfZbigniew Jędrzejewski-Szmek
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <term><constant>-ECHILD</constant></term>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <listitem><para>The event loop object was created in a
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering different process.</para></listitem>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </varlistentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </variablelist>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <xi:include href="libsystemd-pkgconfig.xml" />
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <title>See Also</title>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry><refentrytitle>sd_event_add_time</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering <citerefentry project='man-pages'><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </para>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering </refsect1>
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering
dc83f27a7cf03757dec11a69ec18504ad4ea8f89Lennart Poettering</refentry>