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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/refstr.c
          +++ new/usr/src/uts/common/os/refstr.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  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/refstr.h>
  34   32  #include <sys/refstr_impl.h>
  35   33  
  36   34  refstr_t *
  37   35  refstr_alloc(const char *str)
  38   36  {
↓ open down ↓ 11 lines elided ↑ open up ↑
  50   48  
  51   49  const char *
  52   50  refstr_value(refstr_t *rsp)
  53   51  {
  54   52          return (rsp != NULL ? (const char *)rsp->rs_string : NULL);
  55   53  }
  56   54  
  57   55  void
  58   56  refstr_hold(refstr_t *rsp)
  59   57  {
  60      -        atomic_add_32(&rsp->rs_refcnt, 1);
       58 +        atomic_inc_32(&rsp->rs_refcnt);
  61   59  }
  62   60  
  63   61  void
  64   62  refstr_rele(refstr_t *rsp)
  65   63  {
  66      -        if (atomic_add_32_nv(&rsp->rs_refcnt, -1) == 0)
       64 +        if (atomic_dec_32_nv(&rsp->rs_refcnt) == 0)
  67   65                  kmem_free(rsp, (size_t)rsp->rs_size);
  68   66  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX