public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ayush Singh" <ayushdevel1325@gmail.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>
Subject: [PATCH v1 3/3] RustPkg/Test/TestRustLangApp: Fix building
Date: Sat, 19 Mar 2022 12:35:53 +0530	[thread overview]
Message-ID: <20220319070553.25770-4-ayushdevel1325@gmail.com> (raw)
In-Reply-To: <20220319070553.25770-1-ayushdevel1325@gmail.com>

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


  parent reply	other threads:[~2022-03-19  7:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-03-19  8:40 ` [edk2-devel] [PATCH v1 0/3]: Fix RustPkg/Tests in edkii-rust branch edk2-staging Marvin Häuser
2022-03-19  8:46   ` Ayush Singh
2022-03-19 13:59   ` Yao, Jiewen
2022-03-19 14:14     ` Ayush Singh
2022-03-19 14:36       ` Yao, Jiewen
2022-03-19 21:11         ` Ayush Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220319070553.25770-4-ayushdevel1325@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox