File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 20
20
21
21
#include <linux/bug.h>
22
22
#include <linux/build_bug.h>
23
+ #include <linux/err.h>
23
24
#include <linux/refcount.h>
24
25
25
26
__noreturn void rust_helper_BUG (void )
@@ -46,6 +47,12 @@ bool rust_helper_refcount_dec_and_test(refcount_t *r)
46
47
}
47
48
EXPORT_SYMBOL_GPL (rust_helper_refcount_dec_and_test );
48
49
50
+ __force void * rust_helper_ERR_PTR (long err )
51
+ {
52
+ return ERR_PTR (err );
53
+ }
54
+ EXPORT_SYMBOL_GPL (rust_helper_ERR_PTR );
55
+
49
56
/*
50
57
* We use `bindgen`'s `--size_t-is-usize` option to bind the C `size_t` type
51
58
* as the Rust `usize` type, so we can use it in contexts where Rust
Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ impl Error {
76
76
pub fn to_errno ( self ) -> core:: ffi:: c_int {
77
77
self . 0
78
78
}
79
+
80
+ /// Returns the error encoded as a pointer.
81
+ #[ allow( dead_code) ]
82
+ pub ( crate ) fn to_ptr < T > ( self ) -> * mut T {
83
+ // SAFETY: self.0 is a valid error due to its invariant.
84
+ unsafe { bindings:: ERR_PTR ( self . 0 . into ( ) ) as * mut _ }
85
+ }
79
86
}
80
87
81
88
impl From < AllocError > for Error {
You can’t perform that action at this time.
0 commit comments