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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/sadb.h
          +++ new/usr/src/uts/common/inet/sadb.h
↓ open down ↓ 345 lines elided ↑ open up ↑
 346  346  /*
 347  347   * ipsa_t reference hold/release macros.
 348  348   *
 349  349   * If you have a pointer, you REFHOLD.  If you are releasing a pointer, you
 350  350   * REFRELE.  An ipsa_t that is newly inserted into the table should have
 351  351   * a reference count of 1 (for the table's pointer), plus 1 more for every
 352  352   * pointer that is referencing the ipsa_t.
 353  353   */
 354  354  
 355  355  #define IPSA_REFHOLD(ipsa) {                    \
 356      -        atomic_add_32(&(ipsa)->ipsa_refcnt, 1); \
      356 +        atomic_inc_32(&(ipsa)->ipsa_refcnt);    \
 357  357          ASSERT((ipsa)->ipsa_refcnt != 0);       \
 358  358  }
 359  359  
 360  360  /*
 361  361   * Decrement the reference count on the SA.
 362  362   * In architectures e.g sun4u, where atomic_add_32_nv is just
 363  363   * a cas, we need to maintain the right memory barrier semantics
 364  364   * as that of mutex_exit i.e all the loads and stores should complete
 365  365   * before the cas is executed. membar_exit() does that here.
 366  366   */
 367  367  
 368  368  #define IPSA_REFRELE(ipsa) {                                    \
 369  369          ASSERT((ipsa)->ipsa_refcnt != 0);                       \
 370  370          membar_exit();                                          \
 371      -        if (atomic_add_32_nv(&(ipsa)->ipsa_refcnt, -1) == 0)    \
      371 +        if (atomic_dec_32_nv(&(ipsa)->ipsa_refcnt) == 0)        \
 372  372                  ((ipsa)->ipsa_freefunc)(ipsa);                  \
 373  373  }
 374  374  
 375  375  /*
 376  376   * Security association hash macros and definitions.  For now, assume the
 377  377   * IPsec model, and hash outbounds on destination address, and inbounds on
 378  378   * SPI.
 379  379   */
 380  380  
 381  381  #define IPSEC_DEFAULT_HASH_SIZE 256
↓ open down ↓ 600 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX