1SD_EVENT_NOW(3)                  sd_event_now                  SD_EVENT_NOW(3)
2
3
4

NAME

6       sd_event_now - Retrieve current event loop iteration timestamp
7

SYNOPSIS

9       #include <systemd/sd-event.h>
10
11       int sd_event_now(sd_event *event, clockid_t clock, uint64_t *usec);
12

DESCRIPTION

14       sd_event_now() returns the time when the most recent event loop
15       iteration began. A timestamp is taken right after returning from the
16       event sleep, and before dispatching any event sources. The event
17       parameter specifies the event loop object to retrieve the timestamp
18       from. The clock parameter specifies the clock to retrieve the timestamp
19       for, and is one of CLOCK_REALTIME (or equivalently
20       CLOCK_REALTIME_ALARM), CLOCK_MONOTONIC, or CLOCK_BOOTTIME (or
21       equivalently CLOCK_BOOTTIME_ALARM), see clock_gettime(2) for more
22       information on the various clocks. The retrieved timestamp is stored in
23       the usec parameter, in μs since the clock's epoch. If this function is
24       invoked before the first event loop iteration, the current time is
25       returned, as reported by clock_gettime(). To distinguish this case from
26       a regular invocation the return value will be positive, and zero when
27       the returned timestamp refers to an actual event loop iteration.
28

RETURN VALUE

30       If the first event loop iteration has not run yet sd_event_now() writes
31       current time to usec and returns a positive return value. Otherwise, it
32       will write the requested timestamp to usec and return 0. On failure,
33       the call returns a negative errno-style error code.
34
35   Errors
36       Returned values may indicate the following problems:
37
38       -EINVAL
39           An invalid parameter was passed.
40
41       -EOPNOTSUPP
42           Unsupported clock type.
43
44       -ECHILD
45           The event loop object was created in a different process, library
46           or module instance.
47

NOTES

49       Functions described here are available as a shared library, which can
50       be compiled against and linked to with the libsystemd pkg-config(1)
51       file.
52
53       The code described here uses getenv(3), which is declared to be not
54       multi-thread-safe. This means that the code calling the functions
55       described here must not call setenv(3) from a parallel thread. It is
56       recommended to only do calls to setenv() from an early phase of the
57       program when no other threads have been started.
58

SEE ALSO

60       systemd(1), sd-event(3), sd_event_new(3), sd_event_add_time(3),
61       clock_gettime(2)
62
63
64
65systemd 254                                                    SD_EVENT_NOW(3)
Impressum