1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3 4ATOMICDIR=$(dirname $0) 5 6. ${ATOMICDIR}/atomic-tbl.sh 7 8#gen_cast(arg, int, atomic) 9gen_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...) 21gen_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, arg...) 36gen_proto_order_variant() 37{ 38 local meta="$1"; shift 39 local pfx="$1"; shift 40 local name="$1"; shift 41 local sfx="$1"; shift 42 local order="$1"; shift 43 44 local atomicname="${pfx}${name}${sfx}${order}" 45 46 local ret="$(gen_ret_type "${meta}" "long")" 47 local params="$(gen_params "long" "atomic_long" "$@")" 48 local argscast_32="$(gen_args_cast "int" "atomic" "$@")" 49 local argscast_64="$(gen_args_cast "s64" "atomic64" "$@")" 50 local retstmt="$(gen_ret_stmt "${meta}")" 51 52cat <<EOF 53static __always_inline ${ret} 54raw_atomic_long_${atomicname}(${params}) 55{ 56#ifdef CONFIG_64BIT 57 ${retstmt}raw_atomic64_${atomicname}(${argscast_64}); 58#else 59 ${retstmt}raw_atomic_${atomicname}(${argscast_32}); 60#endif 61} 62 63EOF 64} 65 66cat << EOF 67// SPDX-License-Identifier: GPL-2.0 68 69// Generated by $0 70// DO NOT MODIFY THIS FILE DIRECTLY 71 72#ifndef _LINUX_ATOMIC_LONG_H 73#define _LINUX_ATOMIC_LONG_H 74 75#include <linux/compiler.h> 76#include <asm/types.h> 77 78#ifdef CONFIG_64BIT 79typedef atomic64_t atomic_long_t; 80#define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i) 81#define atomic_long_cond_read_acquire atomic64_cond_read_acquire 82#define atomic_long_cond_read_relaxed atomic64_cond_read_relaxed 83#else 84typedef atomic_t atomic_long_t; 85#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) 86#define atomic_long_cond_read_acquire atomic_cond_read_acquire 87#define atomic_long_cond_read_relaxed atomic_cond_read_relaxed 88#endif 89 90EOF 91 92grep '^[a-z]' "$1" | while read name meta args; do 93 gen_proto "${meta}" "${name}" ${args} 94done 95 96cat <<EOF 97#endif /* _LINUX_ATOMIC_LONG_H */ 98EOF 99