Print this page
patch cstyle-atomic

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/cstyle.pl
          +++ new/usr/src/tools/scripts/cstyle.pl
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16  # If applicable, add the following below this CDDL HEADER, with the
  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 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24  # Use is subject to license terms.
  25   25  #
  26      -# @(#)cstyle 1.58 98/09/09 (from shannon)
  27      -#ident  "%Z%%M% %I%     %E% SMI"
  28      -#
  29   26  # cstyle - check for some common stylistic errors.
  30   27  #
  31   28  #       cstyle is a sort of "lint" for C coding style.
  32   29  #       It attempts to check for the style used in the
  33   30  #       kernel, sometimes known as "Bill Joy Normal Form".
  34   31  #
  35   32  #       There's a lot this can't check for, like proper indentation
  36   33  #       of code blocks.  There's also a lot more this could check for.
  37   34  #
  38   35  #       A note to the non perl literate:
↓ open down ↓ 585 lines elided ↑ open up ↑
 624  621                  err("missing space between type name and *");
 625  622          }
 626  623          if (/^\s+#/) {
 627  624                  err("preprocessor statement not in column 1");
 628  625          }
 629  626          if (/^#\s/) {
 630  627                  err("blank after preprocessor #");
 631  628          }
 632  629          if (/!\s*(strcmp|strncmp|bcmp)\s*\(/) {
 633  630                  err("don't use boolean ! with comparison functions");
      631 +        }
      632 +        if (/\batomic_add_(8|16|32|64|char|short|int|long)\([^,]*,\s*1\)/) {
      633 +                err("use atomic_inc_*(...) instead of atomic_add_*(..., 1)");
      634 +        }
      635 +        if (/\batomic_add_(8|16|32|64|char|short|int|long)\([^,]*,\s*-1\)/) {
      636 +                err("use atomic_dec_*(...) instead of atomic_add_*(..., -1)");
 634  637          }
 635  638  
 636  639          #
 637  640          # We completely ignore, for purposes of indentation:
 638  641          #  * lines outside of functions
 639  642          #  * preprocessor lines
 640  643          #
 641  644          if ($check_continuation && $in_function && !$in_cpp) {
 642  645                  process_indent($_);
 643  646          }
↓ open down ↓ 307 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX