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

Function itimerdecr

freebsd/kern/kern_time.c:952–981  ·  view source on GitHub ↗

* Decrement an interval timer by a specified number * of microseconds, which must be less than a second, * i.e. < 1000000. If the timer expires, then reload * it. In this case, carry over (usec - old value) to * reduce the value reloaded into the timer so that * the timer does not drift. This routine assumes * that it is called in a context where the timers * on which it is operating can

Source from the content-addressed store, hash-verified

950 * on which it is operating cannot change in value.
951 */
952int
953itimerdecr(struct itimerval *itp, int usec)
954{
955
956 if (itp->it_value.tv_usec < usec) {
957 if (itp->it_value.tv_sec == 0) {
958 /* expired, and already in next interval */
959 usec -= itp->it_value.tv_usec;
960 goto expire;
961 }
962 itp->it_value.tv_usec += 1000000;
963 itp->it_value.tv_sec--;
964 }
965 itp->it_value.tv_usec -= usec;
966 usec = 0;
967 if (timevalisset(&itp->it_value))
968 return (1);
969 /* expired, exactly at end of interval */
970expire:
971 if (timevalisset(&itp->it_interval)) {
972 itp->it_value = itp->it_interval;
973 itp->it_value.tv_usec -= usec;
974 if (itp->it_value.tv_usec < 0) {
975 itp->it_value.tv_usec += 1000000;
976 itp->it_value.tv_sec--;
977 }
978 } else
979 itp->it_value.tv_usec = 0; /* sec is already 0 */
980 return (0);
981}
982
983/*
984 * Add and subtract routines for timevals.

Callers 1

hardclock_itimerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected