| 1518 | } |
| 1519 | |
| 1520 | static int |
| 1521 | realtimer_settime(struct itimer *it, int flags, |
| 1522 | struct itimerspec *value, struct itimerspec *ovalue) |
| 1523 | { |
| 1524 | struct timespec cts, ts; |
| 1525 | struct timeval tv; |
| 1526 | struct itimerspec val; |
| 1527 | |
| 1528 | mtx_assert(&it->it_mtx, MA_OWNED); |
| 1529 | |
| 1530 | val = *value; |
| 1531 | if (itimespecfix(&val.it_value)) |
| 1532 | return (EINVAL); |
| 1533 | |
| 1534 | if (timespecisset(&val.it_value)) { |
| 1535 | if (itimespecfix(&val.it_interval)) |
| 1536 | return (EINVAL); |
| 1537 | } else { |
| 1538 | timespecclear(&val.it_interval); |
| 1539 | } |
| 1540 | |
| 1541 | if (ovalue != NULL) |
| 1542 | realtimer_gettime(it, ovalue); |
| 1543 | |
| 1544 | it->it_time = val; |
| 1545 | if (timespecisset(&val.it_value)) { |
| 1546 | realtimer_clocktime(it->it_clockid, &cts); |
| 1547 | ts = val.it_value; |
| 1548 | if ((flags & TIMER_ABSTIME) == 0) { |
| 1549 | /* Convert to absolute time. */ |
| 1550 | timespecadd(&it->it_time.it_value, &cts, |
| 1551 | &it->it_time.it_value); |
| 1552 | } else { |
| 1553 | timespecsub(&ts, &cts, &ts); |
| 1554 | /* |
| 1555 | * We don't care if ts is negative, tztohz will |
| 1556 | * fix it. |
| 1557 | */ |
| 1558 | } |
| 1559 | TIMESPEC_TO_TIMEVAL(&tv, &ts); |
| 1560 | callout_reset(&it->it_callout, tvtohz(&tv), |
| 1561 | realtimer_expire, it); |
| 1562 | } else { |
| 1563 | callout_stop(&it->it_callout); |
| 1564 | } |
| 1565 | |
| 1566 | return (0); |
| 1567 | } |
| 1568 | |
| 1569 | static void |
| 1570 | realtimer_clocktime(clockid_t id, struct timespec *ts) |
nothing calls this directly
no test coverage detected