Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: Add __rust_helper to helpers

This is needed to inline these helpers into Rust code.

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20260105-define-rust-helper-v2-20-51da5f454a67@google.com

authored by

Alice Ryhl and committed by
Boqun Feng
d4ad4de9 9ba1aaf2

+16 -14
+7 -6
rust/helpers/mutex.c
··· 2 2 3 3 #include <linux/mutex.h> 4 4 5 - void rust_helper_mutex_lock(struct mutex *lock) 5 + __rust_helper void rust_helper_mutex_lock(struct mutex *lock) 6 6 { 7 7 mutex_lock(lock); 8 8 } 9 9 10 - int rust_helper_mutex_trylock(struct mutex *lock) 10 + __rust_helper int rust_helper_mutex_trylock(struct mutex *lock) 11 11 { 12 12 return mutex_trylock(lock); 13 13 } 14 14 15 - void rust_helper___mutex_init(struct mutex *mutex, const char *name, 16 - struct lock_class_key *key) 15 + __rust_helper void rust_helper___mutex_init(struct mutex *mutex, 16 + const char *name, 17 + struct lock_class_key *key) 17 18 { 18 19 __mutex_init(mutex, name, key); 19 20 } 20 21 21 - void rust_helper_mutex_assert_is_held(struct mutex *mutex) 22 + __rust_helper void rust_helper_mutex_assert_is_held(struct mutex *mutex) 22 23 { 23 24 lockdep_assert_held(mutex); 24 25 } 25 26 26 - void rust_helper_mutex_destroy(struct mutex *lock) 27 + __rust_helper void rust_helper_mutex_destroy(struct mutex *lock) 27 28 { 28 29 mutex_destroy(lock); 29 30 }
+7 -6
rust/helpers/spinlock.c
··· 2 2 3 3 #include <linux/spinlock.h> 4 4 5 - void rust_helper___spin_lock_init(spinlock_t *lock, const char *name, 6 - struct lock_class_key *key) 5 + __rust_helper void rust_helper___spin_lock_init(spinlock_t *lock, 6 + const char *name, 7 + struct lock_class_key *key) 7 8 { 8 9 #ifdef CONFIG_DEBUG_SPINLOCK 9 10 # if defined(CONFIG_PREEMPT_RT) ··· 17 16 #endif /* CONFIG_DEBUG_SPINLOCK */ 18 17 } 19 18 20 - void rust_helper_spin_lock(spinlock_t *lock) 19 + __rust_helper void rust_helper_spin_lock(spinlock_t *lock) 21 20 { 22 21 spin_lock(lock); 23 22 } 24 23 25 - void rust_helper_spin_unlock(spinlock_t *lock) 24 + __rust_helper void rust_helper_spin_unlock(spinlock_t *lock) 26 25 { 27 26 spin_unlock(lock); 28 27 } 29 28 30 - int rust_helper_spin_trylock(spinlock_t *lock) 29 + __rust_helper int rust_helper_spin_trylock(spinlock_t *lock) 31 30 { 32 31 return spin_trylock(lock); 33 32 } 34 33 35 - void rust_helper_spin_assert_is_held(spinlock_t *lock) 34 + __rust_helper void rust_helper_spin_assert_is_held(spinlock_t *lock) 36 35 { 37 36 lockdep_assert_held(lock); 38 37 }
+2 -2
rust/helpers/sync.c
··· 2 2 3 3 #include <linux/lockdep.h> 4 4 5 - void rust_helper_lockdep_register_key(struct lock_class_key *k) 5 + __rust_helper void rust_helper_lockdep_register_key(struct lock_class_key *k) 6 6 { 7 7 lockdep_register_key(k); 8 8 } 9 9 10 - void rust_helper_lockdep_unregister_key(struct lock_class_key *k) 10 + __rust_helper void rust_helper_lockdep_unregister_key(struct lock_class_key *k) 11 11 { 12 12 lockdep_unregister_key(k); 13 13 }