1 #include <stdio.h>
2 #include <limits.h>
3 
4 /*
5  * This testcase mostly tests mixing of different sized arguments
6  * It only uses constants as arguments
7  */
8 
9 /*
10  * Test mixing of fp arguments (this is useful for multi-fpr architectures)
11  */
12 void
test0(float a0,double a1,long double a2,float a3,float a4,long double a5,double a6,float a7,double a8,long double a9)13 test0(float a0, double a1, long double a2, float a3, float a4, long double a5, double a6, float a7, double a8, long double a9) {
14 	puts("test2");  /* flush registers/stack */
15 	printf("%f %f %Lf %f %f %Lf %f %f %f %Lf\n",
16 		 a0, a1, a2, a3, a4, a5, a6, a7, a8 , a9);
17 }
18 
19 /*
20  * Mix fp with long and medium integers
21 */
22 void
test1(float a0,long long a1,unsigned long a2,float a3,long double a4,int a5,double a6,long double a7,long long a8)23 test1(float a0, long long a1, unsigned long a2, float a3, long double a4, int a5, double a6, long double a7, long long a8) {
24 	puts("test1");
25 	printf("%f %lld %lu %f %Lf %d %f %Lf %lld\n",
26 		a0, a1, a2, a3, a4, a5, a6, a7, a8);
27 }
28 
29 /*
30  * Mix short integers
31  */
32 void
test2(short a0,long long a1,signed char a2,int a3,long a4,long long a5,signed char a6,short a7,int a8,short a9,unsigned char a10)33 test2(short a0, long long a1, signed char a2, int a3, long a4, long long a5, signed char a6, short a7, int a8, short a9, unsigned char a10) {
34 	puts("test2");
35 	printf("%d %lld %d %d %ld %lld %d %d %d %d %d\n",
36 		a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
37 }
38 
39 /*
40  * Mix arithmetic
41  */
42 void
test3(long double a0,signed char a1,double a2,float a3,long long a4,unsigned short a5,double a6,long double a7,short a8,float a9,float a10)43 test3(long double a0, signed char a1, double a2, float a3, long long a4, unsigned short a5, double a6, long double a7, short a8, float a9, float a10) {
44 	puts("test3");
45 	printf("%Lf %d %f %f %lld %u %f %Lf %d %f %f\n",
46 		a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
47 }
48 
49 
50 /*
51  * Throw in structs and unions. Note that we are testing for internal consistency
52  * here, not system ABI compatibility.
53  */
54 struct foo {
55 	char	*p;
56 	char	x;
57 	float	f;
58 	char	alignme[77];
59 };
60 
61 struct bar {
62 	char	c;
63 	char	*p;
64 };
65 
66 void
test4(int x,struct foo f,void * y,short s,long long ll,int i,short s2,short s3,short s4,signed char sc,struct foo f2,struct foo f3,struct bar b,struct foo f4,char * end)67 test4(int x, struct foo f, void *y, short s, long long ll, int i, short s2, short s3, short s4, signed char sc, struct foo f2, struct foo f3,
68 	struct bar b, struct foo f4, char *end) {
69 	puts("test4");
70 	printf("%d %d %d %lld %d %d %d %d %d\n", x, *(char *)y, s, ll, i, s2, s3, s4, sc);
71 	printf("%s %d %f %s\n", f.p, f.x, f.f, f.alignme);
72 	printf("%s %d %f %s\n", f2.p, f2.x, f2.f, f2.alignme);
73 	printf("%s %d %f %s\n", f3.p, f3.x, f3.f, f3.alignme);
74 	printf("%c\n", b.c, b.p);
75 	printf("%s %d %f %s\n", f4.p, f4.x, f4.f, f4.alignme);
76 	puts(end);
77 }
78 
79 int
main()80 main() {
81 	struct foo	f, f2, f3, f4;
82 	struct bar	b;
83 
84 	test0(1.1f, 2.2, 3.3L, 4.4f, 5.5f, 6.6L, 7.7, 8.8f, 9.9, 10.1L);
85 	test1(1.1f, INT_MAX * 2LL, 3lu, 4.4f, 5.5L, 6, 7.7, 8.8L, INT_MAX + 3522LL);
86 	test2(SHRT_MAX, INT_MAX + 222222ll, SCHAR_MAX, 4, LONG_MAX, 353522222234222ll, SCHAR_MAX - 3, SHRT_MAX / 2, 333, 2222, 111);
87 	test3(1111.3522L, -32, 43444.22222, 123.36f, 22525225663333, 1555, 555.225, 7777.22222L, 124, 533.24f, 588.2f);
88 
89 	f.p = "f0";
90 	f.x = 1;
91 	f.f = 1.1;
92 	strcpy(f.alignme, "\thello world");
93 
94 	f2.p = "f1";
95 	f2.x = 2;
96 	f2.f = 2.2;
97 	strcpy(f2.alignme, "\tit is a good day");
98 
99 	f3.p = "f2";
100 	f3.x = 3;
101 	f3.f = 3.3;
102 	strcpy(f3.alignme, "\tto get some");
103 
104 	f4.p = "f3";
105 	f4.x = 4;
106 	f4.f = 4.4;
107 	strcpy(f4.alignme, "\ttesting and debugging done");
108 
109 	b.c = 'x';
110 	b.p = "hmmm lol";
111 	test4(1, f, &f2.x, 3, 44444444443333ll, 5, 3263, 2255, 442, -32, f2, f3, b, f4, "the end");
112 	return 0;
113 }
114 
115