33extern crate proc_macro;
44
55use proc_macro:: TokenStream ;
6+
7+ use proc_macro2:: Span ;
68use quote:: { quote, TokenStreamExt } ;
79use syn:: parse:: { Parse , ParseStream } ;
810use syn:: { parse_macro_input, DeriveInput , Generics , Ident , ItemFn , ItemType , LitStr } ;
@@ -87,10 +89,10 @@ pub fn unsafe_guid(args: TokenStream, input: TokenStream) -> TokenStream {
8789 let ident = type_definition. ident . clone ( ) ;
8890 let ( impl_generics, ty_generics, where_clause) = type_definition. generics . split_for_impl ( ) ;
8991 result. append_all ( quote ! {
90- unsafe impl #impl_generics crate :: Identify for #ident #ty_generics #where_clause {
92+ unsafe impl #impl_generics :: uefi :: Identify for #ident #ty_generics #where_clause {
9193 #[ doc( hidden) ]
9294 #[ allow( clippy:: unreadable_literal) ]
93- const GUID : crate :: Guid = crate :: Guid :: from_values(
95+ const GUID : :: uefi :: Guid = :: uefi :: Guid :: from_values(
9496 #time_low,
9597 #time_mid,
9698 #time_high_and_version,
@@ -113,7 +115,7 @@ pub fn derive_protocol(item: TokenStream) -> TokenStream {
113115 let ( impl_generics, ty_generics, where_clause) = item. generics . split_for_impl ( ) ;
114116 let result = quote ! {
115117 // Mark this as a `Protocol` implementation
116- impl #impl_generics crate :: proto:: Protocol for #ident #ty_generics #where_clause { }
118+ impl #impl_generics :: uefi :: proto:: Protocol for #ident #ty_generics #where_clause { }
117119
118120 // Most UEFI functions expect to be called on the bootstrap processor.
119121 impl #impl_generics !Send for #ident #ty_generics #where_clause { }
@@ -134,14 +136,15 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
134136 panic ! ( "This attribute accepts no arguments" ) ;
135137 }
136138
137- let f = parse_macro_input ! ( input as ItemFn ) ;
139+ let mut f = parse_macro_input ! ( input as ItemFn ) ;
138140
139- let entry_fn_ident = & f. sig . ident ;
141+ // force the exported symbol to be 'efi_main'
142+ f. sig . ident = Ident :: new ( "efi_main" , Span :: call_site ( ) ) ;
140143
141- let result = quote ! (
142- static _UEFI_ENTRY_POINT_TYPE_CHECK: extern "efiapi" fn ( uefi:: Handle , uefi:: table:: SystemTable <uefi:: table:: Boot >) -> uefi:: Status = #entry_fn_ident ;
144+ let result = quote ! {
145+ static _UEFI_ENTRY_POINT_TYPE_CHECK: extern "efiapi" fn ( uefi:: Handle , uefi:: table:: SystemTable <uefi:: table:: Boot >) -> uefi:: Status = efi_main ;
143146 #[ no_mangle]
144147 pub extern "efiapi" #f
145- ) ;
148+ } ;
146149 result. into ( )
147150}
0 commit comments