File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 8
8
#include <linux/highmem.h>
9
9
#include <linux/uio.h>
10
10
#include <linux/errname.h>
11
+ #include <linux/mutex.h>
11
12
12
13
void rust_helper_BUG (void )
13
14
{
@@ -123,6 +124,12 @@ const char *rust_helper_errname(int err)
123
124
return errname (err );
124
125
}
125
126
127
+ void rust_helper_mutex_lock (struct mutex * lock )
128
+ {
129
+ mutex_lock (lock );
130
+ }
131
+ EXPORT_SYMBOL_GPL (rust_helper_mutex_lock );
132
+
126
133
/* We use bindgen's --size_t-is-usize option to bind the C size_t type
127
134
* as the Rust usize type, so we can use it in contexts where Rust
128
135
* expects a usize like slice (array) indices. usize is defined to be
Original file line number Diff line number Diff line change @@ -77,19 +77,18 @@ impl<T: ?Sized> NeedsLockClass for Mutex<T> {
77
77
}
78
78
}
79
79
80
+ extern "C" {
81
+ fn rust_helper_mutex_lock ( mutex : * mut bindings:: mutex ) ;
82
+ }
83
+
80
84
impl < T : ?Sized > Lock for Mutex < T > {
81
85
type Inner = T ;
82
86
83
- #[ cfg( not( CONFIG_DEBUG_LOCK_ALLOC ) ) ]
84
87
fn lock_noguard ( & self ) {
85
88
// SAFETY: `mutex` points to valid memory.
86
- unsafe { bindings:: mutex_lock ( self . mutex . get ( ) ) } ;
87
- }
88
-
89
- #[ cfg( CONFIG_DEBUG_LOCK_ALLOC ) ]
90
- fn lock_noguard ( & self ) {
91
- // SAFETY: `mutex` points to valid memory.
92
- unsafe { bindings:: mutex_lock_nested ( self . mutex . get ( ) , 0 ) } ;
89
+ unsafe {
90
+ rust_helper_mutex_lock ( self . mutex . get ( ) ) ;
91
+ }
93
92
}
94
93
95
94
unsafe fn unlock ( & self ) {
You can’t perform that action at this time.
0 commit comments