[go: up one dir, main page]

File: s-struct.c

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (35 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (3)
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
// The sizeof(Option) is 11 in 64-bit, 7 in 32-bit.
struct __attribute__((packed)) Option {
	char m; // 1
	long n; // 8 or 4
	short k; // 2
};

// empty struct
struct StringRef {};

// global variables to suppress compiler optimization
struct Option g_opt;
struct StringRef g_sr;
unsigned g_index;
int g_value1;
int g_value2;

__attribute__((noinline)) void foo(const struct Option Opt, struct StringRef S, unsigned Index,
				   const int Value1, const int Value2)
{
	g_opt = Opt;
	g_sr = S;
	g_index = Index;
	g_value1 = Value1;
	g_value2 = Value2;
}

int main(void)
{
	struct Option Opt = { 11, 22, 33 };
	struct StringRef S;

	foo(Opt, S, 44, 55, 66);
	return 0;
}