RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Loading...
Searching...
No Matches
rte_posix_osadapter_poll.h File Reference

Private helpers: millisecond waits for poll()'s int timeout argument. More...

#include <limits.h>
#include <stdint.h>
#include <time.h>
Include dependency graph for rte_posix_osadapter_poll.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static int posix_poll_timeout_ms (uint32_t timeout_ms)
 Converts an unsigned millisecond timeout to poll()'s int argument.
static int posix_remaining_ms (const struct timespec *deadline)
 Milliseconds left until a CLOCK_MONOTONIC deadline, for poll()'s int argument.

Detailed Description

Private helpers: millisecond waits for poll()'s int timeout argument.

A plain (int) cast turns a value above INT_MAX into a negative one. poll() reads a negative timeout as "wait forever" - an unbounded wait the OSA rules forbid (every wait has a timeout) - and the IPC and netlink callers of the time left read it as "no time left", so a timeout above INT_MAX ms ended at once instead of waiting. Both helpers cap at INT_MAX instead (about 24.8 days per poll() call).

Not installed: an internal header of this product. A source file including it defines _POSIX_C_SOURCE (or _GNU_SOURCE) before its first include (glibc declares clock_gettime() only under a POSIX feature-test macro).

Definition in file rte_posix_osadapter_poll.h.

Function Documentation

◆ posix_poll_timeout_ms()

int posix_poll_timeout_ms ( uint32_t timeout_ms)
inlinestatic

Converts an unsigned millisecond timeout to poll()'s int argument.

Parameters
timeout_msTimeout in milliseconds.
Returns
timeout_ms, or INT_MAX if timeout_ms is above INT_MAX.

Definition at line 25 of file rte_posix_osadapter_poll.h.

◆ posix_remaining_ms()

int posix_remaining_ms ( const struct timespec * deadline)
inlinestatic

Milliseconds left until a CLOCK_MONOTONIC deadline, for poll()'s int argument.

The difference is (deadline.tv_sec - now.tv_sec) * 1000 plus (deadline.tv_nsec - now.tv_nsec) / 1000000, the nanosecond part truncated toward zero (the rounding of the two local remaining_ms() copies this replaces).

Parameters
deadlineAbsolute CLOCK_MONOTONIC deadline.
Returns
-1 if clock_gettime(CLOCK_MONOTONIC) fails (callers treat that as "no time left"); 0 once the deadline has passed; otherwise the milliseconds left, capped at INT_MAX.

Definition at line 40 of file rte_posix_osadapter_poll.h.