MCPcopy Create free account
hub / github.com/F-Stack/f-stack / realtimer_settime

Function realtimer_settime

freebsd/kern/kern_time.c:1520–1567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1518}
1519
1520static int
1521realtimer_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
1569static void
1570realtimer_clocktime(clockid_t id, struct timespec *ts)

Callers

nothing calls this directly

Calls 5

mtx_assertFunction · 0.85
itimespecfixFunction · 0.85
realtimer_gettimeFunction · 0.85
realtimer_clocktimeFunction · 0.85
tvtohzFunction · 0.70

Tested by

no test coverage detected