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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/str_conf.c
          +++ new/usr/src/uts/common/io/str_conf.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 2004 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/types.h>
  30   28  #include <sys/param.h>
  31   29  #include <sys/systm.h>
  32   30  #include <sys/conf.h>
  33   31  #include <sys/stream.h>
  34   32  #include <sys/strsubr.h>
  35   33  #include <sys/modctl.h>
  36   34  #include <sys/modhash.h>
  37   35  #include <sys/atomic.h>
  38   36  
↓ open down ↓ 238 lines elided ↑ open up ↑
 277  275  fmodsw_impl_t *
 278  276  fmodsw_find(const char *name, fmodsw_flags_t flags)
 279  277  {
 280  278          fmodsw_impl_t   *fp;
 281  279          int             id;
 282  280  
 283  281  try_again:
 284  282          rw_enter(&fmodsw_lock, RW_READER);
 285  283          if (i_fmodsw_hash_find(name, &fp) == 0) {
 286  284                  if (flags & FMODSW_HOLD) {
 287      -                        atomic_add_32(&(fp->f_ref), 1); /* lock must be held */
      285 +                        atomic_inc_32(&(fp->f_ref));    /* lock must be held */
 288  286                          ASSERT(fp->f_ref > 0);
 289  287                  }
 290  288  
 291  289                  rw_exit(&fmodsw_lock);
 292  290                  return (fp);
 293  291          }
 294  292          rw_exit(&fmodsw_lock);
 295  293  
 296  294          if (flags & FMODSW_LOAD) {
 297  295                  if ((id = modload("strmod", (char *)name)) != -1) {
↓ open down ↓ 3 lines elided ↑ open up ↑
 301  299                  }
 302  300          }
 303  301  
 304  302          return (NULL);
 305  303  }
 306  304  
 307  305  void
 308  306  fmodsw_rele(fmodsw_impl_t *fp)
 309  307  {
 310  308          ASSERT(fp->f_ref > 0);
 311      -        atomic_add_32(&(fp->f_ref), -1);
      309 +        atomic_dec_32(&(fp->f_ref));
 312  310  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX