Print this page
5042 stop using deprecated atomic functions

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/sun4/os/prom_subr.c
          +++ new/usr/src/uts/sun4/os/prom_subr.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 2008 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/types.h>
  29   27  #include <sys/param.h>
  30   28  #include <sys/cmn_err.h>
  31   29  #include <sys/mutex.h>
  32   30  #include <sys/systm.h>
  33   31  #include <sys/sysmacros.h>
  34   32  #include <sys/machsystm.h>
  35   33  #include <sys/archsystm.h>
  36   34  #include <sys/x_call.h>
  37   35  #include <sys/promif.h>
↓ open down ↓ 228 lines elided ↑ open up ↑
 266  264                          cp = CPU;
 267  265                          ASSERT(cp->cpu_m.mutex_ready);
 268  266  
 269  267                          /*
 270  268                           * Try the lock.  If we don't get the lock, re-enable
 271  269                           * preemption and see if we should sleep.  If we are
 272  270                           * already the lock holder, remove the effect of the
 273  271                           * previous kpreempt_disable() before returning since
 274  272                           * preemption was disabled by an earlier kern_preprom.
 275  273                           */
 276      -                        prcp = casptr((void *)&prom_cpu, NULL, cp);
      274 +                        prcp = atomic_cas_ptr((void *)&prom_cpu, NULL, cp);
 277  275                          if (prcp == NULL ||
 278  276                              (prcp == cp && prom_thread == curthread)) {
 279  277                                  if (prcp == cp)
 280  278                                          kpreempt_enable();
 281  279                                  break;
 282  280                          }
 283  281  
 284  282                          kpreempt_enable();
 285  283  
 286  284                          /*
↓ open down ↓ 16 lines elided ↑ open up ↑
 303  301                                          cv_wait(&prom_cv, &prom_mutex);
 304  302                          }
 305  303                          mutex_exit(&prom_mutex);
 306  304  
 307  305                  } else {
 308  306                          /*
 309  307                           * If we are not yet mutex_ready, just attempt to grab
 310  308                           * the lock.  If we get it or already hold it, break.
 311  309                           */
 312  310                          ASSERT(getpil() == PIL_MAX);
 313      -                        prcp = casptr((void *)&prom_cpu, NULL, cp);
      311 +                        prcp = atomic_cas_ptr((void *)&prom_cpu, NULL, cp);
 314  312                          if (prcp == NULL || prcp == cp)
 315  313                                  break;
 316  314                  }
 317  315          }
 318  316  
 319  317          /*
 320  318           * We now hold the prom_cpu lock.  Increment the hold count by one
 321  319           * and assert our current state before returning to the caller.
 322  320           */
 323  321          atomic_add_32(&prom_holdcnt, 1);
↓ open down ↓ 268 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX