Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/scripts/atomic/gen-rust-atomic-helpers.sh
29266 views
1
#!/bin/sh
2
# SPDX-License-Identifier: GPL-2.0
3
4
ATOMICDIR=$(dirname $0)
5
6
. ${ATOMICDIR}/atomic-tbl.sh
7
8
#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, arg...)
9
gen_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
26
cat <<EOF
27
__rust_helper ${ret}
28
rust_helper_${atomicname}(${params})
29
{
30
${retstmt}${atomicname}(${args});
31
}
32
33
EOF
34
}
35
36
cat << 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
55
EOF
56
57
grep '^[a-z]' "$1" | while read name meta args; do
58
gen_proto "${meta}" "${name}" "atomic" "int" ${args}
59
done
60
61
grep '^[a-z]' "$1" | while read name meta args; do
62
gen_proto "${meta}" "${name}" "atomic64" "s64" ${args}
63
done
64
65
cat <<EOF
66
#endif /* _RUST_ATOMIC_API_H */
67
EOF
68
69