mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-30 00:06:59 +02:00 
			
		
		
		
	 fdd7c7e0d2
			
		
	
	
		fdd7c7e0d2
		
	
	
	
	
		
			
			In order to support LKMM atomics in Rust, add rust_helper_* for atomic APIs. These helpers ensure the implementation of LKMM atomics in Rust is the same as in C. This could save the maintenance burden of having two similar atomic implementations in asm. Originally-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/all/20250719030827.61357-2-boqun.feng@gmail.com/
		
			
				
	
	
		
			67 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/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>
 | |
| 
 | |
| // TODO: Remove this after INLINE_HELPERS support is added.
 | |
| #ifndef __rust_helper
 | |
| #define __rust_helper
 | |
| #endif
 | |
| 
 | |
| 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
 |