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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/syscall/corectl.c
          +++ new/usr/src/uts/common/syscall/corectl.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   26  #include <sys/proc.h>
  29   27  #include <sys/systm.h>
  30   28  #include <sys/param.h>
  31   29  #include <sys/atomic.h>
  32   30  #include <sys/kmem.h>
  33   31  #include <sys/sysmacros.h>
  34   32  #include <sys/procset.h>
  35   33  #include <sys/corectl.h>
  36   34  #include <sys/zone.h>
  37   35  #include <sys/cmn_err.h>
↓ open down ↓ 60 lines elided ↑ open up ↑
  98   96  corectl_content_set(corectl_content_t *ccp, core_content_t content)
  99   97  {
 100   98          mutex_enter(&ccp->ccc_mtx);
 101   99          ccp->ccc_content = content;
 102  100          mutex_exit(&ccp->ccc_mtx);
 103  101  }
 104  102  
 105  103  void
 106  104  corectl_content_hold(corectl_content_t *ccp)
 107  105  {
 108      -        atomic_add_32(&ccp->ccc_refcnt, 1);
      106 +        atomic_inc_32(&ccp->ccc_refcnt);
 109  107  }
 110  108  
 111  109  void
 112  110  corectl_content_rele(corectl_content_t *ccp)
 113  111  {
 114      -        if (atomic_add_32_nv(&ccp->ccc_refcnt, -1) == 0)
      112 +        if (atomic_dec_32_nv(&ccp->ccc_refcnt) == 0)
 115  113                  kmem_free(ccp, sizeof (corectl_content_t));
 116  114  }
 117  115  
 118  116  
 119  117  static corectl_path_t *
 120  118  corectl_path_alloc(const char *path)
 121  119  {
 122  120          corectl_path_t *ccp;
 123  121  
 124  122          ccp = kmem_zalloc(sizeof (corectl_path_t), KM_SLEEP);
↓ open down ↓ 22 lines elided ↑ open up ↑
 147  145  
 148  146          mutex_enter(&ccp->ccp_mtx);
 149  147          refstr_rele(ccp->ccp_path);
 150  148          ccp->ccp_path = npath;
 151  149          mutex_exit(&ccp->ccp_mtx);
 152  150  }
 153  151  
 154  152  void
 155  153  corectl_path_hold(corectl_path_t *ccp)
 156  154  {
 157      -        atomic_add_32(&ccp->ccp_refcnt, 1);
      155 +        atomic_inc_32(&ccp->ccp_refcnt);
 158  156  }
 159  157  
 160  158  void
 161  159  corectl_path_rele(corectl_path_t *ccp)
 162  160  {
 163      -        if (atomic_add_32_nv(&ccp->ccp_refcnt, -1) == 0) {
      161 +        if (atomic_dec_32_nv(&ccp->ccp_refcnt) == 0) {
 164  162                  refstr_rele(ccp->ccp_path);
 165  163                  kmem_free(ccp, sizeof (corectl_path_t));
 166  164          }
 167  165  }
 168  166  
 169  167  /*
 170  168   * Constructor routine to be called when a zone is created.
 171  169   */
 172  170  /*ARGSUSED*/
 173  171  static void *
↓ open down ↓ 390 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX