OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [vmx/] [varargs-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
#include <altivec.h>
2
#include <stdarg.h>
3
#include <stdio.h>
4
 
5
typedef vector unsigned int T;
6
 
7
extern void f1(int, ...);
8
extern void f2(int, T, ...);
9
extern void f3(int, T, T, ...);
10
extern void f4(int, T, T, T);
11
 
12
void printx(T a)
13
{
14
  union {
15
    T v;
16
    unsigned int a[4];
17
  } u;
18
  u.v = a;
19
  printf("%d, %d, %d, %d\n", u.a[0], u.a[1], u.a[2], u.a[3]);
20
}
21
 
22
void f1(int a, ...)
23
{
24
  va_list ap;
25
  va_start (ap, a);
26
  while (a-- > 0)
27
    printx(va_arg(ap, T));
28
  va_end (ap);
29
}
30
 
31
void f2(int a, T b, ...)
32
{
33
  va_list ap;
34
  printx(b);
35
  a--;
36
  va_start (ap, b);
37
  while (a-- > 0)
38
    printx(va_arg(ap, T));
39
  va_end (ap);
40
}
41
 
42
void f3(int a, T b, T c, ...)
43
{
44
  va_list ap;
45
  printx(b);
46
  a--;
47
  printx(c);
48
  a--;
49
  va_start (ap, c);
50
  while (a-- > 0)
51
    printx(va_arg(ap, T));
52
  va_end (ap);
53
}
54
 
55
void f4(int a, T b, T c,
56
        T d)
57
{
58
  printx(b);
59
  a--;
60
  printx(c);
61
  a--;
62
  printx(d);
63
  a--;
64
}
65
 
66
int main()
67
{
68
  f4 (3,
69
      ((T){1,1,1,1}),
70
      ((T){2,2,2,2}),
71
      ((T){3,3,3,3}));
72
  f3 (3,
73
      ((T){4,4,4,4}),
74
      ((T){5,5,5,5}),
75
      ((T){6,6,6,6}));
76
  f2 (3,
77
      ((T){7,7,7,7}),
78
      ((T){8,8,8,8}),
79
      ((T){9,9,9,9}));
80
  f1 (3,
81
      ((T){10,10,10,10}),
82
      ((T){11,11,11,11}),
83
      ((T){12,12,12,12}));
84
  return 0;
85
}
86
 
87
/* { dg-output "1, 1, 1, 1(\n|\r\n|\r)" }
88
   { dg-output "2, 2, 2, 2(\n|\r\n|\r)" }
89
   { dg-output "3, 3, 3, 3(\n|\r\n|\r)" }
90
   { dg-output "4, 4, 4, 4(\n|\r\n|\r)" }
91
   { dg-output "5, 5, 5, 5(\n|\r\n|\r)" }
92
   { dg-output "6, 6, 6, 6(\n|\r\n|\r)" }
93
   { dg-output "7, 7, 7, 7(\n|\r\n|\r)" }
94
   { dg-output "8, 8, 8, 8(\n|\r\n|\r)" }
95
   { dg-output "9, 9, 9, 9(\n|\r\n|\r)" }
96
   { dg-output "10, 10, 10, 10(\n|\r\n|\r)" }
97
   { dg-output "11, 11, 11, 11(\n|\r\n|\r)" }
98
   { dg-output "12, 12, 12, 12(\n|\r\n|\r)" }
99
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.