mirror of
https://github.com/torvalds/linux.git
synced 2026-11-28 01:13:11 +00:00
rust: kernel: Mark rust_fmt_argument as extern "C"
The rust_fmt_argument function is called from printk() to handle the %pA
format specifier.
Since it's called from C, we should mark it extern "C" to make sure it's
ABI compatible.
Cc: [email protected]
Fixes: 247b365dc8 ("rust: add `kernel` crate")
Signed-off-by: David Gow <[email protected]>
Reviewed-by: Gary Guo <[email protected]>
Reviewed-by: Björn Roy Baron <[email protected]>
Reviewed-by: Vincenzo Palazzo <[email protected]>
[Applied `rustfmt`]
Signed-off-by: Miguel Ojeda <[email protected]>
This commit is contained in:
@@ -18,7 +18,11 @@ use crate::bindings;
|
||||
|
||||
// Called from `vsprintf` with format specifier `%pA`.
|
||||
#[no_mangle]
|
||||
unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
|
||||
unsafe extern "C" fn rust_fmt_argument(
|
||||
buf: *mut c_char,
|
||||
end: *mut c_char,
|
||||
ptr: *const c_void,
|
||||
) -> *mut c_char {
|
||||
use fmt::Write;
|
||||
// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
|
||||
let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
|
||||
|
||||
Reference in New Issue
Block a user