Loading...
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* * BTF-to-C dumper tests for implicit and explicit padding between fields and * at the end of a struct. * * Copyright (c) 2019 Facebook */ /* ----- START-EXPECTED-OUTPUT ----- */ struct padded_implicitly { int a; long b; char c; }; /* ------ END-EXPECTED-OUTPUT ------ */ /* ----- START-EXPECTED-OUTPUT ----- */ /* *struct padded_explicitly { * int a; * long: 0; * int b; *}; * */ /* ------ END-EXPECTED-OUTPUT ------ */ struct padded_explicitly { int a; int: 1; /* algo will emit aligning `long: 0;` here */ int b; }; /* ----- START-EXPECTED-OUTPUT ----- */ struct padded_a_lot { int a; long: 64; long: 64; int b; }; /* ------ END-EXPECTED-OUTPUT ------ */ /* ----- START-EXPECTED-OUTPUT ----- */ /* *struct padded_cache_line { * int a; * long: 64; * long: 64; * long: 64; * int b; * long: 64; * long: 64; * long: 64; *}; * */ /* ------ END-EXPECTED-OUTPUT ------ */ struct padded_cache_line { int a; int b __attribute__((aligned(32))); }; /* ----- START-EXPECTED-OUTPUT ----- */ /* *struct zone_padding { * char x[0]; *}; * *struct zone { * int a; * short b; * long: 0; * struct zone_padding __pad__; *}; * */ /* ------ END-EXPECTED-OUTPUT ------ */ struct zone_padding { char x[0]; } __attribute__((__aligned__(8))); struct zone { int a; short b; struct zone_padding __pad__; }; /* ----- START-EXPECTED-OUTPUT ----- */ struct padding_wo_named_members { long: 64; long: 64; }; struct padding_weird_1 { int a; long: 64; short: 16; short b; }; /* ------ END-EXPECTED-OUTPUT ------ */ /* ----- START-EXPECTED-OUTPUT ----- */ /* *struct padding_weird_2 { * long: 56; * char a; * long: 56; * char b; * char: 8; *}; * */ /* ------ END-EXPECTED-OUTPUT ------ */ struct padding_weird_2 { int: 32; /* these paddings will be collapsed into `long: 56;` */ short: 16; char: 8; char a; int: 32; /* these paddings will be collapsed into `long: 56;` */ short: 16; char: 8; char b; char: 8; }; /* ----- START-EXPECTED-OUTPUT ----- */ struct exact_1byte { char x; }; struct padded_1byte { char: 8; }; struct exact_2bytes { short x; }; struct padded_2bytes { short: 16; }; struct exact_4bytes { int x; }; struct padded_4bytes { int: 32; }; struct exact_8bytes { long x; }; struct padded_8bytes { long: 64; }; struct ff_periodic_effect { int: 32; short magnitude; long: 0; short phase; long: 0; int: 32; int custom_len; short *custom_data; }; struct ib_wc { long: 64; long: 64; int: 32; int byte_len; void *qp; union {} ex; long: 64; int slid; int wc_flags; long: 64; char smac[6]; long: 0; char network_hdr_type; }; struct acpi_object_method { long: 64; char: 8; char type; short reference_count; char flags; short: 0; char: 8; char sync_level; long: 64; void *node; void *aml_start; union {} dispatch; long: 64; int aml_length; }; struct nested_unpacked { int x; }; struct nested_packed { struct nested_unpacked a; char c; } __attribute__((packed)); struct outer_mixed_but_unpacked { struct nested_packed b1; short a1; struct nested_packed b2; }; /* ------ END-EXPECTED-OUTPUT ------ */ int f(struct { struct padded_implicitly _1; struct padded_explicitly _2; struct padded_a_lot _3; struct padded_cache_line _4; struct zone _5; struct padding_wo_named_members _6; struct padding_weird_1 _7; struct padding_weird_2 _8; struct exact_1byte _100; struct padded_1byte _101; struct exact_2bytes _102; struct padded_2bytes _103; struct exact_4bytes _104; struct padded_4bytes _105; struct exact_8bytes _106; struct padded_8bytes _107; struct ff_periodic_effect _200; struct ib_wc _201; struct acpi_object_method _202; struct outer_mixed_but_unpacked _203; } *_) { return 0; } |