diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:39:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:39:07 +0000 |
commit | af6b8ed095f88f1df2116cdc7a9d44872cfa6074 (patch) | |
tree | 1f2df671c1f8033d5ed83f056167a0911f8d2a57 /tests/rust/layout.rs | |
parent | Initial commit. (diff) | |
download | rust-cbindgen-af6b8ed095f88f1df2116cdc7a9d44872cfa6074.tar.xz rust-cbindgen-af6b8ed095f88f1df2116cdc7a9d44872cfa6074.zip |
Adding upstream version 0.26.0.upstream/0.26.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rust/layout.rs')
-rw-r--r-- | tests/rust/layout.rs | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/rust/layout.rs b/tests/rust/layout.rs new file mode 100644 index 0000000..b15c675 --- /dev/null +++ b/tests/rust/layout.rs @@ -0,0 +1,108 @@ +#[repr(align(1), C)] +pub struct Align1Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(align(2), C)] +pub struct Align2Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(align(4), C)] +pub struct Align4Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(align(8), C)] +pub struct Align8Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(align(32), C)] +pub struct Align32Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(packed, C)] +pub struct PackedStruct { + pub arg1: usize, + pub arg2: *mut u8, +} + +#[repr(align(1), C)] +pub union Align1Union { + pub variant1: usize, + pub variant2: *mut u8, +} + +#[repr(align(4), C)] +pub union Align4Union { + pub variant1: usize, + pub variant2: *mut u8, +} + +#[repr(align(16), C)] +pub union Align16Union { + pub variant1: usize, + pub variant2: *mut u8, +} + +#[repr(packed, C)] +pub union PackedUnion { + pub variant1: usize, + pub variant2: *mut u8, +} + +// #[repr(packed(n), C)] structs are currently unsupported. +#[repr(packed(4), C)] +pub struct UnsupportedPacked4Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +// #[repr(packed(n), C)] unions are currently unsupported. +#[repr(packed(4), C)] +pub union UnsupportedPacked4Union { + pub variant1: usize, + pub variant2: *mut u8, +} + +// #[repr(align(n), C)] enums are currently unsupported. +#[repr(align(4), C)] +pub enum UnsupportedAlign4Enum { + Variant1, + Variant2, +} + +// Non-repr(C) structs aren't translated. +#[repr(align(4))] +pub struct RustAlign4Struct { + pub arg1: usize, + pub arg2: *mut u8, +} + +// Non-repr(C) structs aren't translated. +#[repr(packed)] +pub struct RustPackedStruct { + pub arg1: usize, + pub arg2: *mut u8, +} + +// Non-repr(C) unions aren't translated. +#[repr(align(4))] +pub struct RustAlign4Union { + pub arg1: usize, + pub arg2: *mut u8, +} + +// Non-repr(C) unions aren't translated. +#[repr(packed)] +pub struct RustPackedUnion { + pub arg1: usize, + pub arg2: *mut u8, +} |