1 /* This is a small test to see if bitfields are working. It is only a
2 few structs and a union and a test to see if they have the correct
3 size, if values can be read and written and a couple of argument
4 passing tests. No alignment testing is done. */
10 /* These five bitfields are taken from the System V ABI, Intel 386
11 architecture supplement. */
13 /* Word aligned, sizeof is 4. */
21 /* Word aligned, sizeof is 12. */
22 struct BoundaryAlignment
32 /* Halfword aligned, sizeof is 2. */
33 struct StorageUnitSharing
39 /* Halfword aligned, sizeof is 2. */
46 /* Byte aligned, sizeof is 9. */
57 /* Extra struct testing bitfields in larger types.
58 Doubleword aligned, sizeof is 8. */
67 passing1 (struct RightToLeft str
, int j
, int k
, int m
)
75 passing2 (struct BoundaryAlignment str
, short s
, int j
, char c
, short t
,
87 passing3 (struct StorageUnitSharing str
, char c
, short s
)
94 passing4 (struct Unnamed str
, char c
, char d
, char e
)
102 passing5 (struct LargerTypes str
, long long l
, int i
)
110 passingU (union Allocation u
, char c
)
120 struct RightToLeft str1
;
121 struct BoundaryAlignment str2
;
122 struct StorageUnitSharing str3
;
124 struct LargerTypes str5
;
127 /* Check sizeof's. */
129 check_size(str2
, 12);
135 /* Check alignof's. */
136 check_align_lv(str1
, 4);
137 check_align_lv(str2
, 4);
138 check_align_lv(str3
, 2);
139 check_align_lv(str4
, 1);
140 check_align_lv(str5
, 8);
141 check_align_lv(u
, 2);
144 str1
.j
= str2
.s
= str3
.c
= str4
.c
= str5
.l
= 4;
145 str1
.k
= str2
.j
= str3
.s
= str4
.d
= str5
.i
= 5;
146 str1
.m
= str2
.c
= str4
.e
= 6;
150 passing1 (str1
, 4, 5, 6);
151 passing2 (str2
, 4, 5, 6, 7, 8, 9);
152 passing3 (str3
, 4, 5);
153 passing4 (str4
, 4, 5, 6);
154 passing5 (str5
, 4, 5);