The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/tools/cocci/hw_atomic_rewrite.cocci

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 // To apply, at the top of xnu.git:
    2 // $ spatch --max-width=120 --use-gitgrep --in-place --include-headers --sp-file tools/cocci/hw_atomic_rewrite.cocci -dir .
    3 //
    4 // coccinelle insists on adding a space for (void) casts which can be fixed with:
    5 // $ git grep -l 'os_atomic' | xargs -n1 sed -i '' -e 's/os_atomic/os_atomic/'
    6 
    7 @@ expression E, F; @@ // hw_atomic_add -> os_atomic_{inc,dec}
    8 
    9 (
   10 - hw_atomic_add(E, -1) + 1
   11 + os_atomic_dec_orig(E, relaxed)
   12 |
   13 - hw_atomic_add(E, -1)
   14 + os_atomic_dec(E, relaxed)
   15 |
   16 - hw_atomic_add(E, -F) + F
   17 + os_atomic_sub_orig(E, F, relaxed)
   18 |
   19 - hw_atomic_add(E, -F)
   20 + os_atomic_sub(E, F, relaxed)
   21 |
   22 - hw_atomic_add(E, 1) - 1
   23 + os_atomic_inc_orig(E, relaxed)
   24 |
   25 - hw_atomic_add(E, 1)
   26 + os_atomic_inc(E, relaxed)
   27 |
   28 - hw_atomic_add(E, F) - F
   29 + os_atomic_add_orig(E, F, relaxed)
   30 |
   31 - hw_atomic_add(E, F)
   32 + os_atomic_add(E, F, relaxed)
   33 )
   34 
   35 @@ expression E, F; @@ // hw_atomic_sub -> os_atomic_{inc,dec}
   36 
   37 (
   38 - hw_atomic_sub(E, -1) - 1
   39 + os_atomic_inc_orig(E, relaxed)
   40 |
   41 - hw_atomic_sub(E, -1)
   42 + os_atomic_inc(E, relaxed)
   43 |
   44 - hw_atomic_sub(E, -F) - F
   45 + os_atomic_add_orig(E, F, relaxed)
   46 |
   47 - hw_atomic_sub(E, -F)
   48 + os_atomic_add(E, F, relaxed)
   49 |
   50 - hw_atomic_sub(E, 1) + 1
   51 + os_atomic_dec_orig(E, relaxed)
   52 |
   53 - hw_atomic_sub(E, 1)
   54 + os_atomic_dec(E, relaxed)
   55 |
   56 - hw_atomic_sub(E, F) + F
   57 + os_atomic_sub_orig(E, F, relaxed)
   58 |
   59 - hw_atomic_sub(E, F)
   60 + os_atomic_sub(E, F, relaxed)
   61 )
   62 
   63 @@ expression E, F; @@ // hw_atomic_and -> os_atomic_and
   64 
   65 (
   66 - hw_atomic_and(E, ~F)
   67 + os_atomic_andnot(E, F, relaxed)
   68 |
   69 - hw_atomic_and(E, F)
   70 + os_atomic_and(E, F, relaxed)
   71 |
   72 - hw_atomic_and_noret(E, ~F)
   73 + os_atomic_andnot(E, F, relaxed)
   74 |
   75 - hw_atomic_and_noret(E, F)
   76 + os_atomic_and(E, F, relaxed)
   77 )
   78 
   79 @@ expression E, F; @@ // hw_atomic_or -> os_atomic_or
   80 
   81 (
   82 - hw_atomic_or(E, F)
   83 + os_atomic_or(E, F, relaxed)
   84 |
   85 - hw_atomic_or_noret(E, F)
   86 + os_atomic_or(E, F, relaxed)
   87 )
   88 
   89 @@ expression E, F, A; @@ // hw_compare_and_store
   90 
   91 (
   92 - hw_compare_and_store(E, F, A)
   93 + os_atomic_cmpxchg(A, E, F, acq_rel)
   94 )
   95 
   96 // vim:ft=diff:

Cache object: cd98fa1ba60e1d645db0b5544ec1b51d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.