RTE OSAdapter POSIX
0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_posix_osadapter_poll.h
Go to the documentation of this file.
1
13
#ifndef RTE_POSIX_OSADAPTER_POLL_H
14
#define RTE_POSIX_OSADAPTER_POLL_H
15
16
#include <limits.h>
17
#include <stdint.h>
18
#include <time.h>
19
25
static
inline
int
posix_poll_timeout_ms
(uint32_t timeout_ms)
26
{
27
return
(timeout_ms > (uint32_t)INT_MAX) ? INT_MAX : (int)timeout_ms;
28
}
29
40
static
inline
int
posix_remaining_ms
(
const
struct
timespec *deadline)
41
{
42
struct
timespec now;
43
int
remaining = -1;
44
45
if
(clock_gettime(CLOCK_MONOTONIC, &now) == 0)
46
{
47
int64_t delta_ms = ((int64_t)deadline->tv_sec - (int64_t)now.tv_sec) * 1000;
48
49
delta_ms += ((int64_t)deadline->tv_nsec - (int64_t)now.tv_nsec) / 1000000;
50
if
(delta_ms < 0)
51
{
52
delta_ms = 0;
53
}
54
else
if
(delta_ms > (int64_t)INT_MAX)
55
{
56
delta_ms = (int64_t)INT_MAX;
57
}
58
else
59
{
60
/* within [0, INT_MAX]: used as is */
61
}
62
remaining = (int)delta_ms;
63
}
64
return
remaining;
65
}
66
67
#endif
/* RTE_POSIX_OSADAPTER_POLL_H */
posix_remaining_ms
static int posix_remaining_ms(const struct timespec *deadline)
Milliseconds left until a CLOCK_MONOTONIC deadline, for poll()'s int argument.
Definition
rte_posix_osadapter_poll.h:40
posix_poll_timeout_ms
static int posix_poll_timeout_ms(uint32_t timeout_ms)
Converts an unsigned millisecond timeout to poll()'s int argument.
Definition
rte_posix_osadapter_poll.h:25
src
rte_posix_osadapter_poll.h
Generated by
1.18.0