Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 ATOMICDIR=$(dirname $0)
0005 
0006 . ${ATOMICDIR}/atomic-tbl.sh
0007 
0008 #gen_cast(arg, int, atomic)
0009 gen_cast()
0010 {
0011         local arg="$1"; shift
0012         local int="$1"; shift
0013         local atomic="$1"; shift
0014 
0015         [ "${arg%%:*}" = "p" ] || return
0016 
0017         printf "($(gen_param_type "${arg}" "${int}" "${atomic}"))"
0018 }
0019 
0020 #gen_args_cast(int, atomic, arg...)
0021 gen_args_cast()
0022 {
0023         local int="$1"; shift
0024         local atomic="$1"; shift
0025 
0026         while [ "$#" -gt 0 ]; do
0027                 local cast="$(gen_cast "$1" "${int}" "${atomic}")"
0028                 local arg="$(gen_param_name "$1")"
0029                 printf "${cast}${arg}"
0030                 [ "$#" -gt 1 ] && printf ", "
0031                 shift;
0032         done
0033 }
0034 
0035 #gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)
0036 gen_proto_order_variant()
0037 {
0038         local meta="$1"; shift
0039         local name="$1$2$3$4"; shift; shift; shift; shift
0040         local atomic="$1"; shift
0041         local int="$1"; shift
0042 
0043         local ret="$(gen_ret_type "${meta}" "long")"
0044         local params="$(gen_params "long" "atomic_long" "$@")"
0045         local argscast="$(gen_args_cast "${int}" "${atomic}" "$@")"
0046         local retstmt="$(gen_ret_stmt "${meta}")"
0047 
0048 cat <<EOF
0049 static __always_inline ${ret}
0050 arch_atomic_long_${name}(${params})
0051 {
0052         ${retstmt}arch_${atomic}_${name}(${argscast});
0053 }
0054 
0055 EOF
0056 }
0057 
0058 cat << EOF
0059 // SPDX-License-Identifier: GPL-2.0
0060 
0061 // Generated by $0
0062 // DO NOT MODIFY THIS FILE DIRECTLY
0063 
0064 #ifndef _LINUX_ATOMIC_LONG_H
0065 #define _LINUX_ATOMIC_LONG_H
0066 
0067 #include <linux/compiler.h>
0068 #include <asm/types.h>
0069 
0070 #ifdef CONFIG_64BIT
0071 typedef atomic64_t atomic_long_t;
0072 #define ATOMIC_LONG_INIT(i)             ATOMIC64_INIT(i)
0073 #define atomic_long_cond_read_acquire   atomic64_cond_read_acquire
0074 #define atomic_long_cond_read_relaxed   atomic64_cond_read_relaxed
0075 #else
0076 typedef atomic_t atomic_long_t;
0077 #define ATOMIC_LONG_INIT(i)             ATOMIC_INIT(i)
0078 #define atomic_long_cond_read_acquire   atomic_cond_read_acquire
0079 #define atomic_long_cond_read_relaxed   atomic_cond_read_relaxed
0080 #endif
0081 
0082 #ifdef CONFIG_64BIT
0083 
0084 EOF
0085 
0086 grep '^[a-z]' "$1" | while read name meta args; do
0087         gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
0088 done
0089 
0090 cat <<EOF
0091 #else /* CONFIG_64BIT */
0092 
0093 EOF
0094 
0095 grep '^[a-z]' "$1" | while read name meta args; do
0096         gen_proto "${meta}" "${name}" "atomic" "int" ${args}
0097 done
0098 
0099 cat <<EOF
0100 #endif /* CONFIG_64BIT */
0101 #endif /* _LINUX_ATOMIC_LONG_H */
0102 EOF