| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <config.h> |
| 20 |
|
| 21 |
#include <alignof.h> |
| 22 |
|
| 23 |
#include <stddef.h> |
| 24 |
#include <stdint.h> |
| 25 |
|
| 26 |
#include "verify.h" |
| 27 |
|
| 28 |
typedef long double longdouble; |
| 29 |
typedef struct { char a[1]; } struct1; |
| 30 |
typedef struct { char a[2]; } struct2; |
| 31 |
typedef struct { char a[3]; } struct3; |
| 32 |
typedef struct { char a[4]; } struct4; |
| 33 |
|
| 34 |
#define CHECK(type) \ |
| 35 |
typedef struct { char slot1; type slot2; } type##_helper; \ |
| 36 |
verify (alignof_slot (type) == offsetof (type##_helper, slot2)); \ |
| 37 |
const int type##_slot_alignment = alignof_slot (type); \ |
| 38 |
const int type##_type_alignment = alignof_type (type); |
| 39 |
|
| 40 |
CHECK (char) |
| 41 |
CHECK (short) |
| 42 |
CHECK (int) |
| 43 |
CHECK (long) |
| 44 |
CHECK (float) |
| 45 |
CHECK (double) |
| 46 |
CHECK (longdouble) |
| 47 |
#ifdef INT64_MAX |
| 48 |
CHECK (int64_t) |
| 49 |
#endif |
| 50 |
CHECK (struct1) |
| 51 |
CHECK (struct2) |
| 52 |
CHECK (struct3) |
| 53 |
CHECK (struct4) |
| 54 |
|
| 55 |
int |
| 56 |
main () |
| 57 |
{ |
| 58 |
return 0; |
| 59 |
} |