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