| 1 |
/* This tests passing of structs. Only integers are tested. */ |
| 2 |
|
| 3 |
#include "defines.h" |
| 4 |
#include "args.h" |
| 5 |
|
| 6 |
struct IntegerRegisters iregbits = { ~0, ~0, ~0, ~0, ~0, ~0 }; |
| 7 |
struct IntegerRegisters iregs; |
| 8 |
unsigned int num_iregs; |
| 9 |
|
| 10 |
struct int_struct |
| 11 |
{ |
| 12 |
int i; |
| 13 |
}; |
| 14 |
|
| 15 |
struct longlong_struct |
| 16 |
{ |
| 17 |
long long ll; |
| 18 |
}; |
| 19 |
|
| 20 |
struct long2_struct |
| 21 |
{ |
| 22 |
long long ll1, ll2; |
| 23 |
}; |
| 24 |
|
| 25 |
struct long3_struct |
| 26 |
{ |
| 27 |
long l1, l2, l3; |
| 28 |
}; |
| 29 |
|
| 30 |
union un1 |
| 31 |
{ |
| 32 |
char c; |
| 33 |
int i; |
| 34 |
}; |
| 35 |
|
| 36 |
union un2 |
| 37 |
{ |
| 38 |
char c1; |
| 39 |
long l; |
| 40 |
char c2; |
| 41 |
}; |
| 42 |
|
| 43 |
union un3 |
| 44 |
{ |
| 45 |
struct int_struct is; |
| 46 |
struct longlong_struct ls; |
| 47 |
union un1 un; |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
void |
| 52 |
check_mixed_passing1 (char c1 ATTRIBUTE_UNUSED, struct int_struct is ATTRIBUTE_UNUSED, char c2 ATTRIBUTE_UNUSED) |
| 53 |
{ |
| 54 |
check_int_arguments; |
| 55 |
} |
| 56 |
|
| 57 |
void |
| 58 |
check_mixed_passing2 (char c1 ATTRIBUTE_UNUSED, struct long3_struct ls ATTRIBUTE_UNUSED, char c2 ATTRIBUTE_UNUSED) |
| 59 |
{ |
| 60 |
check_int_arguments; |
| 61 |
|
| 62 |
/* Check the passing on the stack by comparing the address of the |
| 63 |
stack elements to the expected place on the stack. */ |
| 64 |
assert ((unsigned long)&ls.l1 == esp+4); |
| 65 |
assert ((unsigned long)&ls.l2 == esp+8); |
| 66 |
assert ((unsigned long)&ls.l3 == esp+12); |
| 67 |
} |
| 68 |
|
| 69 |
int |
| 70 |
main (void) |
| 71 |
{ |
| 72 |
struct int_struct is = { 64 }; |
| 73 |
#ifdef CHECK_LARGER_STRUCTS |
| 74 |
struct long3_struct l3s = { 65, 66, 67 }; |
| 75 |
#endif |
| 76 |
|
| 77 |
clear_struct_registers; |
| 78 |
iregs.I0 = 8; |
| 79 |
iregs.I1 = 64; |
| 80 |
iregs.I2 = 9; |
| 81 |
num_iregs = 3; |
| 82 |
clear_int_hardware_registers; |
| 83 |
WRAP_CALL (check_mixed_passing1)(8, is, 9); |
| 84 |
|
| 85 |
#ifdef CHECK_LARGER_STRUCTS |
| 86 |
clear_struct_registers; |
| 87 |
iregs.I0 = 10; |
| 88 |
iregbits.I0 = 0xff; |
| 89 |
iregs.I1 = 11; |
| 90 |
iregbits.I1 = 0xff; |
| 91 |
num_iregs = 2; |
| 92 |
clear_int_hardware_registers; |
| 93 |
WRAP_CALL (check_mixed_passing2)(10, l3s, 11); |
| 94 |
#endif |
| 95 |
|
| 96 |
return 0; |
| 97 |
} |