ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 1) #!/bin/sh
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 2) # SPDX-License-Identifier: GPL-2.0
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 3)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 4) ATOMICDIR=$(dirname $0)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 5)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 6) . ${ATOMICDIR}/atomic-tbl.sh
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 7)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 8) #gen_template_fallback(template, meta, pfx, name, sfx, order, atomic, int, args...)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 9) gen_template_fallback()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 10) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 11) local template="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 12) local meta="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 13) local pfx="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 14) local name="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 15) local sfx="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 16) local order="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 17) local atomic="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 18) local int="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 19)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 20) local atomicname="arch_${atomic}_${pfx}${name}${sfx}${order}"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 21)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 22) local ret="$(gen_ret_type "${meta}" "${int}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 23) local retstmt="$(gen_ret_stmt "${meta}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 24) local params="$(gen_params "${int}" "${atomic}" "$@")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 25) local args="$(gen_args "$@")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 26)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 27) if [ ! -z "${template}" ]; then
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 28) printf "#ifndef ${atomicname}\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 29) . ${template}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 30) printf "#define ${atomicname} ${atomicname}\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 31) printf "#endif\n\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 32) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 33) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 34)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 35) #gen_proto_fallback(meta, pfx, name, sfx, order, atomic, int, args...)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 36) gen_proto_fallback()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 37) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 38) local meta="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 39) local pfx="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 40) local name="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 41) local sfx="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 42) local order="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 43)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 44) local tmpl="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 45) gen_template_fallback "${tmpl}" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 46) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 47)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 48) #gen_basic_fallbacks(basename)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 49) gen_basic_fallbacks()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 50) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 51) local basename="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 52) cat << EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 53) #define ${basename}_acquire ${basename}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 54) #define ${basename}_release ${basename}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 55) #define ${basename}_relaxed ${basename}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 56) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 57) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 58)
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 59) gen_proto_order_variant()
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 60) {
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 61) local meta="$1"; shift
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 62) local pfx="$1"; shift
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 63) local name="$1"; shift
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 64) local sfx="$1"; shift
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 65) local order="$1"; shift
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 66) local atomic="$1"
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 67)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 68) local basename="arch_${atomic}_${pfx}${name}${sfx}"
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 69)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 70) printf "#define ${basename}${order} ${basename}${order}\n"
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 71) }
5faafd5685764 (Peter Zijlstra 2020-06-25 15:55:14 +0200 72)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 73) #gen_proto_order_variants(meta, pfx, name, sfx, atomic, int, args...)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 74) gen_proto_order_variants()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 75) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 76) local meta="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 77) local pfx="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 78) local name="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 79) local sfx="$1"; shift
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 80) local atomic="$1"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 81)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 82) local basename="arch_${atomic}_${pfx}${name}${sfx}"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 83)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 84) local template="$(find_fallback_template "${pfx}" "${name}" "${sfx}" "${order}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 85)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 86) # If we don't have relaxed atomics, then we don't bother with ordering fallbacks
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 87) # read_acquire and set_release need to be templated, though
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 88) if ! meta_has_relaxed "${meta}"; then
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 89) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 90)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 91) if meta_has_acquire "${meta}"; then
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 92) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 93) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 94)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 95) if meta_has_release "${meta}"; then
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 96) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 97) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 98)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 99) return
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 100) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 101)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 102) printf "#ifndef ${basename}_relaxed\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 103)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 104) if [ ! -z "${template}" ]; then
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 105) printf "#ifdef ${basename}\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 106) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 107)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 108) gen_basic_fallbacks "${basename}"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 109)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 110) if [ ! -z "${template}" ]; then
47401d94947d5 (Mark Rutland 2021-07-13 11:52:49 +0100 111) printf "#endif /* ${basename} */\n\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 112) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 113) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 114) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 115) gen_proto_fallback "${meta}" "${pfx}" "${name}" "${sfx}" "_relaxed" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 116) fi
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 117)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 118) printf "#else /* ${basename}_relaxed */\n\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 119)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 120) gen_template_fallback "${ATOMICDIR}/fallbacks/acquire" "${meta}" "${pfx}" "${name}" "${sfx}" "_acquire" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 121) gen_template_fallback "${ATOMICDIR}/fallbacks/release" "${meta}" "${pfx}" "${name}" "${sfx}" "_release" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 122) gen_template_fallback "${ATOMICDIR}/fallbacks/fence" "${meta}" "${pfx}" "${name}" "${sfx}" "" "$@"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 123)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 124) printf "#endif /* ${basename}_relaxed */\n\n"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 125) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 126)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 127) gen_order_fallbacks()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 128) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 129) local xchg="$1"; shift
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 130)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 131) cat <<EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 132)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 133) #ifndef ${xchg}_acquire
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 134) #define ${xchg}_acquire(...) \\
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 135) __atomic_op_acquire(${xchg}, __VA_ARGS__)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 136) #endif
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 137)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 138) #ifndef ${xchg}_release
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 139) #define ${xchg}_release(...) \\
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 140) __atomic_op_release(${xchg}, __VA_ARGS__)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 141) #endif
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 142)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 143) #ifndef ${xchg}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 144) #define ${xchg}(...) \\
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 145) __atomic_op_fence(${xchg}, __VA_ARGS__)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 146) #endif
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 147)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 148) EOF
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 149) }
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 150)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 151) gen_xchg_fallbacks()
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 152) {
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 153) local xchg="$1"; shift
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 154) printf "#ifndef ${xchg}_relaxed\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 155)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 156) gen_basic_fallbacks ${xchg}
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 157)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 158) printf "#else /* ${xchg}_relaxed */\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 159)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 160) gen_order_fallbacks ${xchg}
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 161)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 162) printf "#endif /* ${xchg}_relaxed */\n\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 163) }
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 164)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 165) gen_try_cmpxchg_fallback()
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 166) {
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 167) local order="$1"; shift;
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 168)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 169) cat <<EOF
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 170) #ifndef arch_try_cmpxchg${order}
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 171) #define arch_try_cmpxchg${order}(_ptr, _oldp, _new) \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 172) ({ \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 173) typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \\
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 174) ___r = arch_cmpxchg${order}((_ptr), ___o, (_new)); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 175) if (unlikely(___r != ___o)) \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 176) *___op = ___r; \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 177) likely(___r == ___o); \\
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 178) })
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 179) #endif /* arch_try_cmpxchg${order} */
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 180)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 181) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 182) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 183)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 184) gen_try_cmpxchg_fallbacks()
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 185) {
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 186) printf "#ifndef arch_try_cmpxchg_relaxed\n"
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 187) printf "#ifdef arch_try_cmpxchg\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 188)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 189) gen_basic_fallbacks "arch_try_cmpxchg"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 190)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 191) printf "#endif /* arch_try_cmpxchg */\n\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 192)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 193) for order in "" "_acquire" "_release" "_relaxed"; do
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 194) gen_try_cmpxchg_fallback "${order}"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 195) done
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 196)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 197) printf "#else /* arch_try_cmpxchg_relaxed */\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 198)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 199) gen_order_fallbacks "arch_try_cmpxchg"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 200)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 201) printf "#endif /* arch_try_cmpxchg_relaxed */\n\n"
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 202) }
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 203)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 204) cat << EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 205) // SPDX-License-Identifier: GPL-2.0
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 206)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 207) // Generated by $0
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 208) // DO NOT MODIFY THIS FILE DIRECTLY
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 209)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 210) #ifndef _LINUX_ATOMIC_FALLBACK_H
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 211) #define _LINUX_ATOMIC_FALLBACK_H
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 212)
765dcd209947e (Marco Elver 2019-11-26 15:04:05 +0100 213) #include <linux/compiler.h>
765dcd209947e (Marco Elver 2019-11-26 15:04:05 +0100 214)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 215) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 216)
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 217) for xchg in "arch_xchg" "arch_cmpxchg" "arch_cmpxchg64"; do
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 218) gen_xchg_fallbacks "${xchg}"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 219) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 220)
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 221) gen_try_cmpxchg_fallbacks
29f006fdefe6f (Peter Zijlstra 2020-08-29 22:03:35 +0900 222)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 223) grep '^[a-z]' "$1" | while read name meta args; do
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 224) gen_proto "${meta}" "${name}" "atomic" "int" ${args}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 225) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 226)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 227) cat <<EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 228) #ifdef CONFIG_GENERIC_ATOMIC64
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 229) #include <asm-generic/atomic64.h>
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 230) #endif
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 231)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 232) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 233)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 234) grep '^[a-z]' "$1" | while read name meta args; do
f3e615b4db1fb (Mark Rutland 2021-07-13 11:52:50 +0100 235) gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 236) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 237)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 238) cat <<EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 239) #endif /* _LINUX_ATOMIC_FALLBACK_H */
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 240) EOF