> Date: Thu, 17 Mar 2016 21:02:03 +0100
> From: Martin Pieuchot <m...@openbsd.org>
> 
> ``ticks'' is in my opinion a really badly named global variable.  But we
> all know that finding names is hard ;)
> 
> Since its popularity seems to be really high lately, I'd suggest to
> rename it.  I chose ``hcticks'' for "hardclock ticks".  I believe this
> would help auditing the possible existing and/or future conditions
> leading to overflow.
> 
> As a bonus this diff removes all the "extern hcticks;" declaration and
> include <sys/kernel.h> instead.
> 
> Opinions?

I don't like this kind of reshuffling.  I don't think there is
anything wrong with the current name.

> PS: I missed 4 conversions in my previous diff, can you find them?
> 
> diff --git sys/dev/atapiscsi/atapiscsi.c sys/dev/atapiscsi/atapiscsi.c
> index df5c45b..be164ea 100644
> --- sys/dev/atapiscsi/atapiscsi.c
> +++ sys/dev/atapiscsi/atapiscsi.c
> @@ -613,7 +613,6 @@ wdc_atapi_the_machine(struct channel_softc *chp, struct 
> wdc_xfer *xfer,
>      enum atapi_context ctxt)
>  {
>       int idx = 0;
> -     extern int ticks;
>       int timeout_delay = hz / 10;
>  
>       if (xfer->c_flags & C_POLL) {
> @@ -637,7 +636,7 @@ wdc_atapi_the_machine(struct channel_softc *chp, struct 
> wdc_xfer *xfer,
>               struct atapi_return_args retargs = ARGS_INIT;
>  
>               (xfer->next)(chp, xfer,
> -                 xfer->endticks && (ticks - xfer->endticks >= 0),
> +                 xfer->endticks && (hcticks - xfer->endticks >= 0),
>                   &retargs);
>  
>               if (retargs.timeout != -1)
> @@ -646,7 +645,7 @@ wdc_atapi_the_machine(struct channel_softc *chp, struct 
> wdc_xfer *xfer,
>                        * can be just microseconds before the tick changes.
>                        */
>                       xfer->endticks =
> -                         max((retargs.timeout * hz) / 1000, 1) + 1 + ticks;
> +                         max((retargs.timeout * hz) / 1000, 1) + 1 + hcticks;
>  
>               if (xfer->next == NULL) {
>                       if (xfer->c_flags & C_POLL_MACHINE)
> @@ -661,7 +660,7 @@ wdc_atapi_the_machine(struct channel_softc *chp, struct 
> wdc_xfer *xfer,
>               if (retargs.expect_irq) {
>                       int timeout_period;
>                       chp->ch_flags |= WDCF_IRQ_WAIT;
> -                     timeout_period =  xfer->endticks - ticks;
> +                     timeout_period =  xfer->endticks - hcticks;
>                       if (timeout_period < 1)
>                               timeout_period = 1;
>                       timeout_add(&chp->ch_timo, timeout_period);
> diff --git sys/dev/ic/ar5008.c sys/dev/ic/ar5008.c
> index d3ad6c9..fa1c1e9 100644
> --- sys/dev/ic/ar5008.c
> +++ sys/dev/ic/ar5008.c
> @@ -2381,8 +2381,7 @@ ar5008_hw_init(struct athn_softc *sc, struct 
> ieee80211_channel *c,
>       ar5008_init_chains(sc);
>  
>       if (sc->flags & ATHN_FLAG_OLPC) {
> -             extern int ticks;
> -             sc->olpc_ticks = ticks;
> +             sc->olpc_ticks = hcticks;
>               ops->olpc_init(sc);
>       }
>  
> diff --git sys/dev/ic/athn.c sys/dev/ic/athn.c
> index 03460ef..df2b9b1 100644
> --- sys/dev/ic/athn.c
> +++ sys/dev/ic/athn.c
> @@ -1218,7 +1218,6 @@ athn_iter_func(void *arg, struct ieee80211_node *ni)
>  void
>  athn_calib_to(void *arg)
>  {
> -     extern int ticks;
>       struct athn_softc *sc = arg;
>       struct athn_ops *ops = &sc->ops;
>       struct ieee80211com *ic = &sc->sc_ic;
> @@ -1229,8 +1228,8 @@ athn_calib_to(void *arg)
>       /* Do periodic (every 4 minutes) PA calibration. */
>       if (AR_SREV_9285_11_OR_LATER(sc) &&
>           !AR_SREV_9380_10_OR_LATER(sc) &&
> -         (ticks - (sc->pa_calib_ticks + 240 * hz)) >= 0) {
> -             sc->pa_calib_ticks = ticks;
> +         (hcticks - (sc->pa_calib_ticks + 240 * hz)) >= 0) {
> +             sc->pa_calib_ticks = hcticks;
>               if (AR_SREV_9271(sc))
>                       ar9271_pa_calib(sc);
>               else
> @@ -1239,8 +1238,8 @@ athn_calib_to(void *arg)
>  
>       /* Do periodic (every 30 seconds) temperature compensation. */
>       if ((sc->flags & ATHN_FLAG_OLPC) &&
> -         ticks >= sc->olpc_ticks + 30 * hz) {
> -             sc->olpc_ticks = ticks;
> +         hcticks >= sc->olpc_ticks + 30 * hz) {
> +             sc->olpc_ticks = hcticks;
>               ops->olpc_temp_compensation(sc);
>       }
>  
> @@ -1279,8 +1278,7 @@ athn_init_calib(struct athn_softc *sc, struct 
> ieee80211_channel *c,
>       if (!AR_SREV_9380_10_OR_LATER(sc)) {
>               /* Do PA calibration. */
>               if (AR_SREV_9285_11_OR_LATER(sc)) {
> -                     extern int ticks;
> -                     sc->pa_calib_ticks = ticks;
> +                     sc->pa_calib_ticks = hcticks;
>                       if (AR_SREV_9271(sc))
>                               ar9271_pa_calib(sc);
>                       else
> diff --git sys/dev/ic/bwi.c sys/dev/ic/bwi.c
> index d612db3..7514e29 100644
> --- sys/dev/ic/bwi.c
> +++ sys/dev/ic/bwi.c
> @@ -97,8 +97,6 @@ int bwi_debug = 1;
>  
>  #define __unused __attribute__((__unused__))
>  
> -extern int ticks;
> -
>  /* XXX end porting goop */
>  
>  /* MAC */
> @@ -6509,11 +6507,11 @@ bwi_led_event(struct bwi_softc *sc, int event)
>       if (event == BWI_LED_EVENT_POLL) {
>               if ((led->l_flags & BWI_LED_F_POLLABLE) == 0)
>                       return;
> -             if (ticks - sc->sc_led_ticks < sc->sc_led_idle)
> +             if (hcticks - sc->sc_led_ticks < sc->sc_led_idle)
>                       return;
>       }
>  
> -     sc->sc_led_ticks = ticks;
> +     sc->sc_led_ticks = hcticks;
>       if (sc->sc_led_blinking)
>               return;
>  
> diff --git sys/dev/pci/drm/drmP.h sys/dev/pci/drm/drmP.h
> index 4cff951..206c6a0 100644
> --- sys/dev/pci/drm/drmP.h
> +++ sys/dev/pci/drm/drmP.h
> @@ -92,8 +92,6 @@
>  
>  #define DRM_WAKEUP(x)                wakeup(x)
>  
> -extern int ticks;
> -
>  #define drm_msleep(x)                mdelay(x)
>  
>  extern struct cfdriver drm_cd;
> diff --git sys/dev/pci/drm/drm_linux.h sys/dev/pci/drm/drm_linux.h
> index 0e651ba..90e5975 100644
> --- sys/dev/pci/drm/drm_linux.h
> +++ sys/dev/pci/drm/drm_linux.h
> @@ -17,6 +17,7 @@
>  
>  #include <sys/atomic.h>
>  #include <sys/task.h>
> +#include <sys/kernel.h>
>  
>  typedef int irqreturn_t;
>  #define IRQ_NONE     0
> @@ -321,9 +322,9 @@ do {                                              \
>       atomic_inc_int(&(wq).count);            \
>       sleep_setup(&sls, &wq, 0, "drmwet");    \
>       sleep_setup_timeout(&sls, ret);         \
> -     deadline = ticks + ret;                 \
> +     deadline = hcticks + ret;               \
>       sleep_finish(&sls, !(condition));       \
> -     ret = deadline - ticks;                 \
> +     ret = deadline - hcticks;               \
>       __error = sleep_finish_timeout(&sls);   \
>       atomic_dec_int(&(wq).count);            \
>       if (ret < 0 || __error == EWOULDBLOCK)  \
> @@ -351,9 +352,9 @@ do {                                              \
>       sleep_setup(&sls, &wq, PCATCH, "drmweti"); \
>       sleep_setup_timeout(&sls, ret);         \
>       sleep_setup_signal(&sls, PCATCH);       \
> -     deadline = ticks + ret;                 \
> +     deadline = hcticks + ret;                       \
>       sleep_finish(&sls, !(condition));       \
> -     ret = deadline - ticks;                 \
> +     ret = deadline - hcticks;               \
>       __error1 = sleep_finish_timeout(&sls);  \
>       __error = sleep_finish_signal(&sls);    \
>       atomic_dec_int(&(wq).count);            \
> @@ -565,8 +566,7 @@ timespec_sub(struct timespec t1, struct timespec t2)
>  
>  #define time_in_range(x, min, max) ((x) >= (min) && (x) <= (max))
>  
> -extern int ticks;
> -#define jiffies ticks
> +#define jiffies hcticks
>  #undef HZ
>  #define HZ   hz
>  
> diff --git sys/dev/usb/if_cdcef.c sys/dev/usb/if_cdcef.c
> index 5496d9c..8b8d195 100644
> --- sys/dev/usb/if_cdcef.c
> +++ sys/dev/usb/if_cdcef.c
> @@ -25,6 +25,7 @@
>  
>  
>  #include <sys/param.h>
> +#include <sys/kernel.h>
>  #include <sys/device.h>
>  #include <sys/socket.h>
>  #include <sys/systm.h>
> @@ -121,8 +122,6 @@ struct usbf_function_methods cdcef_methods = {
>  
>  #define DEVNAME(sc)  ((sc)->sc_dev.bdev.dv_xname)
>  
> -extern int ticks;
> -
>  /*
>   * USB function match/attach/detach
>   */
> @@ -239,7 +238,7 @@ cdcef_attach(struct device *parent, struct device *self, 
> void *aux)
>  
>       macaddr_hi = htons(0x2acb);
>       bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
> -     bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> +     bcopy(&hcticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
>       sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.bdev.dv_unit);
>  
>       printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
> diff --git sys/dev/usb/if_ugl.c sys/dev/usb/if_ugl.c
> index ba8490b..b76e019 100644
> --- sys/dev/usb/if_ugl.c
> +++ sys/dev/usb/if_ugl.c
> @@ -54,6 +54,7 @@
>  #include <bpfilter.h>
>  
>  #include <sys/param.h>
> +#include <sys/kernel.h>
>  #include <sys/systm.h>
>  #include <sys/timeout.h>
>  #include <sys/sockio.h>
> @@ -152,8 +153,6 @@ int       ugldebug = 0;
>  #define DPRINTFN(n,x)
>  #endif
>  
> -extern int ticks;
> -
>  /*
>   * Various supported device vendors/products.
>   */
> @@ -253,7 +252,7 @@ ugl_attach(struct device *parent, struct device *self, 
> void *aux)
>  
>       macaddr_hi = htons(0x2acb);
>       bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
> -     bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> +     bcopy(&hcticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
>       sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.dv_unit);
>  
>       printf("%s: address %s\n",
> diff --git sys/kern/kern_clock.c sys/kern/kern_clock.c
> index adaaab0..b382330 100644
> --- sys/kern/kern_clock.c
> +++ sys/kern/kern_clock.c
> @@ -97,7 +97,7 @@ int stathz;
>  int  schedhz;
>  int  profhz;
>  int  profprocs;
> -int  ticks;
> +int  hcticks;                        /* # of hardclock ticks */
>  static int psdiv, pscnt;             /* prof => stat divider */
>  int  psratio;                        /* ratio: prof / stat */
>  
> diff --git sys/kern/kern_timeout.c sys/kern/kern_timeout.c
> index c888cb3..6cc6c9c 100644
> --- sys/kern/kern_timeout.c
> +++ sys/kern/kern_timeout.c
> @@ -42,8 +42,8 @@
>  
>  /*
>   * Timeouts are kept in a hierarchical timing wheel. The to_time is the value
> - * of the global variable "ticks" when the timeout should be called. There 
> are
> - * four levels with 256 buckets each. See 'Scheme 7' in
> + * of the global variable "hcticks" when the timeout should be called. There
> + * are four levels with 256 buckets each. See 'Scheme 7' in
>   * "Hashed and Hierarchical Timing Wheels: Efficient Data Structures for
>   * Implementing a Timer Facility" by George Varghese and Tony Lauck.
>   */
> @@ -137,7 +137,7 @@ struct mutex timeout_mutex = MUTEX_INITIALIZER(IPL_HIGH);
>   * be positive or negative so comparing it with anything is dangerous.
>   * The only way we can use the to->to_time value in any predictable way
>   * is when we calculate how far in the future `to' will timeout -
> - * "to->to_time - ticks". The result will always be positive for future
> + * "to->to_time - hcticks". The result will always be positive for future
>   * timeouts and 0 or negative for due timeouts.
>   */
>  
> @@ -176,7 +176,7 @@ timeout_add(struct timeout *new, int to_ticks)
>       mtx_enter(&timeout_mutex);
>       /* Initialize the time here, it won't change. */
>       old_time = new->to_time;
> -     new->to_time = to_ticks + ticks;
> +     new->to_time = to_ticks + hcticks;
>       new->to_flags &= ~TIMEOUT_TRIGGERED;
>  
>       /*
> @@ -185,7 +185,7 @@ timeout_add(struct timeout *new, int to_ticks)
>        * and let it be rescheduled later.
>        */
>       if (new->to_flags & TIMEOUT_ONQUEUE) {
> -             if (new->to_time - ticks < old_time - ticks) {
> +             if (new->to_time - hcticks < old_time - hcticks) {
>                       CIRCQ_REMOVE(&new->to_list);
>                       CIRCQ_INSERT(&new->to_list, &timeout_todo);
>               }
> @@ -304,15 +304,15 @@ timeout_hardclock_update(void)
>  
>       mtx_enter(&timeout_mutex);
>  
> -     ticks++;
> +     hcticks++;
>  
> -     MOVEBUCKET(0, ticks);
> -     if (MASKWHEEL(0, ticks) == 0) {
> -             MOVEBUCKET(1, ticks);
> -             if (MASKWHEEL(1, ticks) == 0) {
> -                     MOVEBUCKET(2, ticks);
> -                     if (MASKWHEEL(2, ticks) == 0)
> -                             MOVEBUCKET(3, ticks);
> +     MOVEBUCKET(0, hcticks);
> +     if (MASKWHEEL(0, hcticks) == 0) {
> +             MOVEBUCKET(1, hcticks);
> +             if (MASKWHEEL(1, hcticks) == 0) {
> +                     MOVEBUCKET(2, hcticks);
> +                     if (MASKWHEEL(2, hcticks) == 0)
> +                             MOVEBUCKET(3, hcticks);
>               }
>       }
>       ret = !CIRCQ_EMPTY(&timeout_todo);
> @@ -333,14 +333,14 @@ softclock(void *arg)
>               CIRCQ_REMOVE(&to->to_list);
>  
>               /* If due run it, otherwise insert it into the right bucket. */
> -             if (to->to_time - ticks > 0) {
> +             if (to->to_time - hcticks > 0) {
>                       CIRCQ_INSERT(&to->to_list,
> -                         &BUCKET((to->to_time - ticks), to->to_time));
> +                         &BUCKET((to->to_time - hcticks), to->to_time));
>               } else {
>  #ifdef DEBUG
> -                     if (to->to_time - ticks < 0)
> +                     if (to->to_time - hcticks < 0)
>                               printf("timeout delayed %d\n", to->to_time -
> -                                 ticks);
> +                                 hcticks);
>  #endif
>                       to->to_flags &= ~TIMEOUT_ONQUEUE;
>                       to->to_flags |= TIMEOUT_TRIGGERED;
> @@ -369,7 +369,7 @@ timeout_adjust_ticks(int adj)
>               return;
>  
>       mtx_enter(&timeout_mutex);
> -     new_ticks = ticks + adj;
> +     new_ticks = hcticks + adj;
>       for (b = 0; b < nitems(timeout_wheel); b++) {
>               p = CIRCQ_FIRST(&timeout_wheel[b]);
>               while (p != &timeout_wheel[b]) {
> @@ -377,13 +377,13 @@ timeout_adjust_ticks(int adj)
>                       p = CIRCQ_FIRST(p);
>  
>                       /* when moving a timeout forward need to reinsert it */
> -                     if (to->to_time - ticks < adj)
> +                     if (to->to_time - hcticks < adj)
>                               to->to_time = new_ticks;
>                       CIRCQ_REMOVE(&to->to_list);
>                       CIRCQ_INSERT(&to->to_list, &timeout_todo);
>               }
>       }
> -     ticks = new_ticks;
> +     hcticks = new_ticks;
>       mtx_leave(&timeout_mutex);
>  }
>  #endif
> @@ -403,7 +403,7 @@ db_show_callout_bucket(struct circq *bucket)
>               to = timeout_from_circq(p);
>               db_find_sym_and_offset((db_addr_t)to->to_func, &name, &offset);
>               name = name ? name : "?";
> -             db_printf("%9d %2td/%-4td %p  %s\n", to->to_time - ticks,
> +             db_printf("%9d %2td/%-4td %p  %s\n", to->to_time - hcticks,
>                   (bucket - timeout_wheel) / WHEELSIZE,
>                   bucket - timeout_wheel, to->to_arg, name);
>       }
> @@ -414,8 +414,8 @@ db_show_callout(db_expr_t addr, int haddr, db_expr_t 
> count, char *modif)
>  {
>       int b;
>  
> -     db_printf("ticks now: %d\n", ticks);
> -     db_printf("    ticks  wheel       arg  func\n");
> +     db_printf("hcticks now: %d\n", hcticks);
> +     db_printf("    hcticks  wheel       arg  func\n");
>  
>       db_show_callout_bucket(&timeout_todo);
>       for (b = 0; b < nitems(timeout_wheel); b++)
> diff --git sys/kern/subr_pool.c sys/kern/subr_pool.c
> index 043cc8b..b75f3ad 100644
> --- sys/kern/subr_pool.c
> +++ sys/kern/subr_pool.c
> @@ -682,7 +682,7 @@ pool_put(struct pool *pp, void *v)
>                */
>               pp->pr_nidle++;
>  
> -             ph->ph_tick = ticks;
> +             ph->ph_tick = hcticks;
>               TAILQ_REMOVE(&pp->pr_partpages, ph, ph_pagelist);
>               TAILQ_INSERT_TAIL(&pp->pr_emptypages, ph, ph_pagelist);
>               pool_update_curpage(pp);
> @@ -694,7 +694,7 @@ pool_put(struct pool *pp, void *v)
>       /* is it time to free a page? */
>       if (pp->pr_nidle > pp->pr_maxpages &&
>           (ph = TAILQ_FIRST(&pp->pr_emptypages)) != NULL &&
> -         (ticks - ph->ph_tick) > (hz * pool_wait_free)) {
> +         (hcticks - ph->ph_tick) > (hz * pool_wait_free)) {
>               freeph = ph;
>               pool_p_remove(pp, freeph);
>       }
> @@ -1379,7 +1379,7 @@ pool_gc_pages(void *null)
>               /* is it time to free a page? */
>               if (pp->pr_nidle > pp->pr_minpages &&
>                   (ph = TAILQ_FIRST(&pp->pr_emptypages)) != NULL &&
> -                 (ticks - ph->ph_tick) > (hz * pool_wait_gc)) {
> +                 (hcticks - ph->ph_tick) > (hz * pool_wait_gc)) {
>                       freeph = ph;
>                       pool_p_remove(pp, freeph);
>               } else
> diff --git sys/net/bpf.c sys/net/bpf.c
> index e7a038e..a9afab6 100644
> --- sys/net/bpf.c
> +++ sys/net/bpf.c
> @@ -41,6 +41,7 @@
>  #include "bpfilter.h"
>  
>  #include <sys/param.h>
> +#include <sys/kernel.h>
>  #include <sys/systm.h>
>  #include <sys/mbuf.h>
>  #include <sys/proc.h>
> @@ -73,9 +74,6 @@
>  
>  #define PRINET  26                   /* interruptible */
>  
> -/* from kern/kern_clock.c; incremented each clock tick. */
> -extern int ticks;
> -
>  /*
>   * The default read buffer size is patchable.
>   */
> @@ -411,7 +409,7 @@ bpfread(dev_t dev, struct uio *uio, int ioflag)
>        * we can then figure out when we're done reading.
>        */
>       if (d->bd_rtout != -1 && d->bd_rdStart == 0)
> -             d->bd_rdStart = ticks;
> +             d->bd_rdStart = hcticks;
>       else
>               d->bd_rdStart = 0;
>  
> @@ -444,7 +442,7 @@ bpfread(dev_t dev, struct uio *uio, int ioflag)
>                       /* User requested non-blocking I/O */
>                       error = EWOULDBLOCK;
>               } else {
> -                     if ((d->bd_rdStart + d->bd_rtout) < ticks) {
> +                     if ((d->bd_rdStart + d->bd_rtout) < hcticks) {
>                               error = tsleep((caddr_t)d, PRINET|PCATCH, "bpf",
>                                   d->bd_rtout);
>                       } else
> @@ -1065,7 +1063,7 @@ bpfpoll(dev_t dev, int events, struct proc *p)
>                        * started waiting.
>                        */
>                       if (d->bd_rtout != -1 && d->bd_rdStart == 0)
> -                             d->bd_rdStart = ticks;
> +                             d->bd_rdStart = hcticks;
>                       selrecord(p, &d->bd_sel);
>               }
>               splx(s);
> @@ -1099,7 +1097,7 @@ bpfkqfilter(dev_t dev, struct knote *kn)
>       D_GET(d);
>       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
>       if (d->bd_rtout != -1 && d->bd_rdStart == 0)
> -             d->bd_rdStart = ticks;
> +             d->bd_rdStart = hcticks;
>       splx(s);
>  
>       return (0);
> @@ -1442,7 +1440,7 @@ bpf_catchpacket(struct bpf_d *d, u_char *pkt, size_t 
> pktlen, size_t snaplen,
>               bpf_wakeup(d);
>       }
>  
> -     if (d->bd_rdStart && (d->bd_rtout + d->bd_rdStart < ticks)) {
> +     if (d->bd_rdStart && (d->bd_rtout + d->bd_rdStart < hcticks)) {
>               /*
>                * we could be selecting on the bpf, and we
>                * may have timeouts set.  We got here by getting
> diff --git sys/net/if.c sys/net/if.c
> index fbe239d..907912f 100644
> --- sys/net/if.c
> +++ sys/net/if.c
> @@ -1121,20 +1121,17 @@ if_clone_list(struct if_clonereq *ifcr)
>  void
>  if_congestion(void)
>  {
> -     extern int ticks;
> -
> -     ifq_congestion = ticks;
> +     ifq_congestion = hcticks;
>  }
>  
>  int
>  if_congested(void)
>  {
> -     extern int ticks;
>       int diff;
>  
> -     diff = ticks - ifq_congestion;
> +     diff = hcticks - ifq_congestion;
>       if (diff < 0) {
> -             ifq_congestion = ticks - hz;
> +             ifq_congestion = hcticks - hz;
>               return (0);
>       }
>  
> @@ -2551,12 +2548,10 @@ u_int net_livelocks;
>  void
>  net_tick(void *null)
>  {
> -     extern int ticks;
> -
> -     if (ticks - net_ticks > 1)
> +     if (hcticks - net_ticks > 1)
>               net_livelocks++;
>  
> -     net_ticks = ticks;
> +     net_ticks = hcticks;
>  
>       timeout_add(&net_tick_to, 1);
>  }
> @@ -2564,19 +2559,15 @@ net_tick(void *null)
>  int
>  net_livelocked(void)
>  {
> -     extern int ticks;
> -
> -     return (ticks - net_ticks > 1);
> +     return (hcticks - net_ticks > 1);
>  }
>  
>  void
>  if_rxr_init(struct if_rxring *rxr, u_int lwm, u_int hwm)
>  {
> -     extern int ticks;
> -
>       memset(rxr, 0, sizeof(*rxr));
>  
> -     rxr->rxr_adjusted = ticks;
> +     rxr->rxr_adjusted = hcticks;
>       rxr->rxr_cwm = rxr->rxr_lwm = lwm;
>       rxr->rxr_hwm = hwm;
>  }
> @@ -2584,8 +2575,6 @@ if_rxr_init(struct if_rxring *rxr, u_int lwm, u_int hwm)
>  static inline void
>  if_rxr_adjust_cwm(struct if_rxring *rxr)
>  {
> -     extern int ticks;
> -
>       if (net_livelocked()) {
>               if (rxr->rxr_cwm > rxr->rxr_lwm)
>                       rxr->rxr_cwm--;
> @@ -2596,16 +2585,15 @@ if_rxr_adjust_cwm(struct if_rxring *rxr)
>       else if (rxr->rxr_cwm < rxr->rxr_hwm)
>               rxr->rxr_cwm++;
>  
> -     rxr->rxr_adjusted = ticks;
> +     rxr->rxr_adjusted = hcticks;
>  }
>  
>  u_int
>  if_rxr_get(struct if_rxring *rxr, u_int max)
>  {
> -     extern int ticks;
>       u_int diff;
>  
> -     if (ticks - rxr->rxr_adjusted >= 1) {
> +     if (hcticks - rxr->rxr_adjusted >= 1) {
>               /* we're free to try for an adjustment */
>               if_rxr_adjust_cwm(rxr);
>       }
> diff --git sys/net80211/ieee80211_crypto_tkip.c 
> sys/net80211/ieee80211_crypto_tkip.c
> index 20b84f1..e19cbfa 100644
> --- sys/net80211/ieee80211_crypto_tkip.c
> +++ sys/net80211/ieee80211_crypto_tkip.c
> @@ -23,6 +23,7 @@
>  
>  #include <sys/param.h>
>  #include <sys/systm.h>
> +#include <sys/kernel.h>
>  #include <sys/mbuf.h>
>  #include <sys/malloc.h>
>  #include <sys/kernel.h>
> @@ -499,8 +500,6 @@ ieee80211_tkip_deauth(void *arg, struct ieee80211_node 
> *ni)
>  void
>  ieee80211_michael_mic_failure(struct ieee80211com *ic, u_int64_t tsc)
>  {
> -     extern int ticks;
> -
>       if (ic->ic_flags & IEEE80211_F_COUNTERM)
>               return; /* countermeasures already active */
>  
> @@ -518,8 +517,8 @@ ieee80211_michael_mic_failure(struct ieee80211com *ic, 
> u_int64_t tsc)
>        * seconds have passed since the most recent previous MIC failure.
>        */
>       if (ic->ic_tkip_micfail == 0 ||
> -         ticks - (ic->ic_tkip_micfail + 60 * hz) >= 0) {
> -             ic->ic_tkip_micfail = ticks;
> +         hcticks - (ic->ic_tkip_micfail + 60 * hz) >= 0) {
> +             ic->ic_tkip_micfail = hcticks;
>               ic->ic_tkip_micfail_last_tsc = tsc;
>               return;
>       }
> @@ -558,7 +557,7 @@ ieee80211_michael_mic_failure(struct ieee80211com *ic, 
> u_int64_t tsc)
>               break;
>       }
>  
> -     ic->ic_tkip_micfail = ticks;
> +     ic->ic_tkip_micfail = hcticks;
>       ic->ic_tkip_micfail_last_tsc = tsc;
>  }
>  
> diff --git sys/sys/kernel.h sys/sys/kernel.h
> index 0aa5bab..79dd89b 100644
> --- sys/sys/kernel.h
> +++ sys/sys/kernel.h
> @@ -54,7 +54,7 @@ extern int tick;            /* usec per tick (1000000 / hz) 
> */
>  extern int tickfix;          /* periodic tick adj. tick not integral */
>  extern int tickfixinterval;  /* interval at which to apply adjustment */
>  extern int tickadj;          /* "standard" clock skew, us./tick */
> -extern int ticks;            /* # of hardclock ticks */
> +extern int hcticks;          /* # of hardclock ticks */
>  extern int hz;                       /* system clock's frequency */
>  extern int stathz;           /* statistics clock's frequency */
>  extern int profhz;           /* profiling clock's frequency */
> diff --git sys/sys/timeout.h sys/sys/timeout.h
> index 8f25af1..3f14f20 100644
> --- sys/sys/timeout.h
> +++ sys/sys/timeout.h
> @@ -39,7 +39,7 @@
>   *      Initializes a timeout struct to call the function with the argument.
>   *      A timeout only needs to be initialized once.
>   *  - timeout_add(timeout, ticks)
> - *      Schedule this timeout to run in "ticks" ticks (there are hz ticks in
> + *      Schedule this timeout to run in "hcticks" ticks (there are hz ticks 
> in
>   *      one second). You may not touch the timeout with timeout_set once the
>   *      timeout is scheduled. A second call to timeout_add with an already
>   *      scheduled timeout will cause the old timeout to be canceled and the
> 
> 

Reply via email to