Skip to content

Commit 023f38f

Browse files
committed
custom VaList layout for Hexagon
1 parent ce63e5d commit 023f38f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

library/core/src/ffi/va_list.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ use crate::marker::PhantomCovariantLifetime;
3131
// the pointer decay behavior in Rust, while otherwise matching Rust semantics.
3232
// This attribute ensures that the compiler uses the correct ABI for functions
3333
// like `extern "C" fn takes_va_list(va: VaList<'_>)` by passing `va` indirectly.
34+
//
35+
// The Clang `BuiltinVaListKind` enumerates the `va_list` variations that Clang supports,
36+
// and we mirror these here.
3437
crate::cfg_select! {
3538
all(
3639
target_arch = "aarch64",
@@ -124,6 +127,23 @@ crate::cfg_select! {
124127
}
125128
}
126129

130+
all(target_arch = "hexagon", target_env = "musl") => {
131+
/// Hexagon Musl implementation of a `va_list`.
132+
///
133+
/// See the [LLVM source] for more details. On bare metal Hexagon uses an opaque pointer.
134+
///
135+
/// [LLVM source]:
136+
/// https://github.com/llvm/llvm-project/blob/0cdc1b6dd4a870fc41d4b15ad97e0001882aba58/clang/lib/CodeGen/Targets/Hexagon.cpp#L407-L417
137+
#[repr(C)]
138+
#[derive(Debug)]
139+
#[rustc_pass_indirectly_in_non_rustic_abis]
140+
struct VaListInner {
141+
__current_saved_reg_area_pointer: *const c_void,
142+
__saved_reg_area_end_pointer: *const c_void,
143+
__overflow_area_pointer: *const c_void,
144+
}
145+
}
146+
127147
// The fallback implementation, used for:
128148
//
129149
// - apple aarch64 (see https://github.com/rust-lang/rust/pull/56599)

0 commit comments

Comments
 (0)