mirror of
https://git.proxmox.com/git/perlmod
synced 2025-10-04 18:27:16 +00:00
macro: ensure bootstrap functions happen only once
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
7b22916567
commit
b94cbb8f16
@ -104,8 +104,7 @@ impl Package {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let bootstrap_name =
|
let bootstrap_name = format!("boot_{}", self.attrs.package_name).replace("::", "__");
|
||||||
format!("boot_{}", self.attrs.package_name).replace("::", "__");
|
|
||||||
let bootstrap_ident = Ident::new(&bootstrap_name, Span::call_site());
|
let bootstrap_ident = Ident::new(&bootstrap_name, Span::call_site());
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
@ -113,14 +112,17 @@ impl Package {
|
|||||||
pub extern "C" fn #bootstrap_ident(
|
pub extern "C" fn #bootstrap_ident(
|
||||||
_cv: &::perlmod::ffi::CV,
|
_cv: &::perlmod::ffi::CV,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
static ONCE: ::std::sync::Once = ::std::sync::Once::new();
|
||||||
use ::perlmod::ffi::RSPL_newXS_flags;
|
ONCE.call_once(|| {
|
||||||
|
unsafe {
|
||||||
|
use ::perlmod::ffi::RSPL_newXS_flags;
|
||||||
|
|
||||||
let argmark = ::perlmod::ffi::pop_arg_mark();
|
let argmark = ::perlmod::ffi::pop_arg_mark();
|
||||||
argmark.set_stack();
|
argmark.set_stack();
|
||||||
|
|
||||||
#newxs
|
#newxs
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user