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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [fixed-point/] [func-vararg-mixed.c] - Blame information for rev 753

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=gnu99" } */
3
 
4
/* C99 6.5.2.2 Function calls.
5
   Test passing varargs of fixed-point types.
6
   Based on the test from ../dfp/.  */
7
 
8
#include <stdarg.h>
9
 
10
extern void abort (void);
11
 
12
static int
13
vararg_int (unsigned arg, ...)
14
{
15
  va_list ap;
16
  int result_i;
17
  va_start (ap, arg);
18
  result_i = va_arg (ap, int);
19
  return result_i;
20
}
21
 
22
static _Fract
23
vararg_fract (unsigned arg, ...)
24
{
25
  va_list ap;
26
  int result_i;
27
  _Fract result_fr; \
28
  va_start (ap, arg);
29
  result_i = va_arg (ap, int);
30
  result_fr = va_arg (ap, _Fract); \
31
  return result_fr;
32
}
33
 
34
static int
35
vararg_double (unsigned arg, ...)
36
{
37
  va_list ap;
38
  int result_i;
39
  _Fract result_fr; \
40
  double result_d;
41
  va_start (ap, arg);
42
  result_i = va_arg (ap, int);
43
  result_fr = va_arg (ap, _Fract); \
44
  result_d = va_arg (ap, double); \
45
  return result_d;
46
}
47
 
48
#define FUNC(TYPE, NAME) \
49
static TYPE \
50
vararg_ ## NAME (unsigned arg, ...) \
51
{ \
52
  va_list ap; \
53
  int result_i; \
54
  _Fract result_fr; \
55
  double result_d; \
56
  TYPE result; \
57
  va_start (ap, arg); \
58
  result_i = va_arg (ap, int); \
59
  result_fr = va_arg (ap, _Fract); \
60
  result_d = va_arg (ap, double); \
61
  result = va_arg (ap, TYPE); \
62
  va_end (ap); \
63
  return result; \
64
}
65
 
66
FUNC (short _Fract, sf)
67
FUNC (_Fract, f)
68
FUNC (long _Fract, lf)
69
FUNC (long long _Fract, llf)
70
FUNC (unsigned short _Fract, usf)
71
FUNC (unsigned _Fract, uf)
72
FUNC (unsigned long _Fract, ulf)
73
FUNC (unsigned long long _Fract, ullf)
74
FUNC (_Sat short _Fract, Ssf)
75
FUNC (_Sat _Fract, Sf)
76
FUNC (_Sat long _Fract, Slf)
77
FUNC (_Sat long long _Fract, Sllf)
78
FUNC (_Sat unsigned short _Fract, Susf)
79
FUNC (_Sat unsigned _Fract, Suf)
80
FUNC (_Sat unsigned long _Fract, Sulf)
81
FUNC (_Sat unsigned long long _Fract, Sullf)
82
FUNC (short _Accum, sa)
83
FUNC (_Accum, a)
84
FUNC (long _Accum, la)
85
FUNC (long long _Accum, lla)
86
FUNC (unsigned short _Accum, usa)
87
FUNC (unsigned _Accum, ua)
88
FUNC (unsigned long _Accum, ula)
89
FUNC (unsigned long long _Accum, ulla)
90
FUNC (_Sat short _Accum, Ssa)
91
FUNC (_Sat _Accum, Sa)
92
FUNC (_Sat long _Accum, Sla)
93
FUNC (_Sat long long _Accum, Slla)
94
FUNC (_Sat unsigned short _Accum, Susa)
95
FUNC (_Sat unsigned _Accum, Sua)
96
FUNC (_Sat unsigned long _Accum, Sula)
97
FUNC (_Sat unsigned long long _Accum, Sulla)
98
 
99
int main()
100
{
101
#define TEST(NAME,PF) \
102
  if (vararg_int  (0, 100, 0.9r, 55.0, 0.2 ## PF) != 100) \
103
    abort (); \
104
  if (vararg_fract  (1, 100, 0.9r, 55.0, 0.2 ## PF) != 0.9r) \
105
    abort (); \
106
  if (vararg_double  (2, 100, 0.9r, 55.0, 0.2 ## PF) != 55.0) \
107
    abort (); \
108
  if (vararg_ ## NAME (3, 100, 0.9r, 55.0, 0.2 ## PF) != 0.2 ## PF) \
109
    abort (); \
110
 
111
  TEST(sf, hr)
112
  TEST(f, r)
113
  TEST(lf, lr)
114
  TEST(llf, llr)
115
  TEST(usf, uhr)
116
  TEST(uf, ur)
117
  TEST(ulf, ulr)
118
  TEST(ullf, ullr)
119
  TEST(Ssf, hr)
120
  TEST(Sf, r)
121
  TEST(Slf, lr)
122
  TEST(Sllf, llr)
123
  TEST(Susf, uhr)
124
  TEST(Suf, ur)
125
  TEST(Sulf, ulr)
126
  TEST(Sullf, ullr)
127
  TEST(sa, hk)
128
  TEST(a, k)
129
  TEST(la, lk)
130
  TEST(lla, llk)
131
  TEST(usa, uhk)
132
  TEST(ua, uk)
133
  TEST(ula, ulk)
134
  TEST(ulla, ullk)
135
  TEST(Ssa, hk)
136
  TEST(Sa, k)
137
  TEST(Sla, lk)
138
  TEST(Slla, llk)
139
  TEST(Susa, uhk)
140
  TEST(Sua, uk)
141
  TEST(Sula, ulk)
142
  TEST(Sulla, ullk)
143
 
144
  return 0;
145
}

powered by: WebSVN 2.1.0

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