annotate test/tstdarg.c @ 896:d712ee10feb7

local_nptr for locally defined struct
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Apr 2014 19:20:58 +0900
parents 5313ed059cee
children
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
811
4c13e6784414 i64 stdarg (is this correct?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
6 #if 0
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
7 void
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
8 print(__builtin_va_list *ap)
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
9 {
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
10 #if 0
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
11 printf(
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
12 " long long_last %0lx; \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
13 " long float_first %0lx; \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
14 " long float_last %0lx; \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
15 " long stack_top %0lx; \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
16 " long arg %0lx; \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
17 " long top %0lx; \n",
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
18 ap->long_last ,
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
19 ap->float_first ,
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
20 ap->float_last ,
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
21 ap->stack_top ,
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
22 ap->arg ,
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
23 ap->top );
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
24 #endif
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
25 }
811
4c13e6784414 i64 stdarg (is this correct?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
26 #else
4c13e6784414 i64 stdarg (is this correct?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
27 #define print(d)
4c13e6784414 i64 stdarg (is this correct?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
28 #endif
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
29
575
a4445cb1aa91 Example filex.
kono
parents: 540
diff changeset
30 void
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
31 var_args(char *numtypes, ...)
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
32 {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
33 int t;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
34 int i;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
35 float f;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
36 double d;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
37 long long l;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
38 char *s;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
39 va_list ap;
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
40
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
41 va_start(ap,numtypes);
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
42 print(&ap);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
43 while((t= *numtypes++)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
44 if (t=='i') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
45 i = va_arg(ap,int);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
46 printf("#0045:int arg: %d\n",i);
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
47 print(&ap);
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 741
diff changeset
48
741
ebf5ae3f3863 i64 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 575
diff changeset
49 #if 0 /* ‘float’ is promoted to ‘double’ when passed through ‘...’ */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
50 } else if (t=='f') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
51 f = va_arg(ap,float);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
52 printf("#0051:float arg: %g\n",f);
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
53 #endif
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
54 } else if (t=='d') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
55 d = va_arg(ap,double);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
56 printf("#0055:double arg: %g\n",d);
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
57 print(&ap);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
58 } else if (t=='l') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
59 l = va_arg(ap,long long);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
60 printf("#0059:long long arg: %lld\n",l);
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
61 print(&ap);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
62 } else if (t=='s') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
63 s = va_arg(ap,char *);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
64 printf("#0063:char *arg: %s\n",s);
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
65 print(&ap);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
66 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
67 s = va_arg(ap,char *);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
68 printf("#0067:arg: error\n");
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
69 print(&ap);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
70 }
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
71 }
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
72 }
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
73
540
fe37f32b552b include_next, macro_function eat 1 char.
kono
parents: 427
diff changeset
74 int
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
75 main()
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
76 {
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
77
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
78 var_args("iiiiii",1,2,3,4,5,6);
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
79 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
80 #if 0
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
81 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
82 #endif
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
83 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
84 var_args("ssssss","1","2","3","4","5","6");
306
1ec915dcd2d1 struct return size error
kono
parents: 305
diff changeset
85 return 0;
285
912b54949344 register assop const ( int/long )
kono
parents:
diff changeset
86 }