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