Path: blob/master/scripts/atomic/gen-rust-atomic-helpers.sh
29266 views
#!/bin/sh1# SPDX-License-Identifier: GPL-2.023ATOMICDIR=$(dirname $0)45. ${ATOMICDIR}/atomic-tbl.sh67#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)8gen_proto_order_variant()9{10local meta="$1"; shift11local pfx="$1"; shift12local name="$1"; shift13local sfx="$1"; shift14local order="$1"; shift15local atomic="$1"; shift16local int="$1"; shift1718local atomicname="${atomic}_${pfx}${name}${sfx}${order}"1920local ret="$(gen_ret_type "${meta}" "${int}")"21local params="$(gen_params "${int}" "${atomic}" "$@")"22local args="$(gen_args "$@")"23local retstmt="$(gen_ret_stmt "${meta}")"2425cat <<EOF26__rust_helper ${ret}27rust_helper_${atomicname}(${params})28{29${retstmt}${atomicname}(${args});30}3132EOF33}3435cat << EOF36// SPDX-License-Identifier: GPL-2.03738// Generated by $039// DO NOT MODIFY THIS FILE DIRECTLY4041/*42* This file provides helpers for the various atomic functions for Rust.43*/44#ifndef _RUST_ATOMIC_API_H45#define _RUST_ATOMIC_API_H4647#include <linux/atomic.h>4849// TODO: Remove this after INLINE_HELPERS support is added.50#ifndef __rust_helper51#define __rust_helper52#endif5354EOF5556grep '^[a-z]' "$1" | while read name meta args; do57gen_proto "${meta}" "${name}" "atomic" "int" ${args}58done5960grep '^[a-z]' "$1" | while read name meta args; do61gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}62done6364cat <<EOF65#endif /* _RUST_ATOMIC_API_H */66EOF676869