File: arm-layout.c

package info (click to toggle)
llvm-toolchain-3.9 1%3A3.9.1-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 441,144 kB
  • ctags: 428,836
  • sloc: cpp: 2,546,577; ansic: 538,318; asm: 119,677; objc: 103,316; python: 102,148; sh: 27,847; pascal: 5,626; ml: 5,510; perl: 5,293; lisp: 4,801; makefile: 2,177; xml: 686; cs: 362; php: 212; csh: 117
file content (54 lines) | stat: -rw-r--r-- 1,505 bytes parent folder | download | duplicates (41)
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
// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi apcs-gnu %s -verify
// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi aapcs %s -verify
// expected-no-diagnostics

#define check(name, cond) int _##name##_check[(cond) ? 1 : -1]

struct s0 { char field0; double field1; };
#ifdef __ARM_EABI__
check(s0_size, sizeof(struct s0) == 16);
#else
check(s0_size, sizeof(struct s0) == 12);
#endif

struct s1 { char field0; long double field1; };
#ifdef __ARM_EABI__
check(s1_size, sizeof(struct s1) == 16);
#else
check(s1_size, sizeof(struct s1) == 12);
#endif

struct s2 {
  short field0;
  int field1 : 24;
  char field2;
};
#ifdef __ARM_EABI__
check(s2_size, sizeof(struct s2) == 8);
check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 7);
#else
check(s2_size, sizeof(struct s2) == 6);
check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 5);
#endif

struct s3 {
  short field0;
  int field1 : 24 __attribute__((aligned(4)));
  char field2;
};
check(s3_size, sizeof(struct s3) == 8);
check(s3_offset_0, __builtin_offsetof(struct s3, field0) == 0);
check(s3_offset_1, __builtin_offsetof(struct s3, field2) == 7);

struct s4 {
  int field0 : 4;
};
#ifdef __ARM_EABI__
check(s4_size, sizeof(struct s4) == 4);
check(s4_align, __alignof(struct s4) == 4);
#else
check(s4_size, sizeof(struct s4) == 1);
check(s4_align, __alignof(struct s4) == 1);
#endif