annotate test/tstdarg.c @ 751:c921670e2ce8

i64 continue... 64bit register
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 14 Nov 2010 04:56:02 +0900
parents ebf5ae3f3863
children 032dc03be02e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
1
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
2
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
3 #include <stdio.h>
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
4 #include <stdarg.h>
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
5
575
a4445cb1aa91 Example filex.
kono
parents: 540
diff changeset
6 void
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
7 var_args(char *numtypes, ...)
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
8 {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
9 int t;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
10 int i;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
11 float f;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
12 double d;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
13 long long l;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
14 char *s;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
15 va_list ap;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
16
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
17 va_start(ap,numtypes);
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
18
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
19 while((t= *numtypes++)) {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
20 if (t=='i') {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
21 i = va_arg(ap,int);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
22 printf("#0021:int arg: %d\n",i);
741
ebf5ae3f3863 i64 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
23 #if 0 /* ‘float’ is promoted to ‘double’ when passed through ‘...’ */
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
24 } else if (t=='f') {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
25 f = va_arg(ap,float);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
26 printf("#0025:float arg: %g\n",f);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
27 #endif
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
28 } else if (t=='d') {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
29 d = va_arg(ap,double);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
30 printf("#0029:double arg: %g\n",d);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
31 } else if (t=='l') {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
32 l = va_arg(ap,long long);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
33 printf("#0032:long long arg: %lld\n",l);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
34 } else if (t=='s') {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
35 s = va_arg(ap,char *);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
36 printf("#0035:char *arg: %s\n",s);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
37 } else {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
38 s = va_arg(ap,char *);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 306
diff changeset
39 printf("#0038:arg: error\n");
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
40 }
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
41 }
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
42 }
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
43
540
fe37f32b552b include_next, macro_function eat 1 char.
kono
parents: 427
diff changeset
44 int
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
45 main()
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
46 {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
47
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
48 var_args("iiiiii",1,2,3,4,5,6);
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
49 var_args("llllll",(long long)1,(long long)2,(long long)3,(long long)4,(long long)5,(long long)6);
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 285
diff changeset
50 #if 0
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
51 var_args("ffffff",(float)1,(float)2,(float)3,(float)4,(float)5,(float)6);
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 285
diff changeset
52 #endif
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
53 var_args("dddddd",(double)1,(double)2,(double)3,(double)4,(double)5,(double)6);
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
54 var_args("ssssss","1","2","3","4","5","6");
306
1ec915dcd2d1 struct return size error
kono
parents: 305
diff changeset
55 return 0;
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
56 }