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)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 8) #gen_cast(arg, int, atomic)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 9) gen_cast()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 10) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 11) local arg="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 12) local int="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 13) local atomic="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 14)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 15) [ "${arg%%:*}" = "p" ] || return
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 16)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 17) printf "($(gen_param_type "${arg}" "${int}" "${atomic}"))"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 18) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 19)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 20) #gen_args_cast(int, atomic, arg...)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 21) gen_args_cast()
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 22) {
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 23) local int="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 24) local atomic="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 25)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 26) while [ "$#" -gt 0 ]; do
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 27) local cast="$(gen_cast "$1" "${int}" "${atomic}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 28) local arg="$(gen_param_name "$1")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 29) printf "${cast}${arg}"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 30) [ "$#" -gt 1 ] && printf ", "
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 31) shift;
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 32) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 33) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 34)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 35) #gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 36) gen_proto_order_variant()
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 name="$1$2$3$4"; shift; shift; shift; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 40) local atomic="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 41) local int="$1"; shift
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 42)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 43) local ret="$(gen_ret_type "${meta}" "long")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 44) local params="$(gen_params "long" "atomic_long" "$@")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 45) local argscast="$(gen_args_cast "${int}" "${atomic}" "$@")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 46) local retstmt="$(gen_ret_stmt "${meta}")"
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 47)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 48) cat <<EOF
c020395b6634b (Marco Elver 2019-11-26 15:04:04 +0100 49) static __always_inline ${ret}
67d1b0de258ad (Mark Rutland 2021-07-13 11:52:52 +0100 50) arch_atomic_long_${name}(${params})
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 51) {
67d1b0de258ad (Mark Rutland 2021-07-13 11:52:52 +0100 52) ${retstmt}arch_${atomic}_${name}(${argscast});
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 53) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 54)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 55) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 56) }
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 57)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 58) cat << EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 59) // SPDX-License-Identifier: GPL-2.0
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 60)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 61) // Generated by $0
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 62) // DO NOT MODIFY THIS FILE DIRECTLY
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 63)
e3d18cee258b8 (Mark Rutland 2021-07-13 11:52:51 +0100 64) #ifndef _LINUX_ATOMIC_LONG_H
e3d18cee258b8 (Mark Rutland 2021-07-13 11:52:51 +0100 65) #define _LINUX_ATOMIC_LONG_H
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 66)
c020395b6634b (Marco Elver 2019-11-26 15:04:04 +0100 67) #include <linux/compiler.h>
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 68) #include <asm/types.h>
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 69)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 70) #ifdef CONFIG_64BIT
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 71) typedef atomic64_t atomic_long_t;
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 72) #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 73) #define atomic_long_cond_read_acquire atomic64_cond_read_acquire
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 74) #define atomic_long_cond_read_relaxed atomic64_cond_read_relaxed
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 75) #else
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 76) typedef atomic_t atomic_long_t;
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 77) #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 78) #define atomic_long_cond_read_acquire atomic_cond_read_acquire
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 79) #define atomic_long_cond_read_relaxed atomic_cond_read_relaxed
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 80) #endif
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 81)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 82) #ifdef CONFIG_64BIT
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 83)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 84) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 85)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 86) grep '^[a-z]' "$1" | while read name meta args; do
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 87) gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 88) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 89)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 90) cat <<EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 91) #else /* CONFIG_64BIT */
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 92)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 93) EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 94)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 95) grep '^[a-z]' "$1" | while read name meta args; do
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 96) gen_proto "${meta}" "${name}" "atomic" "int" ${args}
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 97) done
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 98)
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 99) cat <<EOF
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 100) #endif /* CONFIG_64BIT */
e3d18cee258b8 (Mark Rutland 2021-07-13 11:52:51 +0100 101) #endif /* _LINUX_ATOMIC_LONG_H */
ace9bad4df268 (Mark Rutland 2018-09-04 11:48:25 +0100 102) EOF