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