#!/bin/sh # SPDX-License-Identifier: GPL-2.0 ATOMICDIR=$(dirname $0) . ${ATOMICDIR}/atomic-tbl.sh #gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...) gen_proto_order_variant() { local meta="$1"; shift local pfx="$1"; shift local name="$1"; shift local sfx="$1"; shift local order="$1"; shift local atomic="$1"; shift local int="$1"; shift local atomicname="${atomic}_${pfx}${name}${sfx}${order}" local ret="$(gen_ret_type "${meta}" "${int}")" local params="$(gen_params "${int}" "${atomic}" "$@")" local args="$(gen_args "$@")" local retstmt="$(gen_ret_stmt "${meta}")" cat <<EOF __rust_helper ${ret} rust_helper_${atomicname}(${params}) { ${retstmt}${atomicname}(${args}); } EOF } cat << EOF // SPDX-License-Identifier: GPL-2.0 // Generated by $0 // DO NOT MODIFY THIS FILE DIRECTLY /* * This file provides helpers for the various atomic functions for Rust. */ #ifndef _RUST_ATOMIC_API_H #define _RUST_ATOMIC_API_H #include <linux/atomic.h> EOF grep '^[a-z]' "$1" | while read name meta args; do gen_proto "${meta}" "${name}" "atomic" "int" ${args} done grep '^[a-z]' "$1" | while read name meta args; do gen_proto "${meta}" "${name}" "atomic64" "s64" ${args} done cat <<EOF #endif /* _RUST_ATOMIC_API_H */ EOF |