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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/cred.c
          +++ new/usr/src/uts/common/os/cred.c
↓ open down ↓ 336 lines elided ↑ open up ↑
 337  337          }
 338  338  }
 339  339  
 340  340  /*
 341  341   * Put a hold on a cred structure.
 342  342   */
 343  343  void
 344  344  crhold(cred_t *cr)
 345  345  {
 346  346          ASSERT(cr->cr_ref != 0xdeadbeef && cr->cr_ref != 0);
 347      -        atomic_add_32(&cr->cr_ref, 1);
      347 +        atomic_inc_32(&cr->cr_ref);
 348  348  }
 349  349  
 350  350  /*
 351  351   * Release previous hold on a cred structure.  Free it if refcnt == 0.
 352  352   * If cred uses label different from zone label, free it.
 353  353   */
 354  354  void
 355  355  crfree(cred_t *cr)
 356  356  {
 357  357          ASSERT(cr->cr_ref != 0xdeadbeef && cr->cr_ref != 0);
 358      -        if (atomic_add_32_nv(&cr->cr_ref, -1) == 0) {
      358 +        if (atomic_dec_32_nv(&cr->cr_ref) == 0) {
 359  359                  ASSERT(cr != kcred);
 360  360                  if (cr->cr_label)
 361  361                          label_rele(cr->cr_label);
 362  362                  if (cr->cr_klpd)
 363  363                          crklpd_rele(cr->cr_klpd);
 364  364                  if (cr->cr_zone)
 365  365                          zone_cred_rele(cr->cr_zone);
 366  366                  if (cr->cr_ksid)
 367  367                          kcrsid_rele(cr->cr_ksid);
 368  368                  if (cr->cr_grps)
↓ open down ↓ 1091 lines elided ↑ open up ↑
1460 1460  
1461 1461          if (cr->cr_grps != NULL)
1462 1462                  crgrprele(cr->cr_grps);
1463 1463  
1464 1464          cr->cr_grps = grps;
1465 1465  }
1466 1466  
1467 1467  void
1468 1468  crgrprele(credgrp_t *grps)
1469 1469  {
1470      -        if (atomic_add_32_nv(&grps->crg_ref, -1) == 0)
     1470 +        if (atomic_dec_32_nv(&grps->crg_ref) == 0)
1471 1471                  kmem_free(grps, CREDGRPSZ(grps->crg_ngroups));
1472 1472  }
1473 1473  
1474 1474  static void
1475 1475  crgrphold(credgrp_t *grps)
1476 1476  {
1477      -        atomic_add_32(&grps->crg_ref, 1);
     1477 +        atomic_inc_32(&grps->crg_ref);
1478 1478  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX