1SD_EVENT_NOW(3) sd_event_now SD_EVENT_NOW(3)
2
3
4
6 sd_event_now - Retrieve current event loop iteration timestamp
7
9 #include <systemd/sd-event.h>
10
11 int sd_event_now(sd_event *event, clockid_t clock, uint64_t *usec);
12
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
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.
46
48 These APIs are implemented as a shared library, which can be compiled
49 and linked to with the libsystemd pkg-config(1) file.
50
52 systemd(1), sd-event(3), sd_event_new(3), sd_event_add_time(3),
53 clock_gettime(2)
54
55
56
57systemd 249 SD_EVENT_NOW(3)