summaryrefslogtreecommitdiffstats
path: root/tests/rust/layout.rs
blob: b15c67585b521cc10c1eb92b02186937159b08a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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,
}