FreeBSD/sys/kern/kern_time.c
/*
 * ppsratecheck(): packets (or events) per second limitation.
 *
 * Return 0 if the limit is to be enforced (e.g. the caller
 * should drop a packet because of the rate limitation).
 *
 * maxpps of 0 always causes zero to be returned.  maxpps of -1
 * always causes 1 to be returned; this effectively defeats rate
 * limiting.
 *
 * Note that we maintain the struct timeval for compatibility
 * with other bsd systems.  We reuse the storage and just monitor
 * clock ticks for minimal overhead.  
 */
packets (or events) per second limitation.
Return 0 if the limit is to be enforced .

maxpps of 0 always causes zero to be returned.  maxpps of -1
always causes 1 to be returned; this effectively defeats rate
limiting.

Note that we maintain the struct timeval for compatibility
with other bsd systems.  We reuse the storage and just monitor
clock ticks for minimal overhead.
packets ( or events ) per second limitation . Return 0 if the limit is to be enforced . maxpps of 0 always causes zero to be returned . maxpps of - 1 always causes 1 to be returned ; this effectively defeats rate limiting . Note that we maintain the struct timeval for compatibility with other bsd systems . We reuse the storage and just monitor clock ticks for minimal overhead .
int
ppsratecheck(struct timeval *lasttime, int *curpps, int maxpps)
{
	int now;
	now = ticks;
	if (lasttime->tv_sec == 0 || (u_int)(now - lasttime->tv_sec) >= hz) {
		lasttime->tv_sec = now;
		*curpps = 1;
		return (maxpps != 0);
	} else {
		(*curpps)++;		
		return (maxpps < 0 || *curpps <= maxpps);
	}
}
int ppsratecheck ( struct timeval * lasttime , int * curpps , int maxpps ) { int now ; now = ticks ; if ( lasttime -> tv_sec == 0 || ( u_int ) ( now - lasttime -> tv_sec ) >= hz ) { lasttime -> tv_sec = now ; * curpps = 1 ; return ( maxpps != 0 ) ; } else { ( * curpps ) ++ ; return ( maxpps < 0 || * curpps <= maxpps ) ; } }
ppsratecheck(): packets (or events) per second limitation.
ppsratecheck () : packets ( or events ) per second limitation .
/*
	 * Reset the last time and counter if this is the first call
	 * or more than a second has passed since the last update of
	 * lasttime.
	 */ /* NB: ignore potential overflow */