~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/atomic/atomic-tbl.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/atomic/atomic-tbl.sh (Architecture sparc) and /scripts/atomic/atomic-tbl.sh (Architecture ppc)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 # helpers for dealing with atomics.tbl              3 # helpers for dealing with atomics.tbl
  4                                                     4 
  5 #meta_in(meta, match)                               5 #meta_in(meta, match)
  6 meta_in()                                           6 meta_in()
  7 {                                                   7 {
  8         case "$1" in                                8         case "$1" in
  9         [$2]) return 0;;                            9         [$2]) return 0;;
 10         esac                                       10         esac
 11                                                    11 
 12         return 1                                   12         return 1
 13 }                                                  13 }
 14                                                    14 
 15 #meta_has_ret(meta)                                15 #meta_has_ret(meta)
 16 meta_has_ret()                                     16 meta_has_ret()
 17 {                                                  17 {
 18         meta_in "$1" "bBiIfFlR"                    18         meta_in "$1" "bBiIfFlR"
 19 }                                                  19 }
 20                                                    20 
 21 #meta_has_acquire(meta)                            21 #meta_has_acquire(meta)
 22 meta_has_acquire()                                 22 meta_has_acquire()
 23 {                                                  23 {
 24         meta_in "$1" "BFIlR"                       24         meta_in "$1" "BFIlR"
 25 }                                                  25 }
 26                                                    26 
 27 #meta_has_release(meta)                            27 #meta_has_release(meta)
 28 meta_has_release()                                 28 meta_has_release()
 29 {                                                  29 {
 30         meta_in "$1" "BFIRs"                       30         meta_in "$1" "BFIRs"
 31 }                                                  31 }
 32                                                    32 
 33 #meta_has_relaxed(meta)                            33 #meta_has_relaxed(meta)
 34 meta_has_relaxed()                                 34 meta_has_relaxed()
 35 {                                                  35 {
 36         meta_in "$1" "BFIR"                        36         meta_in "$1" "BFIR"
 37 }                                                  37 }
 38                                                    38 
 39 #meta_is_implicitly_relaxed(meta)                  39 #meta_is_implicitly_relaxed(meta)
 40 meta_is_implicitly_relaxed()                       40 meta_is_implicitly_relaxed()
 41 {                                                  41 {
 42         meta_in "$1" "vls"                         42         meta_in "$1" "vls"
 43 }                                                  43 }
 44                                                    44 
 45 #find_template(tmpltype, pfx, name, sfx, order     45 #find_template(tmpltype, pfx, name, sfx, order)
 46 find_template()                                    46 find_template()
 47 {                                                  47 {
 48         local tmpltype="$1"; shift                 48         local tmpltype="$1"; shift
 49         local pfx="$1"; shift                      49         local pfx="$1"; shift
 50         local name="$1"; shift                     50         local name="$1"; shift
 51         local sfx="$1"; shift                      51         local sfx="$1"; shift
 52         local order="$1"; shift                    52         local order="$1"; shift
 53                                                    53 
 54         local base=""                              54         local base=""
 55         local file=""                              55         local file=""
 56                                                    56 
 57         # We may have fallbacks for a specific     57         # We may have fallbacks for a specific case (e.g. read_acquire()), or
 58         # an entire class, e.g. *inc*().           58         # an entire class, e.g. *inc*().
 59         #                                          59         #
 60         # Start at the most specific, and fall     60         # Start at the most specific, and fall back to the most general. Once
 61         # we find a specific fallback, don't b     61         # we find a specific fallback, don't bother looking for more.
 62         for base in "${pfx}${name}${sfx}${orde     62         for base in "${pfx}${name}${sfx}${order}" "${pfx}${name}${sfx}" "${name}"; do
 63                 file="${ATOMICDIR}/${tmpltype}     63                 file="${ATOMICDIR}/${tmpltype}/${base}"
 64                                                    64 
 65                 if [ -f "${file}" ]; then          65                 if [ -f "${file}" ]; then
 66                         printf "${file}"           66                         printf "${file}"
 67                         break                      67                         break
 68                 fi                                 68                 fi
 69         done                                       69         done
 70 }                                                  70 }
 71                                                    71 
 72 #find_fallback_template(pfx, name, sfx, order)     72 #find_fallback_template(pfx, name, sfx, order)
 73 find_fallback_template()                           73 find_fallback_template()
 74 {                                                  74 {
 75         find_template "fallbacks" "$@"             75         find_template "fallbacks" "$@"
 76 }                                                  76 }
 77                                                    77 
 78 #find_kerneldoc_template(pfx, name, sfx, order     78 #find_kerneldoc_template(pfx, name, sfx, order)
 79 find_kerneldoc_template()                          79 find_kerneldoc_template()
 80 {                                                  80 {
 81         find_template "kerneldoc" "$@"             81         find_template "kerneldoc" "$@"
 82 }                                                  82 }
 83                                                    83 
 84 #gen_ret_type(meta, int)                           84 #gen_ret_type(meta, int)
 85 gen_ret_type() {                                   85 gen_ret_type() {
 86         local meta="$1"; shift                     86         local meta="$1"; shift
 87         local int="$1"; shift                      87         local int="$1"; shift
 88                                                    88 
 89         case "${meta}" in                          89         case "${meta}" in
 90         [sv]) printf "void";;                      90         [sv]) printf "void";;
 91         [bB]) printf "bool";;                      91         [bB]) printf "bool";;
 92         [aiIfFlR]) printf "${int}";;               92         [aiIfFlR]) printf "${int}";;
 93         esac                                       93         esac
 94 }                                                  94 }
 95                                                    95 
 96 #gen_ret_stmt(meta)                                96 #gen_ret_stmt(meta)
 97 gen_ret_stmt()                                     97 gen_ret_stmt()
 98 {                                                  98 {
 99         if meta_has_ret "${meta}"; then            99         if meta_has_ret "${meta}"; then
100                 printf "return ";                 100                 printf "return ";
101         fi                                        101         fi
102 }                                                 102 }
103                                                   103 
104 # gen_param_name(arg)                             104 # gen_param_name(arg)
105 gen_param_name()                                  105 gen_param_name()
106 {                                                 106 {
107         # strip off the leading 'c' for 'cv'      107         # strip off the leading 'c' for 'cv'
108         local name="${1#c}"                       108         local name="${1#c}"
109         printf "${name#*:}"                       109         printf "${name#*:}"
110 }                                                 110 }
111                                                   111 
112 # gen_param_type(arg, int, atomic)                112 # gen_param_type(arg, int, atomic)
113 gen_param_type()                                  113 gen_param_type()
114 {                                                 114 {
115         local type="${1%%:*}"; shift              115         local type="${1%%:*}"; shift
116         local int="$1"; shift                     116         local int="$1"; shift
117         local atomic="$1"; shift                  117         local atomic="$1"; shift
118                                                   118 
119         case "${type}" in                         119         case "${type}" in
120         i) type="${int} ";;                       120         i) type="${int} ";;
121         p) type="${int} *";;                      121         p) type="${int} *";;
122         v) type="${atomic}_t *";;                 122         v) type="${atomic}_t *";;
123         cv) type="const ${atomic}_t *";;          123         cv) type="const ${atomic}_t *";;
124         esac                                      124         esac
125                                                   125 
126         printf "${type}"                          126         printf "${type}"
127 }                                                 127 }
128                                                   128 
129 #gen_param(arg, int, atomic)                      129 #gen_param(arg, int, atomic)
130 gen_param()                                       130 gen_param()
131 {                                                 131 {
132         local arg="$1"; shift                     132         local arg="$1"; shift
133         local int="$1"; shift                     133         local int="$1"; shift
134         local atomic="$1"; shift                  134         local atomic="$1"; shift
135         local name="$(gen_param_name "${arg}")    135         local name="$(gen_param_name "${arg}")"
136         local type="$(gen_param_type "${arg}"     136         local type="$(gen_param_type "${arg}" "${int}" "${atomic}")"
137                                                   137 
138         printf "${type}${name}"                   138         printf "${type}${name}"
139 }                                                 139 }
140                                                   140 
141 #gen_params(int, atomic, arg...)                  141 #gen_params(int, atomic, arg...)
142 gen_params()                                      142 gen_params()
143 {                                                 143 {
144         local int="$1"; shift                     144         local int="$1"; shift
145         local atomic="$1"; shift                  145         local atomic="$1"; shift
146                                                   146 
147         while [ "$#" -gt 0 ]; do                  147         while [ "$#" -gt 0 ]; do
148                 gen_param "$1" "${int}" "${ato    148                 gen_param "$1" "${int}" "${atomic}"
149                 [ "$#" -gt 1 ] && printf ", "     149                 [ "$#" -gt 1 ] && printf ", "
150                 shift;                            150                 shift;
151         done                                      151         done
152 }                                                 152 }
153                                                   153 
154 #gen_args(arg...)                                 154 #gen_args(arg...)
155 gen_args()                                        155 gen_args()
156 {                                                 156 {
157         while [ "$#" -gt 0 ]; do                  157         while [ "$#" -gt 0 ]; do
158                 printf "$(gen_param_name "$1")    158                 printf "$(gen_param_name "$1")"
159                 [ "$#" -gt 1 ] && printf ", "     159                 [ "$#" -gt 1 ] && printf ", "
160                 shift;                            160                 shift;
161         done                                      161         done
162 }                                                 162 }
163                                                   163 
164 #gen_desc_return(meta)                            164 #gen_desc_return(meta)
165 gen_desc_return()                                 165 gen_desc_return()
166 {                                                 166 {
167         local meta="$1"; shift                    167         local meta="$1"; shift
168                                                   168 
169         case "${meta}" in                         169         case "${meta}" in
170         [v])                                      170         [v])
171                 printf "Return: Nothing."         171                 printf "Return: Nothing."
172                 ;;                                172                 ;;
173         [Ff])                                     173         [Ff])
174                 printf "Return: The original v    174                 printf "Return: The original value of @v."
175                 ;;                                175                 ;;
176         [R])                                      176         [R])
177                 printf "Return: The updated va    177                 printf "Return: The updated value of @v."
178                 ;;                                178                 ;;
179         [l])                                      179         [l])
180                 printf "Return: The value of @    180                 printf "Return: The value of @v."
181                 ;;                                181                 ;;
182         esac                                      182         esac
183 }                                                 183 }
184                                                   184 
185 #gen_template_kerneldoc(template, class, meta,    185 #gen_template_kerneldoc(template, class, meta, pfx, name, sfx, order, atomic, int, args...)
186 gen_template_kerneldoc()                          186 gen_template_kerneldoc()
187 {                                                 187 {
188         local template="$1"; shift                188         local template="$1"; shift
189         local class="$1"; shift                   189         local class="$1"; shift
190         local meta="$1"; shift                    190         local meta="$1"; shift
191         local pfx="$1"; shift                     191         local pfx="$1"; shift
192         local name="$1"; shift                    192         local name="$1"; shift
193         local sfx="$1"; shift                     193         local sfx="$1"; shift
194         local order="$1"; shift                   194         local order="$1"; shift
195         local atomic="$1"; shift                  195         local atomic="$1"; shift
196         local int="$1"; shift                     196         local int="$1"; shift
197                                                   197 
198         local atomicname="${atomic}_${pfx}${na    198         local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
199                                                   199 
200         local ret="$(gen_ret_type "${meta}" "$    200         local ret="$(gen_ret_type "${meta}" "${int}")"
201         local retstmt="$(gen_ret_stmt "${meta}    201         local retstmt="$(gen_ret_stmt "${meta}")"
202         local params="$(gen_params "${int}" "$    202         local params="$(gen_params "${int}" "${atomic}" "$@")"
203         local args="$(gen_args "$@")"             203         local args="$(gen_args "$@")"
204         local desc_order=""                       204         local desc_order=""
205         local desc_instrumentation=""             205         local desc_instrumentation=""
206         local desc_return=""                      206         local desc_return=""
207                                                   207 
208         if [ ! -z "${order}" ]; then              208         if [ ! -z "${order}" ]; then
209                 desc_order="${order##_}"          209                 desc_order="${order##_}"
210         elif meta_is_implicitly_relaxed "${met    210         elif meta_is_implicitly_relaxed "${meta}"; then
211                 desc_order="relaxed"              211                 desc_order="relaxed"
212         else                                      212         else
213                 desc_order="full"                 213                 desc_order="full"
214         fi                                        214         fi
215                                                   215 
216         if [ -z "${class}" ]; then                216         if [ -z "${class}" ]; then
217                 desc_noinstr="Unsafe to use in    217                 desc_noinstr="Unsafe to use in noinstr code; use raw_${atomicname}() there."
218         else                                      218         else
219                 desc_noinstr="Safe to use in n    219                 desc_noinstr="Safe to use in noinstr code; prefer ${atomicname}() elsewhere."
220         fi                                        220         fi
221                                                   221 
222         desc_return="$(gen_desc_return "${meta    222         desc_return="$(gen_desc_return "${meta}")"
223                                                   223 
224         . ${template}                             224         . ${template}
225 }                                                 225 }
226                                                   226 
227 #gen_kerneldoc(class, meta, pfx, name, sfx, or    227 #gen_kerneldoc(class, meta, pfx, name, sfx, order, atomic, int, args...)
228 gen_kerneldoc()                                   228 gen_kerneldoc()
229 {                                                 229 {
230         local class="$1"; shift                   230         local class="$1"; shift
231         local meta="$1"; shift                    231         local meta="$1"; shift
232         local pfx="$1"; shift                     232         local pfx="$1"; shift
233         local name="$1"; shift                    233         local name="$1"; shift
234         local sfx="$1"; shift                     234         local sfx="$1"; shift
235         local order="$1"; shift                   235         local order="$1"; shift
236                                                   236 
237         local atomicname="${atomic}_${pfx}${na    237         local atomicname="${atomic}_${pfx}${name}${sfx}${order}"
238                                                   238 
239         local tmpl="$(find_kerneldoc_template     239         local tmpl="$(find_kerneldoc_template "${pfx}" "${name}" "${sfx}" "${order}")"
240         if [ -z "${tmpl}" ]; then                 240         if [ -z "${tmpl}" ]; then
241                 printf "/*\n"                     241                 printf "/*\n"
242                 printf " * No kerneldoc availa    242                 printf " * No kerneldoc available for ${class}${atomicname}\n"
243                 printf " */\n"                    243                 printf " */\n"
244         else                                      244         else
245         gen_template_kerneldoc "${tmpl}" "${cl    245         gen_template_kerneldoc "${tmpl}" "${class}" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "$@"
246         fi                                        246         fi
247 }                                                 247 }
248                                                   248 
249 #gen_proto_order_variants(meta, pfx, name, sfx    249 #gen_proto_order_variants(meta, pfx, name, sfx, ...)
250 gen_proto_order_variants()                        250 gen_proto_order_variants()
251 {                                                 251 {
252         local meta="$1"; shift                    252         local meta="$1"; shift
253         local pfx="$1"; shift                     253         local pfx="$1"; shift
254         local name="$1"; shift                    254         local name="$1"; shift
255         local sfx="$1"; shift                     255         local sfx="$1"; shift
256                                                   256 
257         gen_proto_order_variant "${meta}" "${p    257         gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
258                                                   258 
259         if meta_has_acquire "${meta}"; then       259         if meta_has_acquire "${meta}"; then
260                 gen_proto_order_variant "${met    260                 gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
261         fi                                        261         fi
262         if meta_has_release "${meta}"; then       262         if meta_has_release "${meta}"; then
263                 gen_proto_order_variant "${met    263                 gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
264         fi                                        264         fi
265         if meta_has_relaxed "${meta}"; then       265         if meta_has_relaxed "${meta}"; then
266                 gen_proto_order_variant "${met    266                 gen_proto_order_variant "${meta}" "${pfx}" "${name}" "${sfx}" "_relaxed" "$@"
267         fi                                        267         fi
268 }                                                 268 }
269                                                   269 
270 #gen_proto_variants(meta, name, ...)              270 #gen_proto_variants(meta, name, ...)
271 gen_proto_variants()                              271 gen_proto_variants()
272 {                                                 272 {
273         local meta="$1"; shift                    273         local meta="$1"; shift
274         local name="$1"; shift                    274         local name="$1"; shift
275         local pfx=""                              275         local pfx=""
276         local sfx=""                              276         local sfx=""
277                                                   277 
278         meta_in "${meta}" "fF" && pfx="fetch_"    278         meta_in "${meta}" "fF" && pfx="fetch_"
279         meta_in "${meta}" "R" && sfx="_return"    279         meta_in "${meta}" "R" && sfx="_return"
280                                                   280 
281         gen_proto_order_variants "${meta}" "${    281         gen_proto_order_variants "${meta}" "${pfx}" "${name}" "${sfx}" "$@"
282 }                                                 282 }
283                                                   283 
284 #gen_proto(meta, ...)                             284 #gen_proto(meta, ...)
285 gen_proto() {                                     285 gen_proto() {
286         local meta="$1"; shift                    286         local meta="$1"; shift
287         for m in $(echo "${meta}" | grep -o .)    287         for m in $(echo "${meta}" | grep -o .); do
288                 gen_proto_variants "${m}" "$@"    288                 gen_proto_variants "${m}" "$@"
289         done                                      289         done
290 }                                                 290 }
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php