Skip to content

Commit

Permalink
Teach rust core about Xtensa VaListImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
kelnos authored and MabezDev committed Apr 15, 2021
1 parent 0e8aacc commit c051584
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions library/core/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl fmt::Debug for c_void {
/// Basic implementation of a `va_list`.
// The name is WIP, using `VaListImpl` for now.
#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64"), not(target_arch = "xtensa")),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
Expand All @@ -84,7 +84,7 @@ pub struct VaListImpl<'f> {
}

#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64"), not(target_arch = "xtensa")),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
Expand Down Expand Up @@ -169,6 +169,24 @@ pub struct VaListImpl<'f> {
_marker: PhantomData<&'f mut &'f c_void>,
}

/// xtensa ABI implementation of a `va_list`.
#[cfg(target_arch = "xtensa")]
#[repr(C)]
#[derive(Debug)]
#[unstable(
feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
all supported platforms",
issue = "44930"
)]
#[lang = "va_list"]
pub struct VaListImpl<'f> {
stk: *mut i32,
reg: *mut i32,
ndx: i32,
_marker: PhantomData<&'f mut &'f i32>,
}

/// A wrapper for a `va_list`
#[repr(transparent)]
#[derive(Debug)]
Expand All @@ -183,7 +201,8 @@ pub struct VaList<'a, 'f: 'a> {
all(
not(target_arch = "aarch64"),
not(target_arch = "powerpc"),
not(target_arch = "x86_64")
not(target_arch = "x86_64"),
not(target_arch = "xtensa")
),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
Expand All @@ -193,7 +212,7 @@ pub struct VaList<'a, 'f: 'a> {
inner: VaListImpl<'f>,

#[cfg(all(
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64", target_arch = "xtensa"),
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
Expand All @@ -205,7 +224,7 @@ pub struct VaList<'a, 'f: 'a> {
}

#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64"), not(target_arch = "xtensa")),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
Expand All @@ -226,7 +245,7 @@ impl<'f> VaListImpl<'f> {
}

#[cfg(all(
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64", target_arch = "xtensa"),
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
Expand Down

0 comments on commit c051584

Please sign in to comment.