summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/sd_event_now.3
blob: 8ecffe6ab28f0b8ced310b58616dbc43f3558598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
'\" t
.TH "SD_EVENT_NOW" "3" "" "systemd 255" "sd_event_now"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_event_now \- Retrieve current event loop iteration timestamp
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-event\&.h>
.fi
.ft
.HP \w'int\ sd_event_now('u
.BI "int sd_event_now(sd_event\ *" "event" ", clockid_t\ " "clock" ", uint64_t\ *" "usec" ");"
.SH "DESCRIPTION"
.PP
\fBsd_event_now()\fR
returns the time when the most recent event loop iteration began\&. A timestamp is taken right after returning from the event sleep, and before dispatching any event sources\&. The
\fIevent\fR
parameter specifies the event loop object to retrieve the timestamp from\&. The
\fIclock\fR
parameter specifies the clock to retrieve the timestamp for, and is one of
\fBCLOCK_REALTIME\fR
(or equivalently
\fBCLOCK_REALTIME_ALARM\fR),
\fBCLOCK_MONOTONIC\fR, or
\fBCLOCK_BOOTTIME\fR
(or equivalently
\fBCLOCK_BOOTTIME_ALARM\fR), see
\fBclock_gettime\fR(2)
for more information on the various clocks\&. The retrieved timestamp is stored in the
\fIusec\fR
parameter, in μs since the clock\*(Aqs epoch\&. If this function is invoked before the first event loop iteration, the current time is returned, as reported by
\fBclock_gettime()\fR\&. To distinguish this case from a regular invocation the return value will be positive, and zero when the returned timestamp refers to an actual event loop iteration\&.
.SH "RETURN VALUE"
.PP
If the first event loop iteration has not run yet
\fBsd_event_now()\fR
writes current time to
\fIusec\fR
and returns a positive return value\&. Otherwise, it will write the requested timestamp to
\fIusec\fR
and return 0\&. On failure, the call returns a negative errno\-style error code\&.
.SS "Errors"
.PP
Returned values may indicate the following problems:
.PP
\fB\-EINVAL\fR
.RS 4
An invalid parameter was passed\&.
.RE
.PP
\fB\-EOPNOTSUPP\fR
.RS 4
Unsupported clock type\&.
.RE
.PP
\fB\-ECHILD\fR
.RS 4
The event loop object was created in a different process, library or module instance\&.
.RE
.SH "NOTES"
.PP
Functions described here are available as a shared library, which can be compiled against and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.PP
The code described here uses
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
\fBsetenv\fR(3)
from a parallel thread\&. It is recommended to only do calls to
\fBsetenv()\fR
from an early phase of the program when no other threads have been started\&.
.SH "HISTORY"
.PP
\fBsd_event_now()\fR
was added in version 229\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-event\fR(3),
\fBsd_event_new\fR(3),
\fBsd_event_add_time\fR(3),
\fBclock_gettime\fR(2)