Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
0002 
0003 /*
0004  * BTF-to-C dumper tests for struct packing determination.
0005  *
0006  * Copyright (c) 2019 Facebook
0007  */
0008 /* ----- START-EXPECTED-OUTPUT ----- */
0009 struct packed_trailing_space {
0010     int a;
0011     short b;
0012 } __attribute__((packed));
0013 
0014 struct non_packed_trailing_space {
0015     int a;
0016     short b;
0017 };
0018 
0019 struct packed_fields {
0020     short a;
0021     int b;
0022 } __attribute__((packed));
0023 
0024 struct non_packed_fields {
0025     short a;
0026     int b;
0027 };
0028 
0029 struct nested_packed {
0030     char: 4;
0031     int a: 4;
0032     long b;
0033     struct {
0034         char c;
0035         int d;
0036     } __attribute__((packed)) e;
0037 } __attribute__((packed));
0038 
0039 union union_is_never_packed {
0040     int a: 4;
0041     char b;
0042     char c: 1;
0043 };
0044 
0045 union union_does_not_need_packing {
0046     struct {
0047         long a;
0048         int b;
0049     } __attribute__((packed));
0050     int c;
0051 };
0052 
0053 union jump_code_union {
0054     char code[5];
0055     struct {
0056         char jump;
0057         int offset;
0058     } __attribute__((packed));
0059 };
0060 
0061 /*------ END-EXPECTED-OUTPUT ------ */
0062 
0063 int f(struct {
0064     struct packed_trailing_space _1;
0065     struct non_packed_trailing_space _2;
0066     struct packed_fields _3;
0067     struct non_packed_fields _4;
0068     struct nested_packed _5;
0069     union union_is_never_packed _6;
0070     union union_does_not_need_packing _7;
0071     union jump_code_union _8;
0072 } *_)
0073 {
0074     return 0;
0075 }