Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.15.
  1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
  2
  3/*
  4 * BTF-to-C dumper tests for implicit and explicit padding between fields and
  5 * at the end of a struct.
  6 *
  7 * Copyright (c) 2019 Facebook
  8 */
  9/* ----- START-EXPECTED-OUTPUT ----- */
 10struct padded_implicitly {
 11	int a;
 12	long int b;
 13	char c;
 14};
 15
 16/* ------ END-EXPECTED-OUTPUT ------ */
 17
 18/* ----- START-EXPECTED-OUTPUT ----- */
 19/*
 20 *struct padded_explicitly {
 21 *	int a;
 22 *	int: 32;
 23 *	int b;
 24 *};
 25 *
 26 */
 27/* ------ END-EXPECTED-OUTPUT ------ */
 28
 29struct padded_explicitly {
 30	int a;
 31	int: 1; /* algo will explicitly pad with full 32 bits here */
 32	int b;
 33};
 34
 35/* ----- START-EXPECTED-OUTPUT ----- */
 36/*
 37 *struct padded_a_lot {
 38 *	int a;
 39 *	long: 32;
 40 *	long: 64;
 41 *	long: 64;
 42 *	int b;
 43 *};
 44 *
 45 */
 46/* ------ END-EXPECTED-OUTPUT ------ */
 47
 48struct padded_a_lot {
 49	int a;
 50	/* 32 bit of implicit padding here, which algo will make explicit */
 51	long: 64;
 52	long: 64;
 53	int b;
 54};
 55
 56/* ----- START-EXPECTED-OUTPUT ----- */
 57/*
 58 *struct padded_cache_line {
 59 *	int a;
 60 *	long: 32;
 61 *	long: 64;
 62 *	long: 64;
 63 *	long: 64;
 64 *	int b;
 65 *};
 66 *
 67 */
 68/* ------ END-EXPECTED-OUTPUT ------ */
 69
 70struct padded_cache_line {
 71	int a;
 72	int b __attribute__((aligned(32)));
 73};
 74
 75/* ----- START-EXPECTED-OUTPUT ----- */
 76/*
 77 *struct zone_padding {
 78 *	char x[0];
 79 *};
 80 *
 81 *struct zone {
 82 *	int a;
 83 *	short b;
 84 *	short: 16;
 85 *	struct zone_padding __pad__;
 86 *};
 87 *
 88 */
 89/* ------ END-EXPECTED-OUTPUT ------ */
 90
 91struct zone_padding {
 92	char x[0];
 93} __attribute__((__aligned__(8)));
 94
 95struct zone {
 96	int a;
 97	short b;
 98	short: 16;
 99	struct zone_padding __pad__;
100};
101
102int f(struct {
103	struct padded_implicitly _1;
104	struct padded_explicitly _2;
105	struct padded_a_lot _3;
106	struct padded_cache_line _4;
107	struct zone _5;
108} *_)
109{
110	return 0;
111}