Print this page
5042 stop using deprecated atomic functions

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/bge/bge_atomic.c
          +++ new/usr/src/uts/common/io/bge/bge_atomic.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2006 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 "bge_impl.h"
  30   28  
  31   29  /*
  32   30   * Atomically decrement a counter, but only if it will remain
  33   31   * strictly positive (greater than zero) afterwards.  We return
  34   32   * the decremented value if so, otherwise zero (in which case
  35   33   * the counter is unchanged).
  36   34   *
  37   35   * This is used for keeping track of available resources such
  38   36   * as transmit ring slots ...
↓ open down ↓ 3 lines elided ↑ open up ↑
  42   40  {
  43   41          uint64_t oldval;
  44   42          uint64_t newval;
  45   43  
  46   44          /* ATOMICALLY */
  47   45          do {
  48   46                  oldval = *count_p;
  49   47                  newval = oldval - n;
  50   48                  if (oldval <= n)
  51   49                          return (0);             /* no resources left    */
  52      -        } while (cas64(count_p, oldval, newval) != oldval);
       50 +        } while (atomic_cas_64(count_p, oldval, newval) != oldval);
  53   51  
  54   52          return (newval);
  55   53  }
  56   54  
  57   55  /*
  58   56   * Atomically increment a counter
  59   57   */
  60   58  void
  61   59  bge_atomic_renounce(uint64_t *count_p, uint64_t n)
  62   60  {
  63   61          uint64_t oldval;
  64   62          uint64_t newval;
  65   63  
  66   64          /* ATOMICALLY */
  67   65          do {
  68   66                  oldval = *count_p;
  69   67                  newval = oldval + n;
  70      -        } while (cas64(count_p, oldval, newval) != oldval);
       68 +        } while (atomic_cas_64(count_p, oldval, newval) != oldval);
  71   69  }
  72   70  
  73   71  /*
  74   72   * Atomically claim a slot in a descriptor ring
  75   73   */
  76   74  uint64_t
  77   75  bge_atomic_claim(uint64_t *count_p, uint64_t limit)
  78   76  {
  79   77          uint64_t oldval;
  80   78          uint64_t newval;
  81   79  
  82   80          /* ATOMICALLY */
  83   81          do {
  84   82                  oldval = *count_p;
  85   83                  newval = NEXT(oldval, limit);
  86      -        } while (cas64(count_p, oldval, newval) != oldval);
       84 +        } while (atomic_cas_64(count_p, oldval, newval) != oldval);
  87   85  
  88   86          return (oldval);
  89   87  }
  90   88  
  91   89  /*
  92   90   * Atomically NEXT a 64-bit integer, returning the
  93   91   * value it had *before* the NEXT was applied
  94   92   */
  95   93  uint64_t
  96   94  bge_atomic_next(uint64_t *sp, uint64_t limit)
  97   95  {
  98   96          uint64_t oldval;
  99   97          uint64_t newval;
 100   98  
 101   99          /* ATOMICALLY */
 102  100          do {
 103  101                  oldval = *sp;
 104  102                  newval = NEXT(oldval, limit);
 105      -        } while (cas64(sp, oldval, newval) != oldval);
      103 +        } while (atomic_cas_64(sp, oldval, newval) != oldval);
 106  104  
 107  105          return (oldval);
 108  106  }
 109  107  
 110  108  /*
 111  109   * Atomically decrement a counter
 112  110   */
 113  111  void
 114  112  bge_atomic_sub64(uint64_t *count_p, uint64_t n)
 115  113  {
 116  114          uint64_t oldval;
 117  115          uint64_t newval;
 118  116  
 119  117          /* ATOMICALLY */
 120  118          do {
 121  119                  oldval = *count_p;
 122  120                  newval = oldval - n;
 123      -        } while (cas64(count_p, oldval, newval) != oldval);
      121 +        } while (atomic_cas_64(count_p, oldval, newval) != oldval);
 124  122  }
 125  123  
 126  124  /*
 127  125   * Atomically clear bits in a 64-bit word, returning
 128  126   * the value it had *before* the bits were cleared.
 129  127   */
 130  128  uint64_t
 131  129  bge_atomic_clr64(uint64_t *sp, uint64_t bits)
 132  130  {
 133  131          uint64_t oldval;
 134  132          uint64_t newval;
 135  133  
 136  134          /* ATOMICALLY */
 137  135          do {
 138  136                  oldval = *sp;
 139  137                  newval = oldval & ~bits;
 140      -        } while (cas64(sp, oldval, newval) != oldval);
      138 +        } while (atomic_cas_64(sp, oldval, newval) != oldval);
 141  139  
 142  140          return (oldval);
 143  141  }
 144  142  
 145  143  /*
 146  144   * Atomically shift a 32-bit word left, returning
 147  145   * the value it had *before* the shift was applied
 148  146   */
 149  147  uint32_t
 150  148  bge_atomic_shl32(uint32_t *sp, uint_t count)
 151  149  {
 152  150          uint32_t oldval;
 153  151          uint32_t newval;
 154  152  
 155  153          /* ATOMICALLY */
 156  154          do {
 157  155                  oldval = *sp;
 158  156                  newval = oldval << count;
 159      -        } while (cas32(sp, oldval, newval) != oldval);
      157 +        } while (atomic_cas_32(sp, oldval, newval) != oldval);
 160  158  
 161  159          return (oldval);
 162  160  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX