| 1 |
#include "compat-common.h" |
| 2 |
|
| 3 |
#ifdef SKIP_VA |
| 4 |
const int test_va = 0; |
| 5 |
#else |
| 6 |
const int test_va = 1; |
| 7 |
#endif |
| 8 |
|
| 9 |
typedef void (*fpi)(int); |
| 10 |
typedef void (*fpd)(double); |
| 11 |
|
| 12 |
extern void test1a (fpi); |
| 13 |
extern void test1b (fpi, int); |
| 14 |
extern void test1c (double, fpd); |
| 15 |
extern void test2a (fpi, fpd); |
| 16 |
extern void test2b (fpi, fpd, int); |
| 17 |
extern void test2c (fpi, int, fpd); |
| 18 |
extern void test2d (int, fpi, fpd); |
| 19 |
extern void test2e (fpi, fpd, int, double); |
| 20 |
extern void test2f (fpi, int, fpd, double); |
| 21 |
extern void test2g (fpi, int, double, fpd); |
| 22 |
extern void test2h (double, fpd, fpi, int); |
| 23 |
extern void test2i (double, fpd, int, fpi); |
| 24 |
extern void test2j (int, double, fpi, fpd); |
| 25 |
extern void testva (int, ...); |
| 26 |
|
| 27 |
int f1_val; |
| 28 |
double f2_val; |
| 29 |
|
| 30 |
void f1 (int i) { f1_val = i; } |
| 31 |
void f2 (double x) { f2_val = x; } |
| 32 |
|
| 33 |
void |
| 34 |
checki (int x, int v) |
| 35 |
{ |
| 36 |
if (x != v) |
| 37 |
DEBUG_CHECK |
| 38 |
} |
| 39 |
|
| 40 |
void |
| 41 |
checkd (double x, double v) |
| 42 |
{ |
| 43 |
if (x != v) |
| 44 |
DEBUG_CHECK |
| 45 |
} |
| 46 |
|
| 47 |
void |
| 48 |
testit (void) |
| 49 |
{ |
| 50 |
DEBUG_FPUTS ("test1a: "); |
| 51 |
test1a (f1); |
| 52 |
checki (f1_val, 1); |
| 53 |
DEBUG_NL; |
| 54 |
DEBUG_FPUTS ("test1b: "); |
| 55 |
test1b (f1, 2); |
| 56 |
checki (f1_val, 2); |
| 57 |
DEBUG_NL; |
| 58 |
DEBUG_FPUTS ("test1c: "); |
| 59 |
test1c (3.0, f2); |
| 60 |
checkd (f2_val, 3.0); |
| 61 |
DEBUG_NL; |
| 62 |
DEBUG_FPUTS ("test2a: "); |
| 63 |
test2a (f1, f2); |
| 64 |
checki (f1_val, 10); |
| 65 |
checkd (f2_val, 10.0); |
| 66 |
DEBUG_NL; |
| 67 |
DEBUG_FPUTS ("test2b: "); |
| 68 |
test2b (f1, f2, 11); |
| 69 |
checki (f1_val, 11); |
| 70 |
checkd (f2_val, 11.0); |
| 71 |
DEBUG_NL; |
| 72 |
DEBUG_FPUTS ("test2c: "); |
| 73 |
test2c (f1, 12, f2); |
| 74 |
checki (f1_val, 12); |
| 75 |
checkd (f2_val, 12.0); |
| 76 |
DEBUG_NL; |
| 77 |
DEBUG_FPUTS ("test2d: "); |
| 78 |
test2d (13, f1, f2); |
| 79 |
checki (f1_val, 13); |
| 80 |
checkd (f2_val, 13.0); |
| 81 |
DEBUG_NL; |
| 82 |
DEBUG_FPUTS ("test2e: "); |
| 83 |
test2e (f1, f2, 14, 15.0); |
| 84 |
checki (f1_val, 14); |
| 85 |
checkd (f2_val, 15.0); |
| 86 |
DEBUG_NL; |
| 87 |
DEBUG_FPUTS ("test2f: "); |
| 88 |
test2f (f1, 16, f2, 17.0); |
| 89 |
checki (f1_val, 16); |
| 90 |
checkd (f2_val, 17.0); |
| 91 |
DEBUG_NL; |
| 92 |
DEBUG_FPUTS ("test2g: "); |
| 93 |
test2g (f1, 18, 19.0, f2); |
| 94 |
checki (f1_val, 18); |
| 95 |
checkd (f2_val, 19.0); |
| 96 |
DEBUG_NL; |
| 97 |
DEBUG_FPUTS ("test2h: "); |
| 98 |
test2h (20.0, f2, f1, 21); |
| 99 |
checkd (f2_val, 20.0); |
| 100 |
checki (f1_val, 21); |
| 101 |
DEBUG_NL; |
| 102 |
DEBUG_FPUTS ("test2i: "); |
| 103 |
test2i (22.0, f2, 23, f1); |
| 104 |
checkd (f2_val, 22.0); |
| 105 |
checki (f1_val, 23); |
| 106 |
DEBUG_NL; |
| 107 |
DEBUG_FPUTS ("test2j: "); |
| 108 |
test2j (24, 25.0, f1, f2); |
| 109 |
checki (f1_val, 24); |
| 110 |
checkd (f2_val, 25.0); |
| 111 |
if (test_va) |
| 112 |
{ |
| 113 |
DEBUG_NL; |
| 114 |
DEBUG_FPUTS ("testva: "); |
| 115 |
testva (1, f1); |
| 116 |
DEBUG_NL; |
| 117 |
DEBUG_FPUTS (" "); |
| 118 |
testva (2, f1, f1); |
| 119 |
DEBUG_NL; |
| 120 |
DEBUG_FPUTS (" "); |
| 121 |
testva (3, f1, f1, f1); |
| 122 |
DEBUG_NL; |
| 123 |
DEBUG_FPUTS (" "); |
| 124 |
testva (4, f1, f1, f1, f1); |
| 125 |
DEBUG_NL; |
| 126 |
DEBUG_FPUTS (" "); |
| 127 |
testva (5, f1, f1, f1, f1, f1); |
| 128 |
DEBUG_NL; |
| 129 |
DEBUG_FPUTS (" "); |
| 130 |
testva (6, f1, f1, f1, f1, f1, f1); |
| 131 |
DEBUG_NL; |
| 132 |
DEBUG_FPUTS (" "); |
| 133 |
testva (7, f1, f1, f1, f1, f1, f1, f1); |
| 134 |
DEBUG_NL; |
| 135 |
DEBUG_FPUTS (" "); |
| 136 |
testva (8, f1, f1, f1, f1, f1, f1, f1, f1); |
| 137 |
DEBUG_NL; |
| 138 |
DEBUG_FPUTS (" "); |
| 139 |
testva (9, f1, f1, f1, f1, f1, f1, f1, f1, f1); |
| 140 |
DEBUG_NL; |
| 141 |
DEBUG_FPUTS (" "); |
| 142 |
testva (10, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); |
| 143 |
DEBUG_NL; |
| 144 |
DEBUG_FPUTS (" "); |
| 145 |
testva (11, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); |
| 146 |
DEBUG_NL; |
| 147 |
DEBUG_FPUTS (" "); |
| 148 |
testva (12, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); |
| 149 |
} |
| 150 |
DEBUG_NL; |
| 151 |
} |
| 152 |
|
| 153 |
void |
| 154 |
fnptr_by_value_1_x () |
| 155 |
{ |
| 156 |
DEBUG_INIT |
| 157 |
testit (); |
| 158 |
DEBUG_FINI |
| 159 |
|
| 160 |
if (fails != 0) |
| 161 |
abort (); |
| 162 |
} |