1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3 4ATOMICDIR=$(dirname $0) 5 6. ${ATOMICDIR}/atomic-tbl.sh 7 8#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...) 9gen_proto_order_variant() 10{ 11 local meta="$1"; shift 12 local pfx="$1"; shift 13 local name="$1"; shift 14 local sfx="$1"; shift 15 local order="$1"; shift 16 local atomic="$1"; shift 17 local int="$1"; shift 18 19 local atomicname="${atomic}_${pfx}${name}${sfx}${order}" 20 21 local ret="$(gen_ret_type "${meta}" "${int}")" 22 local params="$(gen_params "${int}" "${atomic}" "$@")" 23 local args="$(gen_args "$@")" 24 local retstmt="$(gen_ret_stmt "${meta}")" 25 26cat <<EOF 27__rust_helper ${ret} 28rust_helper_${atomicname}(${params}) 29{ 30 ${retstmt}${atomicname}(${args}); 31} 32 33EOF 34} 35 36cat << EOF 37// SPDX-License-Identifier: GPL-2.0 38 39// Generated by $0 40// DO NOT MODIFY THIS FILE DIRECTLY 41 42/* 43 * This file provides helpers for the various atomic functions for Rust. 44 */ 45#ifndef _RUST_ATOMIC_API_H 46#define _RUST_ATOMIC_API_H 47 48#include <linux/atomic.h> 49 50// TODO: Remove this after INLINE_HELPERS support is added. 51#ifndef __rust_helper 52#define __rust_helper 53#endif 54 55EOF 56 57grep '^[a-z]' "$1" | while read name meta args; do 58 gen_proto "${meta}" "${name}" "atomic" "int" ${args} 59done 60 61grep '^[a-z]' "$1" | while read name meta args; do 62 gen_proto "${meta}" "${name}" "atomic64" "s64" ${args} 63done 64 65cat <<EOF 66#endif /* _RUST_ATOMIC_API_H */ 67EOF 68