* [PATCH v1 2/3] RustPkg/Test/TestRustLangLib: Fix Building
2022-03-19 7:05 [PATCH v1 0/3]: Fix RustPkg/Tests in edkii-rust branch edk2-staging ayushdevel1325
2022-03-19 7:05 ` [PATCH v1 1/3] RustPkg/Test: Replace cargo-xbuild with build-std Ayush Singh
@ 2022-03-19 7:05 ` Ayush Singh
2022-03-19 7:05 ` [PATCH v1 3/3] RustPkg/Test/TestRustLangApp: Fix building Ayush Singh
2022-03-19 8:40 ` [edk2-devel] [PATCH v1 0/3]: Fix RustPkg/Tests in edkii-rust branch edk2-staging Marvin Häuser
3 siblings, 0 replies; 10+ messages in thread
From: Ayush Singh @ 2022-03-19 7:05 UTC (permalink / raw)
To: devel; +Cc: Jiewen Yao
From: Ayush Singh <ayushsingh1325@gmail.com>
Removed the Alloc trait usage which seems to have been removed from
Rust now.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
---
RustPkg/Library/UefiRustAllocationLib/src/lib.rs | 53 ++--
RustPkg/Test/TestRustLangLib/.cargo/config.toml | 3 +
RustPkg/Test/TestRustLangLib/src/lib.rs | 264 ++++++++------------
3 files changed, 137 insertions(+), 183 deletions(-)
diff --git a/RustPkg/Library/UefiRustAllocationLib/src/lib.rs b/RustPkg/Library/UefiRustAllocationLib/src/lib.rs
index f369e1bb170b..6a65f0a5f988 100644
--- a/RustPkg/Library/UefiRustAllocationLib/src/lib.rs
+++ b/RustPkg/Library/UefiRustAllocationLib/src/lib.rs
@@ -15,44 +15,42 @@
#![feature(alloc_layout_extra)]
#![feature(allocator_api)]
#![feature(alloc_error_handler)]
-
#![cfg_attr(not(test), no_std)]
-
#![allow(unused)]
extern crate uefi_rust_panic_lib;
-use core::alloc::{GlobalAlloc, Layout, Alloc};
-use r_efi::efi;
-use r_efi::efi::{Status};
+use core::alloc::{GlobalAlloc, Layout};
use core::ffi::c_void;
+use r_efi::efi;
+use r_efi::efi::Status;
pub struct MyAllocator;
-static mut ST : *mut efi::SystemTable = core::ptr::null_mut();
-static mut BS : *mut efi::BootServices = core::ptr::null_mut();
+static mut ST: *mut efi::SystemTable = core::ptr::null_mut();
+static mut BS: *mut efi::BootServices = core::ptr::null_mut();
unsafe impl GlobalAlloc for MyAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
- let size = layout.size();
- let align = layout.align();
- if align > 8 {
- return core::ptr::null_mut();
- }
+ let size = layout.size();
+ let align = layout.align();
+ if align > 8 {
+ return core::ptr::null_mut();
+ }
- let mut address : *mut c_void = core::ptr::null_mut();
- let status = ((*BS).allocate_pool) (
- efi::MemoryType::BootServicesData,
- size,
- &mut address as *mut *mut c_void
- );
- if status != Status::SUCCESS {
- return core::ptr::null_mut();
- }
- address as *mut u8
+ let mut address: *mut c_void = core::ptr::null_mut();
+ let status = ((*BS).allocate_pool)(
+ efi::MemoryType::BootServicesData,
+ size,
+ &mut address as *mut *mut c_void,
+ );
+ if status != Status::SUCCESS {
+ return core::ptr::null_mut();
+ }
+ address as *mut u8
}
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
- ((*BS).free_pool) (ptr as *mut c_void);
+ ((*BS).free_pool)(ptr as *mut c_void);
}
}
@@ -60,14 +58,13 @@ unsafe impl GlobalAlloc for MyAllocator {
static ALLOCATOR: MyAllocator = MyAllocator;
#[alloc_error_handler]
-fn alloc_error_handler(layout: core::alloc::Layout) -> !
-{
+fn alloc_error_handler(layout: core::alloc::Layout) -> ! {
loop {}
}
-pub extern fn init(system_table: *mut efi::SystemTable) {
+pub extern "C" fn init(system_table: *mut efi::SystemTable) {
unsafe {
- ST = system_table;
- BS = (*ST).boot_services;
+ ST = system_table;
+ BS = (*ST).boot_services;
}
}
diff --git a/RustPkg/Test/TestRustLangLib/.cargo/config.toml b/RustPkg/Test/TestRustLangLib/.cargo/config.toml
new file mode 100644
index 000000000000..422bf9d2ab4e
--- /dev/null
+++ b/RustPkg/Test/TestRustLangLib/.cargo/config.toml
@@ -0,0 +1,3 @@
+[unstable]
+build-std = ["core", "compiler_builtins", "alloc"]
+build-std-features = ["compiler-builtins-mem"]
diff --git a/RustPkg/Test/TestRustLangLib/src/lib.rs b/RustPkg/Test/TestRustLangLib/src/lib.rs
index ee3a0d7cc83e..888733232b71 100644
--- a/RustPkg/Test/TestRustLangLib/src/lib.rs
+++ b/RustPkg/Test/TestRustLangLib/src/lib.rs
@@ -14,24 +14,22 @@
#![feature(alloc_layout_extra)]
#![feature(allocator_api)]
-#![feature(core_panic_info)]
-
+#![feature(slice_ptr_get)]
#![cfg_attr(not(test), no_std)]
-
#![allow(unused)]
mod mem;
use r_efi::efi;
-use r_efi::efi::{Status};
+use r_efi::efi::Status;
-extern {
- fn AllocatePool (Size: usize) -> *mut c_void;
- fn FreePool (Buffer: *mut c_void);
+extern "C" {
+ fn AllocatePool(Size: usize) -> *mut c_void;
+ fn FreePool(Buffer: *mut c_void);
}
-use core::panic::PanicInfo;
use core::ffi::c_void;
+use core::panic::PanicInfo;
use core::mem::size_of;
use core::mem::transmute;
@@ -40,30 +38,22 @@ use core::slice;
use core::slice::from_raw_parts;
use core::slice::from_raw_parts_mut;
-extern crate uefi_rust_panic_lib;
extern crate uefi_rust_allocation_lib;
+extern crate uefi_rust_panic_lib;
extern crate alloc;
-use alloc::vec::Vec;
+use alloc::alloc::{handle_alloc_error, Allocator, Global, Layout};
use alloc::boxed::Box;
-use alloc::{
- alloc::{handle_alloc_error, Alloc, Global, Layout},
-};
-
+use alloc::vec::Vec;
#[no_mangle]
#[export_name = "TestIntegerOverflow"]
-pub extern fn test_integer_overflow (
- buffer_size: usize,
- width : u32,
- height : u32,
- ) -> Status
-{
+pub extern "C" fn test_integer_overflow(buffer_size: usize, width: u32, height: u32) -> Status {
let data_size = width * height * 4;
if data_size as usize > buffer_size {
- return Status::UNSUPPORTED;
+ return Status::UNSUPPORTED;
}
Status::SUCCESS
@@ -71,26 +61,24 @@ pub extern fn test_integer_overflow (
#[no_mangle]
#[export_name = "TestIntegerCheckedOverflow"]
-pub extern fn test_integer_checked_overflow (
+pub extern "C" fn test_integer_checked_overflow(
buffer_size: usize,
- width : u32,
- height : u32,
- ) -> Status
-{
-
+ width: u32,
+ height: u32,
+) -> Status {
let mut data_size: u32 = 0;
match width.checked_mul(height) {
- Some(size) => {data_size = size},
- None => {return Status::INVALID_PARAMETER},
+ Some(size) => data_size = size,
+ None => return Status::INVALID_PARAMETER,
}
match data_size.checked_mul(4) {
- Some(size) => {data_size = size},
- None => {return Status::INVALID_PARAMETER},
+ Some(size) => data_size = size,
+ None => return Status::INVALID_PARAMETER,
}
if data_size as usize > buffer_size {
- return Status::UNSUPPORTED;
+ return Status::UNSUPPORTED;
}
Status::SUCCESS
@@ -98,31 +86,27 @@ pub extern fn test_integer_checked_overflow (
#[no_mangle]
#[export_name = "TestIntegerCast"]
-pub extern fn test_integer_cast (
- buffer_size: u64,
- ) -> u32
-{
- let data_size : u32 = buffer_size as u32;
+pub extern "C" fn test_integer_cast(buffer_size: u64) -> u32 {
+ let data_size: u32 = buffer_size as u32;
data_size
}
-extern {
- fn ExternInit(Data: *mut usize);
+extern "C" {
+ fn ExternInit(Data: *mut usize);
}
#[no_mangle]
#[export_name = "TestUninitializedVariable"]
-pub extern fn test_uninitializd_variable (
- index: usize,
- ) -> usize
-{
- let mut data : usize = 1;
+pub extern "C" fn test_uninitializd_variable(index: usize) -> usize {
+ let mut data: usize = 1;
if index > 10 {
- data = 0;
+ data = 0;
}
- unsafe { ExternInit (&mut data ); }
+ unsafe {
+ ExternInit(&mut data);
+ }
data = data + 1;
@@ -131,11 +115,8 @@ pub extern fn test_uninitializd_variable (
#[no_mangle]
#[export_name = "TestArrayOutOfRange"]
-pub extern fn test_array_out_of_range (
- index: usize,
- ) -> usize
-{
- let mut data : [u8; 8] = [0; 8];
+pub extern "C" fn test_array_out_of_range(index: usize) -> usize {
+ let mut data: [u8; 8] = [0; 8];
data[index] = 1;
@@ -152,18 +133,21 @@ pub struct TestTable {
#[no_mangle]
#[export_name = "TestBufferOverflow"]
-pub extern fn test_buffer_overflow (
+pub extern "C" fn test_buffer_overflow(
buffer: &mut [u8; 0],
buffer_size: usize,
table: &TestTable,
table_size: usize,
- )
-{
- let mut dest = crate::mem::MemoryRegion::new(buffer as *mut [u8; 0] as usize as u64, buffer_size as u64);
- let mut source = crate::mem::MemoryRegion::new(&table.value as *const [u8; 0] as usize as u64, table_size as u64);
+) {
+ let mut dest =
+ crate::mem::MemoryRegion::new(buffer as *mut [u8; 0] as usize as u64, buffer_size as u64);
+ let mut source = crate::mem::MemoryRegion::new(
+ &table.value as *const [u8; 0] as usize as u64,
+ table_size as u64,
+ );
- for index in 0_u64 .. table.length as u64 {
- dest.write_u8(index, source.read_u8(index));
+ for index in 0_u64..table.length as u64 {
+ dest.write_u8(index, source.read_u8(index));
}
}
@@ -177,59 +161,49 @@ pub struct TestTableFixed {
#[no_mangle]
#[export_name = "TestBufferOverflowFixed"]
-pub extern fn test_buffer_overflow_fixed (
- buffer: &mut [u8; 32],
- table: &TestTableFixed,
- )
-{
- (*buffer)[0_usize..(table.length as usize)].copy_from_slice(
- &table.value[0_usize..(table.length as usize)]
- );
+pub extern "C" fn test_buffer_overflow_fixed(buffer: &mut [u8; 32], table: &TestTableFixed) {
+ (*buffer)[0_usize..(table.length as usize)]
+ .copy_from_slice(&table.value[0_usize..(table.length as usize)]);
}
-fn get_buffer<'a> () -> Option<&'a mut TestTableFixed>
-{
- let ptr : *mut c_void = unsafe { AllocatePool (size_of::<TestTableFixed>()) };
+fn get_buffer<'a>() -> Option<&'a mut TestTableFixed> {
+ let ptr: *mut c_void = unsafe { AllocatePool(size_of::<TestTableFixed>()) };
if ptr.is_null() {
- return None;
+ return None;
}
- let buffer : &mut TestTableFixed = unsafe { core::mem::transmute::<*mut c_void, &mut TestTableFixed>(ptr) };
+ let buffer: &mut TestTableFixed =
+ unsafe { core::mem::transmute::<*mut c_void, &mut TestTableFixed>(ptr) };
Some(buffer)
}
-fn release_buffer (test_table : &mut TestTableFixed)
-{
- test_table.r#type = 0;
- unsafe { FreePool (test_table as *mut TestTableFixed as *mut c_void) ; }
+fn release_buffer(test_table: &mut TestTableFixed) {
+ test_table.r#type = 0;
+ unsafe {
+ FreePool(test_table as *mut TestTableFixed as *mut c_void);
+ }
}
#[no_mangle]
#[export_name = "TestBufferDrop"]
-pub extern fn test_buffer_drop (
-
- )
-{
- match get_buffer () {
- Some(buffer) => {
- buffer.r#type = 1;
- release_buffer(buffer);
- drop (buffer); // This is required.
- //buffer.r#type = 1; // error
- },
- None => {},
+pub extern "C" fn test_buffer_drop() {
+ match get_buffer() {
+ Some(buffer) => {
+ buffer.r#type = 1;
+ release_buffer(buffer);
+ drop(buffer); // This is required.
+ //buffer.r#type = 1; // error
+ }
+ None => {}
}
}
#[no_mangle]
#[export_name = "TestBufferBorrow"]
-pub extern fn test_buffer_borrow (
- test_table : &mut TestTableFixed
- )
-{
- let test_table2 : &mut TestTableFixed = test_table;
+pub extern "C" fn test_buffer_borrow(test_table: &mut TestTableFixed) {
+ let test_table2: &mut TestTableFixed = test_table;
test_table2.r#type = 1;
- let test_table3 : &mut [u8; 64] = &mut test_table.value;
+ let test_table3: &mut [u8; 64] = &mut test_table.value;
test_table3[63] = 0;
//test_table2.r#type = 2; // error
@@ -237,44 +211,38 @@ pub extern fn test_buffer_borrow (
#[no_mangle]
#[export_name = "TestBufferAlloc"]
-pub extern fn test_buffer_alloc (
-
- )
-{
+pub extern "C" fn test_buffer_alloc() {
let layout = unsafe { core::alloc::Layout::from_size_align_unchecked(32, 4) };
unsafe {
- match Global.alloc (layout) {
- Ok(buffer) => {
- let mut box_buffer = Box::from_raw(from_raw_parts_mut(buffer.as_ptr(), layout.size()));
- box_buffer[0] = 1;
- Global.dealloc (buffer, layout);
- drop (buffer); // It is useless
- box_buffer[0] = 1; // cannot catch
- },
- Err(_) => handle_alloc_error (layout),
- }
+ match Global.allocate(layout) {
+ Ok(mut buffer) => {
+ let mut box_buffer = Box::from_raw(buffer.as_mut());
+ box_buffer[0] = 1;
+ Global.deallocate(buffer.as_non_null_ptr(), layout);
+ drop(buffer); // It is useless
+ box_buffer[0] = 1; // cannot catch
+ }
+ Err(_) => handle_alloc_error(layout),
+ }
}
let layout = core::alloc::Layout::new::<u32>();
unsafe {
- match Global.alloc (layout) {
- Ok(buffer) => {
- Global.dealloc (buffer, layout);
- },
- Err(_) => handle_alloc_error (layout),
- }
+ match Global.allocate(layout) {
+ Ok(buffer) => {
+ Global.deallocate(buffer.as_non_null_ptr(), layout);
+ }
+ Err(_) => handle_alloc_error(layout),
+ }
}
}
-fn get_box (
- r#type: u32
- ) -> Box<TestTableFixed>
-{
- let mut a = Box::new(TestTableFixed{
- r#type: 0,
- length: size_of::<TestTableFixed>() as u32,
- value: [0; 64]
- }); // it will call __rust_alloc().
+fn get_box(r#type: u32) -> Box<TestTableFixed> {
+ let mut a = Box::new(TestTableFixed {
+ r#type: 0,
+ length: size_of::<TestTableFixed>() as u32,
+ value: [0; 64],
+ }); // it will call __rust_alloc().
a.r#type = r#type;
a
@@ -282,35 +250,26 @@ fn get_box (
#[no_mangle]
#[export_name = "TestBoxAlloc"]
-pub extern fn test_box_alloc (
- r#type: u32
- ) -> Box<TestTableFixed>
-{
- let mut a = get_box(1);
+pub extern "C" fn test_box_alloc(r#type: u32) -> Box<TestTableFixed> {
+ let mut a = get_box(1);
- a.r#type = r#type;
+ a.r#type = r#type;
- //test_box_free(a); // build fail.
+ //test_box_free(a); // build fail.
- let b = a;
- b
+ let b = a;
+ b
}
#[no_mangle]
#[export_name = "TestBoxFree"]
-pub extern fn test_box_free (
- buffer: Box<TestTableFixed>
- )
-{
- // it will call __rust_dealloc()
+pub extern "C" fn test_box_free(buffer: Box<TestTableFixed>) {
+ // it will call __rust_dealloc()
}
#[no_mangle]
#[export_name = "TestBoxAllocFail"]
-pub extern fn test_box_alloc_fail (
- size: u32
- ) -> Box<[u8; 0x800]>
-{
+pub extern "C" fn test_box_alloc_fail(size: u32) -> Box<[u8; 0x800]> {
let mut a = Box::new([0_u8; 0x800]); // it will call __rust_alloc().
a
@@ -318,22 +277,17 @@ pub extern fn test_box_alloc_fail (
#[no_mangle]
#[export_name = "TestBoxConvert"]
-pub extern fn test_box_convert (
- size: usize
- ) -> *mut u8
-{
+pub extern "C" fn test_box_convert(size: usize) -> *mut u8 {
let layout = unsafe { core::alloc::Layout::from_size_align_unchecked(size, 4) };
unsafe {
- match Global.alloc (layout) {
- Ok(buffer) => {
- let mut box_buffer = Box::<u8>::from_raw(from_raw_parts_mut(buffer.as_ptr(), layout.size()) as *mut [u8] as *mut u8 );
- Global.dealloc (buffer, layout);
- *box_buffer = 1;
- Box::<u8>::into_raw(box_buffer)
- },
- Err(_) => handle_alloc_error (layout),
- }
+ match Global.allocate(layout) {
+ Ok(buffer) => {
+ let mut box_buffer = Box::<u8>::from_raw(buffer.as_mut_ptr());
+ Global.deallocate(buffer.as_non_null_ptr(), layout);
+ *box_buffer = 1;
+ Box::<u8>::into_raw(box_buffer)
+ }
+ Err(_) => handle_alloc_error(layout),
+ }
}
-
-
}
--
2.35.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v1 3/3] RustPkg/Test/TestRustLangApp: Fix building
2022-03-19 7:05 [PATCH v1 0/3]: Fix RustPkg/Tests in edkii-rust branch edk2-staging ayushdevel1325
2022-03-19 7:05 ` [PATCH v1 1/3] RustPkg/Test: Replace cargo-xbuild with build-std Ayush Singh
2022-03-19 7:05 ` [PATCH v1 2/3] RustPkg/Test/TestRustLangLib: Fix Building Ayush Singh
@ 2022-03-19 7:05 ` Ayush Singh
2022-03-19 8:40 ` [edk2-devel] [PATCH v1 0/3]: Fix RustPkg/Tests in edkii-rust branch edk2-staging Marvin Häuser
3 siblings, 0 replies; 10+ messages in thread
From: Ayush Singh @ 2022-03-19 7:05 UTC (permalink / raw)
To: devel; +Cc: Jiewen Yao
Removed defination of _fltused from
RustPkg/Library/UefiRustIntrinsicLib since compiler_builtins now
provides one
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
---
RustPkg/Library/UefiRustIntrinsicLib/src/lib.rs | 8 --
RustPkg/Test/TestRustLangApp/.cargo/config.toml | 3 +
RustPkg/Test/TestRustLangApp/src/main.rs | 95 +++++++++-----------
3 files changed, 43 insertions(+), 63 deletions(-)
diff --git a/RustPkg/Library/UefiRustIntrinsicLib/src/lib.rs b/RustPkg/Library/UefiRustIntrinsicLib/src/lib.rs
index c2341e9a65af..2bfdc524a11c 100644
--- a/RustPkg/Library/UefiRustIntrinsicLib/src/lib.rs
+++ b/RustPkg/Library/UefiRustIntrinsicLib/src/lib.rs
@@ -12,15 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-
#![cfg_attr(not(test), no_std)]
-
#![allow(unused)]
-#[used]
-#[no_mangle]
-pub static _fltused : i32 = 0;
-
extern crate uefi_rust_panic_lib;
-
-
diff --git a/RustPkg/Test/TestRustLangApp/.cargo/config.toml b/RustPkg/Test/TestRustLangApp/.cargo/config.toml
new file mode 100644
index 000000000000..422bf9d2ab4e
--- /dev/null
+++ b/RustPkg/Test/TestRustLangApp/.cargo/config.toml
@@ -0,0 +1,3 @@
+[unstable]
+build-std = ["core", "compiler_builtins", "alloc"]
+build-std-features = ["compiler-builtins-mem"]
diff --git a/RustPkg/Test/TestRustLangApp/src/main.rs b/RustPkg/Test/TestRustLangApp/src/main.rs
index 9dcea4fa5c4e..72bb12e16adf 100644
--- a/RustPkg/Test/TestRustLangApp/src/main.rs
+++ b/RustPkg/Test/TestRustLangApp/src/main.rs
@@ -13,120 +13,105 @@
// limitations under the License.
#![crate_type = "staticlib"]
-
#![feature(alloc_layout_extra)]
#![feature(allocator_api)]
#![feature(alloc_error_handler)]
-#![feature(core_panic_info)]
-#![feature(asm)]
-
#![cfg_attr(not(test), no_std)]
#![no_main]
-
#![allow(unused)]
mod mem;
extern crate test_rust_lang_lib;
+extern crate uefi_rust_allocation_lib;
extern crate uefi_rust_intrinsic_lib;
extern crate uefi_rust_panic_lib;
-extern crate uefi_rust_allocation_lib;
use r_efi::efi;
-use r_efi::efi::{Status};
+use r_efi::efi::Status;
-use core::panic::PanicInfo;
use core::ffi::c_void;
+use core::panic::PanicInfo;
use core::mem::size_of;
use core::mem::transmute;
use core::slice::from_raw_parts;
-
-static mut ST : *mut efi::SystemTable = core::ptr::null_mut();
-static mut BS : *mut efi::BootServices = core::ptr::null_mut();
+static mut ST: *mut efi::SystemTable = core::ptr::null_mut();
+static mut BS: *mut efi::BootServices = core::ptr::null_mut();
extern crate alloc;
-use alloc::vec::Vec;
use alloc::boxed::Box;
-
+use alloc::vec::Vec;
#[no_mangle]
#[export_name = "AllocatePool"]
-extern fn AllocatePool (size: usize) -> *mut c_void
-{
- let mut address : *mut c_void = core::ptr::null_mut();
-
- let status = unsafe { ((*BS).allocate_pool) (
- efi::MemoryType::BootServicesData,
- size,
- &mut address as *mut *mut c_void
- ) } ;
- if status != Status::SUCCESS {
+extern "C" fn AllocatePool(size: usize) -> *mut c_void {
+ let mut address: *mut c_void = core::ptr::null_mut();
+
+ let status = unsafe {
+ ((*BS).allocate_pool)(
+ efi::MemoryType::BootServicesData,
+ size,
+ &mut address as *mut *mut c_void,
+ )
+ };
+ if status != Status::SUCCESS {
return core::ptr::null_mut();
- }
- address as *mut c_void
+ }
+ address as *mut c_void
}
-
-
#[no_mangle]
#[export_name = "AllocateZeroPool"]
-extern fn AllocateZeroPool (size: usize) -> *mut c_void
-{
- let buffer = AllocatePool (size);
+extern "C" fn AllocateZeroPool(size: usize) -> *mut c_void {
+ let buffer = AllocatePool(size);
if buffer == core::ptr::null_mut() {
- return core::ptr::null_mut();
+ return core::ptr::null_mut();
}
- unsafe {core::ptr::write_bytes (buffer, 0, size);}
+ unsafe {
+ core::ptr::write_bytes(buffer, 0, size);
+ }
buffer as *mut c_void
}
-
-
#[no_mangle]
#[export_name = "FreePool"]
-extern fn FreePool (buffer: *mut c_void)
-{
+extern "C" fn FreePool(buffer: *mut c_void) {
unsafe {
- ((*BS).free_pool) (buffer as *mut c_void);
+ ((*BS).free_pool)(buffer as *mut c_void);
}
}
#[no_mangle]
#[export_name = "ExternInit"]
-extern fn ExternInit(data: *mut usize)
-{
-}
-
+extern "C" fn ExternInit(data: *mut usize) {}
#[no_mangle]
-pub extern fn efi_main(handle: efi::Handle, system_table: *mut efi::SystemTable) -> Status
-{
+pub extern "C" fn efi_main(handle: efi::Handle, system_table: *mut efi::SystemTable) -> Status {
uefi_rust_allocation_lib::init(system_table);
unsafe {
- ST = system_table;
- BS = (*ST).boot_services;
+ ST = system_table;
+ BS = (*ST).boot_services;
}
// L"Hello World!/r/n"
- let string_name = & mut [
- 0x48u16, 0x65u16, 0x6cu16, 0x6cu16, 0x6fu16, 0x20u16,
- 0x57u16, 0x6fu16, 0x72u16, 0x6cu16, 0x64u16, 0x21u16,
- 0x0Au16, 0x0Du16, 0x00u16
- ];
+ let string_name = &mut [
+ 0x48u16, 0x65u16, 0x6cu16, 0x6cu16, 0x6fu16, 0x20u16, 0x57u16, 0x6fu16, 0x72u16, 0x6cu16,
+ 0x64u16, 0x21u16, 0x0Au16, 0x0Du16, 0x00u16,
+ ];
unsafe {
- ((*((*ST).con_out)).output_string) (
- unsafe {(*ST).con_out},
- string_name.as_ptr() as *mut efi::Char16,
- );
+ ((*((*ST).con_out)).output_string)(
+ unsafe { (*ST).con_out },
+ string_name.as_ptr() as *mut efi::Char16,
+ );
}
- test_rust_lang_lib::test_integer_overflow (0x10000, 0xFFFFFFFF, 0xFFFFFFFF);
+ test_rust_lang_lib::test_integer_overflow(0x10000, 0xFFFFFFFF, 0xFFFFFFFF);
Status::SUCCESS
}
--
2.35.1
^ permalink raw reply related [flat|nested] 10+ messages in thread