version 1.186, 2023/08/18 01:37:41 |
version 1.187, 2023/08/28 03:31:16 |
|
|
ptimeout_deadline_tsp(pt, &p); |
ptimeout_deadline_tsp(pt, &p); |
} |
} |
|
|
/* Specify a poll/ppoll deadline at wall clock monotime 'when' */ |
/* Specify a poll/ppoll deadline at wall clock monotime 'when' (timespec) */ |
void |
void |
ptimeout_deadline_monotime(struct timespec *pt, time_t when) |
ptimeout_deadline_monotime_tsp(struct timespec *pt, struct timespec *when) |
{ |
{ |
struct timespec now, t; |
struct timespec now, t; |
|
|
t.tv_sec = when; |
|
t.tv_nsec = 0; |
|
monotime_ts(&now); |
monotime_ts(&now); |
|
|
if (timespeccmp(&now, &t, >=)) |
if (timespeccmp(&now, when, >=)) { |
ptimeout_deadline_sec(pt, 0); |
/* 'when' is now or in the past. Timeout ASAP */ |
else { |
pt->tv_sec = 0; |
timespecsub(&t, &now, &t); |
pt->tv_nsec = 0; |
|
} else { |
|
timespecsub(when, &now, &t); |
ptimeout_deadline_tsp(pt, &t); |
ptimeout_deadline_tsp(pt, &t); |
} |
} |
|
} |
|
|
|
/* Specify a poll/ppoll deadline at wall clock monotime 'when' */ |
|
void |
|
ptimeout_deadline_monotime(struct timespec *pt, time_t when) |
|
{ |
|
struct timespec t; |
|
|
|
t.tv_sec = when; |
|
t.tv_nsec = 0; |
|
ptimeout_deadline_monotime_tsp(pt, &t); |
} |
} |
|
|
/* Get a poll(2) timeout value in milliseconds */ |
/* Get a poll(2) timeout value in milliseconds */ |