Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/evchannels.c
          +++ new/usr/src/uts/common/os/evchannels.c
↓ open down ↓ 371 lines elided ↑ open up ↑
 372  372  /*
 373  373   * Frees evch_gevent_t structure including the payload, if the reference count
 374  374   * drops to or below zero. Below zero happens when the event is freed
 375  375   * without beeing queued into a queue.
 376  376   */
 377  377  static void
 378  378  evch_gevent_free(evch_gevent_t *evp)
 379  379  {
 380  380          int32_t refcnt;
 381  381  
 382      -        refcnt = (int32_t)atomic_add_32_nv(&evp->ge_refcount, -1);
      382 +        refcnt = (int32_t)atomic_dec_32_nv(&evp->ge_refcount);
 383  383          if (refcnt <= 0) {
 384  384                  if (evp->ge_destruct != NULL) {
 385  385                          evp->ge_destruct((void *)&(evp->ge_payload),
 386  386                              evp->ge_dstcookie);
 387  387                  }
 388  388                  kmem_free(evp, evp->ge_size);
 389  389          }
 390  390  }
 391  391  
 392  392  /*
↓ open down ↓ 247 lines elided ↑ open up ↑
 640  640                  qep = kmem_alloc_tryhard(size, &size, KM_NOSLEEP);
 641  641          } else {
 642  642                  qep = kmem_alloc(size, flags & EVCH_NOSLEEP ?
 643  643                      KM_NOSLEEP : KM_SLEEP);
 644  644          }
 645  645          if (qep == NULL) {
 646  646                  return (-1);
 647  647          }
 648  648          qep->q_objref = (void *)evp;
 649  649          qep->q_objsize = size;
 650      -        atomic_add_32(&evp->ge_refcount, 1);
      650 +        atomic_inc_32(&evp->ge_refcount);
 651  651          mutex_enter(&eqp->eq_queuemx);
 652  652          evch_q_in(&eqp->eq_eventq, qep);
 653  653  
 654  654          /* Wakeup delivery thread */
 655  655          cv_signal(&eqp->eq_thrsleepcv);
 656  656          mutex_exit(&eqp->eq_queuemx);
 657  657          return (0);
 658  658  }
 659  659  
 660  660  /*
↓ open down ↓ 1686 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX