closure_ffi/
cc.rs

1//! Defines calling convention marker types for use with `BareFn` variants.
2
3#[cfg(feature = "proc_macros")]
4#[doc(inline)]
5pub use closure_ffi_proc_macros::hrtb_cc as hrtb;
6
7macro_rules! cc_impl {
8    ($ty_name:ident, $lit_name:literal $(,$cfg:meta)?) => {
9        #[doc = "Marker type representing the"]
10        #[doc = $lit_name]
11        #[doc = "calling convention."]
12        #[derive(Debug, Clone, Copy, Default)]
13        $(#[cfg(any($cfg, doc))])?
14        pub struct $ty_name;
15        $(#[cfg($cfg)])?
16        $crate::thunk::cc_thunk_impl!($ty_name, $lit_name);
17    };
18}
19
20cc_impl!(C, "C");
21
22cc_impl!(System, "system");
23
24cc_impl!(Sysv64, "sysv64", all(not(windows), target_arch = "x86_64"));
25
26cc_impl!(
27    Aapcs,
28    "aapcs",
29    any(target_arch = "arm", target_arch = "aarch64")
30);
31
32cc_impl!(
33    Fastcall,
34    "fastcall",
35    all(windows, any(target_arch = "x86_64", target_arch = "x86"))
36);
37
38cc_impl!(
39    Stdcall,
40    "stdcall",
41    all(windows, any(target_arch = "x86_64", target_arch = "x86"))
42);
43
44cc_impl!(
45    Cdecl,
46    "cdecl",
47    all(windows, any(target_arch = "x86_64", target_arch = "x86"))
48);
49
50cc_impl!(Thiscall, "thiscall", all(windows, target_arch = "x86"));
51
52cc_impl!(Win64, "win64", all(windows, target_arch = "x86_64"));